From c2e832095a4e4b8f1d7e23b5c32d1a7bba87b94c Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 20 Jun 2021 12:18:10 -0700 Subject: [PATCH] Minecraft 1.17 support (#1781) * Java 16 preliminary branch. This compiles, but junit tests fail all over because there is a lack of Java 16 support right now. * Use Java 16 * 1.17 WIP * Require 1.17 * Fixes tests. * WIP fixing tests * Exclude maven from shading * Try update snapshots to build action * Try repo on command line * Remove reference to shade plugin in dependencies --- .github/workflows/build.yml | 6 +-- pom.xml | 49 ++++++++++++------- .../bentobox/bentobox/nms/NMSAbstraction.java | 6 --- .../bentobox/nms/v1_16_R3/NMSHandler.java | 25 ---------- .../bentobox/nms/v1_17_R1/NMSHandler.java | 31 ++++++++++++ .../versions/ServerCompatibility.java | 15 ++++-- src/main/resources/plugin.yml | 2 +- .../clicklisteners/GeoMobLimitTabTest.java | 1 + 8 files changed, 77 insertions(+), 58 deletions(-) delete mode 100644 src/main/java/world/bentobox/bentobox/nms/v1_16_R3/NMSHandler.java create mode 100644 src/main/java/world/bentobox/bentobox/nms/v1_17_R1/NMSHandler.java diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 836d494cd..261665e62 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,10 +13,10 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 8 + - name: Set up JDK 16 uses: actions/setup-java@v1 with: - java-version: 8 + java-version: 16 - name: Cache SonarCloud packages uses: actions/cache@v1 with: @@ -30,7 +30,7 @@ jobs: key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 - name: Build - run: mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install + run: mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install - run: mkdir staging && cp target/*.jar staging - name: Save artifacts uses: actions/upload-artifact@v2 diff --git a/pom.xml b/pom.xml index 2bbbf0839..6d99349c3 100644 --- a/pom.xml +++ b/pom.xml @@ -63,21 +63,21 @@ UTF-8 UTF-8 - 1.8 + 16 - 2.0.4 - 3.8.0 + 2.0.9 + 3.12.8 - 1.16.4-R0.1-SNAPSHOT + 1.17-R0.1-SNAPSHOT - 1.16.4-R0.1-SNAPSHOT - 2.1.0 + 1.16.5-R0.1-SNAPSHOT + 2.2.1 1.7 2.10.9 d5f5e0bbd8 3.0-SNAPSHOT - 7.0.0 + 7.2.5 ${build.version}-SNAPSHOT @@ -154,6 +154,12 @@ + + + maven-snapshots + https://repository.apache.org/content/repositories/snapshots/ + spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots @@ -203,7 +209,7 @@ org.spigotmc spigot - ${spigot.version} + 1.17-R0.1-SNAPSHOT provided @@ -216,7 +222,7 @@ org.mockito mockito-core - 3.1.0 + 3.11.1 test @@ -283,7 +289,7 @@ org.eclipse.jdt org.eclipse.jdt.annotation - 2.2.200 + 2.2.600 @@ -296,7 +302,7 @@ com.github.apachezy LangUtils - 3.1.3 + 3.2.2 provided @@ -333,21 +339,26 @@ org.apache.maven.plugins maven-resources-plugin - 3.1.0 + 3.2.0 org.apache.maven.plugins maven-compiler-plugin 3.8.1 - ${java.version} - ${java.version} + 16 + org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 3.0.0-M5 + + + --illegal-access=permit + + org.apache.maven.plugins @@ -357,7 +368,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.1.1 + 3.3.0 8 private @@ -393,7 +404,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.1 + 3.3.0-SNAPSHOT true @@ -412,6 +423,8 @@ + org.apache.maven.shared:* + org.apache.maven:* com.google.code.gson:* org.mongodb:* org.eclipse.jdt:* @@ -449,7 +462,7 @@ org.jacoco jacoco-maven-plugin - 0.8.4 + 0.8.7 true diff --git a/src/main/java/world/bentobox/bentobox/nms/NMSAbstraction.java b/src/main/java/world/bentobox/bentobox/nms/NMSAbstraction.java index 99eb72a82..24bca0842 100644 --- a/src/main/java/world/bentobox/bentobox/nms/NMSAbstraction.java +++ b/src/main/java/world/bentobox/bentobox/nms/NMSAbstraction.java @@ -1,16 +1,10 @@ package world.bentobox.bentobox.nms; -import org.bukkit.Bukkit; import org.bukkit.Chunk; -import org.bukkit.Material; import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData; - -import net.minecraft.server.v1_16_R3.IBlockData; public interface NMSAbstraction { - static final IBlockData AIR = ((CraftBlockData) Bukkit.createBlockData(Material.AIR)).getState(); /** * Update the low-level chunk information for the given block to the new block ID and data. This diff --git a/src/main/java/world/bentobox/bentobox/nms/v1_16_R3/NMSHandler.java b/src/main/java/world/bentobox/bentobox/nms/v1_16_R3/NMSHandler.java deleted file mode 100644 index 0c69f345c..000000000 --- a/src/main/java/world/bentobox/bentobox/nms/v1_16_R3/NMSHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package world.bentobox.bentobox.nms.v1_16_R3; - -import org.bukkit.Chunk; -import org.bukkit.block.data.BlockData; -import org.bukkit.craftbukkit.v1_16_R3.CraftWorld; -import org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData; - -import net.minecraft.server.v1_16_R3.BlockPosition; -import world.bentobox.bentobox.nms.NMSAbstraction; - -public class NMSHandler implements NMSAbstraction { - - @Override - public void setBlockInNativeChunk(Chunk chunk, int x, int y, int z, BlockData blockData, boolean applyPhysics) { - CraftBlockData craft = (CraftBlockData) blockData; - net.minecraft.server.v1_16_R3.World nmsWorld = ((CraftWorld) chunk.getWorld()).getHandle(); - net.minecraft.server.v1_16_R3.Chunk nmsChunk = nmsWorld.getChunkAt(chunk.getX(), chunk.getZ()); - BlockPosition bp = new BlockPosition((chunk.getX() << 4) + x, y, (chunk.getZ() << 4) + z); - // Setting the block to air before setting to another state prevents some console errors - nmsChunk.setType(bp, AIR, applyPhysics, true); - nmsChunk.setType(bp, craft.getState(), applyPhysics, true); - } - - -} \ No newline at end of file diff --git a/src/main/java/world/bentobox/bentobox/nms/v1_17_R1/NMSHandler.java b/src/main/java/world/bentobox/bentobox/nms/v1_17_R1/NMSHandler.java new file mode 100644 index 000000000..7d807f559 --- /dev/null +++ b/src/main/java/world/bentobox/bentobox/nms/v1_17_R1/NMSHandler.java @@ -0,0 +1,31 @@ +package world.bentobox.bentobox.nms.v1_17_R1; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.block.data.BlockData; +import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_17_R1.block.data.CraftBlockData; + +import net.minecraft.core.BlockPosition; +import net.minecraft.world.level.World; +import net.minecraft.world.level.block.state.IBlockData; +import net.minecraft.world.level.chunk.Chunk; +import world.bentobox.bentobox.nms.NMSAbstraction; + + +public class NMSHandler implements NMSAbstraction { + + private static final IBlockData AIR = ((CraftBlockData) Bukkit.createBlockData(Material.AIR)).getState(); + + @Override + public void setBlockInNativeChunk(org.bukkit.Chunk chunk, int x, int y, int z, BlockData blockData, boolean applyPhysics) { + CraftBlockData craft = (CraftBlockData) blockData; + World nmsWorld = ((CraftWorld) chunk.getWorld()).getHandle(); + Chunk nmsChunk = nmsWorld.getChunkAt(chunk.getX(), chunk.getZ()); + BlockPosition bp = new BlockPosition((chunk.getX() << 4) + x, y, (chunk.getZ() << 4) + z); + // Setting the block to air before setting to another state prevents some console errors + nmsChunk.setType(bp, AIR, applyPhysics, true); + nmsChunk.setType(bp, craft.getState(), applyPhysics, true); + } + +} \ No newline at end of file diff --git a/src/main/java/world/bentobox/bentobox/versions/ServerCompatibility.java b/src/main/java/world/bentobox/bentobox/versions/ServerCompatibility.java index eabdf29f6..9bf1a132c 100644 --- a/src/main/java/world/bentobox/bentobox/versions/ServerCompatibility.java +++ b/src/main/java/world/bentobox/bentobox/versions/ServerCompatibility.java @@ -160,25 +160,30 @@ public class ServerCompatibility { /** * @since 1.14.0 */ - V1_16_1(Compatibility.NOT_SUPPORTED), + V1_16_1(Compatibility.INCOMPATIBLE), /** * @since 1.15.0 */ - V1_16_2(Compatibility.NOT_SUPPORTED), + V1_16_2(Compatibility.INCOMPATIBLE), /** * @since 1.15.1 */ - V1_16_3(Compatibility.NOT_SUPPORTED), + V1_16_3(Compatibility.INCOMPATIBLE), /** * @since 1.15.3 */ - V1_16_4(Compatibility.COMPATIBLE), + V1_16_4(Compatibility.INCOMPATIBLE), /** * @since 1.16.0 */ - V1_16_5(Compatibility.COMPATIBLE) + V1_16_5(Compatibility.INCOMPATIBLE), + + /** + * @since 1.17.0 + */ + V1_17(Compatibility.COMPATIBLE) ; private Compatibility compatibility; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 631731424..a07ee8626 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: BentoBox main: world.bentobox.bentobox.BentoBox version: ${project.version}${build.number} -api-version: "1.15" +api-version: "1.17" authors: [tastybento, Poslovitch] contributors: ["The BentoBoxWorld Community"] diff --git a/src/test/java/world/bentobox/bentobox/listeners/flags/clicklisteners/GeoMobLimitTabTest.java b/src/test/java/world/bentobox/bentobox/listeners/flags/clicklisteners/GeoMobLimitTabTest.java index 818de36b4..e77eb1eec 100644 --- a/src/test/java/world/bentobox/bentobox/listeners/flags/clicklisteners/GeoMobLimitTabTest.java +++ b/src/test/java/world/bentobox/bentobox/listeners/flags/clicklisteners/GeoMobLimitTabTest.java @@ -108,6 +108,7 @@ public class GeoMobLimitTabTest { assertEquals("BAT", list.get(0)); // Click on BAT tab.onClick(panel, user, ClickType.LEFT, 9); + list.forEach(System.out::println); assertEquals(1, list.size()); assertEquals("COW", list.get(0)); // Click on BAT again to have it added