Skip to content

Commit

Permalink
Added support for MC 1.21 block/entity types
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelli committed Jun 18, 2024
1 parent 3e8083b commit 3d32320
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v2
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Cache Maven packages
uses: actions/cache@v1
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ repositories {
}

dependencies {
implementation(platform("com.intellectualsites.bom:bom-newest:1.44")) // Ref: https://github.com/IntellectualSites/bom
implementation(platform("com.intellectualsites.bom:bom-newest:1.45")) // Ref: https://github.com/IntellectualSites/bom
compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Core")
compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Bukkit")
compileOnly 'io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT'
compileOnly 'io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT'
implementation 'org.bstats:bstats-bukkit-lite:1.8'
implementation 'com.zaxxer:HikariCP:5.0.1'
}
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<dependency>
<groupId>com.intellectualsites.bom</groupId>
<artifactId>bom-newest</artifactId> <!-- Ref: https://github.com/IntellectualSites/bom -->
<version>1.44</version>
<version>1.45</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand All @@ -122,7 +122,7 @@
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/net/coreprotect/bukkit/BukkitAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class BukkitAdapter implements BukkitInterface {
public static final int BUKKIT_V1_18 = 18;
public static final int BUKKIT_V1_19 = 19;
public static final int BUKKIT_V1_20 = 20;
public static final int BUKKIT_V1_21 = 21;

public static void loadAdapter() {
switch (ConfigHandler.SERVER_VERSION) {
Expand All @@ -63,9 +64,12 @@ public static void loadAdapter() {
BukkitAdapter.ADAPTER = new Bukkit_v1_19();
break;
case BUKKIT_V1_20:
default:
BukkitAdapter.ADAPTER = new Bukkit_v1_20();
break;
case BUKKIT_V1_21:
default:
BukkitAdapter.ADAPTER = new Bukkit_v1_21();
break;
}
}

Expand Down
25 changes: 25 additions & 0 deletions src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.coreprotect.bukkit;

import org.bukkit.Material;
import org.bukkit.Tag;

import net.coreprotect.model.BlockGroup;

public class Bukkit_v1_21 extends Bukkit_v1_20 implements BukkitInterface {

public Bukkit_v1_21() {
for (Material value : Tag.TRAPDOORS.getValues()) {
if (value == Material.IRON_TRAPDOOR) {
continue;
}

if (!BlockGroup.INTERACT_BLOCKS.contains(value)) {
BlockGroup.INTERACT_BLOCKS.add(value);
}
if (!BlockGroup.SAFE_INTERACT_BLOCKS.contains(value)) {
BlockGroup.SAFE_INTERACT_BLOCKS.add(value);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,12 @@ else if (type == Material.DRAGON_EGG) {

if (event.useItemInHand() != Event.Result.DENY) {
List<Material> entityBlockTypes = Arrays.asList(Material.ARMOR_STAND, Material.END_CRYSTAL, Material.BOW, Material.CROSSBOW, Material.TRIDENT, Material.EXPERIENCE_BOTTLE, Material.SPLASH_POTION, Material.LINGERING_POTION, Material.ENDER_PEARL, Material.FIREWORK_ROCKET, Material.EGG, Material.SNOWBALL);
try {
entityBlockTypes.add(Material.valueOf("WIND_CHARGE"));
}
catch (Exception e) {
// not running MC 1.21+
}
ItemStack handItem = null;
ItemStack mainHand = player.getInventory().getItemInMainHand();
ItemStack offHand = player.getInventory().getItemInOffHand();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/coreprotect/paper/PaperAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class PaperAdapter implements PaperInterface {
public static final int PAPER_V1_18 = BukkitAdapter.BUKKIT_V1_18;
public static final int PAPER_V1_19 = BukkitAdapter.BUKKIT_V1_19;
public static final int PAPER_V1_20 = BukkitAdapter.BUKKIT_V1_20;
public static final int PAPER_V1_21 = BukkitAdapter.BUKKIT_V1_21;

public static void loadAdapter() {
int paperVersion = ConfigHandler.SERVER_VERSION;
Expand All @@ -48,6 +49,7 @@ public static void loadAdapter() {
PaperAdapter.ADAPTER = new Paper_v1_17();
break;
case PAPER_V1_20:
case PAPER_V1_21:
default:
PaperAdapter.ADAPTER = new Paper_v1_20();
break;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/coreprotect/spigot/SpigotAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class SpigotAdapter implements SpigotInterface {
public static final int SPIGOT_V1_18 = BukkitAdapter.BUKKIT_V1_18;
public static final int SPIGOT_V1_19 = BukkitAdapter.BUKKIT_V1_19;
public static final int SPIGOT_V1_20 = BukkitAdapter.BUKKIT_V1_20;
public static final int SPIGOT_V1_21 = BukkitAdapter.BUKKIT_V1_21;

public static void loadAdapter() {
int spigotVersion = ConfigHandler.SERVER_VERSION;
Expand All @@ -42,6 +43,7 @@ public static void loadAdapter() {
case SPIGOT_V1_18:
case SPIGOT_V1_19:
case SPIGOT_V1_20:
case SPIGOT_V1_21:
default:
SpigotAdapter.ADAPTER = new Spigot_v1_16();
break;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/coreprotect/utility/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,8 @@ public static Material getEntityMaterial(EntityType type) {
return Material.EGG;
case "SNOWBALL":
return Material.SNOWBALL;
case "WIND_CHARGE":
return Material.valueOf("WIND_CHARGE");
default:
return BukkitAdapter.ADAPTER.getFrameType(type);
}
Expand Down

0 comments on commit 3d32320

Please sign in to comment.