From 3d32320a3302e3c37cc129f358512d9c39f8c435 Mon Sep 17 00:00:00 2001 From: Intelli Date: Mon, 17 Jun 2024 18:31:33 -0600 Subject: [PATCH] Added support for MC 1.21 block/entity types --- .github/workflows/build.yml | 8 +++--- build.gradle | 4 +-- pom.xml | 4 +-- .../net/coreprotect/bukkit/BukkitAdapter.java | 6 ++++- .../net/coreprotect/bukkit/Bukkit_v1_21.java | 25 +++++++++++++++++++ .../player/PlayerInteractListener.java | 6 +++++ .../net/coreprotect/paper/PaperAdapter.java | 2 ++ .../net/coreprotect/spigot/SpigotAdapter.java | 2 ++ .../java/net/coreprotect/utility/Util.java | 2 ++ 9 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 24aa094a..ef2d4132 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/build.gradle b/build.gradle index 727d0194..d22c2de8 100644 --- a/build.gradle +++ b/build.gradle @@ -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' } diff --git a/pom.xml b/pom.xml index e9424cee..966b88ee 100755 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ com.intellectualsites.bom bom-newest - 1.44 + 1.45 import pom @@ -122,7 +122,7 @@ io.papermc.paper paper-api - 1.20.4-R0.1-SNAPSHOT + 1.21-R0.1-SNAPSHOT provided diff --git a/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java b/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java index 9818afd7..59c5878a 100644 --- a/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java +++ b/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java @@ -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) { @@ -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; } } diff --git a/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java b/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java new file mode 100644 index 00000000..4b133b5d --- /dev/null +++ b/src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java @@ -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); + } + } + } + +} diff --git a/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java b/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java index 6faf5c3f..9a95afc1 100755 --- a/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java +++ b/src/main/java/net/coreprotect/listener/player/PlayerInteractListener.java @@ -835,6 +835,12 @@ else if (type == Material.DRAGON_EGG) { if (event.useItemInHand() != Event.Result.DENY) { List 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(); diff --git a/src/main/java/net/coreprotect/paper/PaperAdapter.java b/src/main/java/net/coreprotect/paper/PaperAdapter.java index e0933d5a..e510aea2 100644 --- a/src/main/java/net/coreprotect/paper/PaperAdapter.java +++ b/src/main/java/net/coreprotect/paper/PaperAdapter.java @@ -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; @@ -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; diff --git a/src/main/java/net/coreprotect/spigot/SpigotAdapter.java b/src/main/java/net/coreprotect/spigot/SpigotAdapter.java index 175f7dab..04602fac 100644 --- a/src/main/java/net/coreprotect/spigot/SpigotAdapter.java +++ b/src/main/java/net/coreprotect/spigot/SpigotAdapter.java @@ -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; @@ -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; diff --git a/src/main/java/net/coreprotect/utility/Util.java b/src/main/java/net/coreprotect/utility/Util.java index 625cd1bb..7014d7d4 100755 --- a/src/main/java/net/coreprotect/utility/Util.java +++ b/src/main/java/net/coreprotect/utility/Util.java @@ -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); }