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
This commit is contained in:
tastybento 2021-06-20 12:18:10 -07:00 committed by GitHub
parent cc43dbfabe
commit c2e832095a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 77 additions and 58 deletions

View File

@ -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

49
pom.xml
View File

@ -63,21 +63,21 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<java.version>16</java.version>
<!-- Non-minecraft related dependencies -->
<powermock.version>2.0.4</powermock.version>
<mongodb.version>3.8.0</mongodb.version>
<powermock.version>2.0.9</powermock.version>
<mongodb.version>3.12.8</mongodb.version>
<!-- More visible way to change dependency versions -->
<spigot.version>1.16.4-R0.1-SNAPSHOT</spigot.version>
<spigot.version>1.17-R0.1-SNAPSHOT</spigot.version>
<!-- Might differ from the last Spigot release for short periods
of time -->
<paper.version>1.16.4-R0.1-SNAPSHOT</paper.version>
<bstats.version>2.1.0</bstats.version>
<paper.version>1.16.5-R0.1-SNAPSHOT</paper.version>
<bstats.version>2.2.1</bstats.version>
<vault.version>1.7</vault.version>
<placeholderapi.version>2.10.9</placeholderapi.version>
<githubapi.version>d5f5e0bbd8</githubapi.version>
<dynmap.version>3.0-SNAPSHOT</dynmap.version>
<worldedit.version>7.0.0</worldedit.version>
<worldedit.version>7.2.5</worldedit.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- Do not change unless you want different name for local builds. -->
@ -154,6 +154,12 @@
</profiles>
<repositories>
<repository>
<!-- This is a temporary reference as the Maven Shade plugin
that supports Java 16 is not released yet -->
<id>maven-snapshots</id>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
@ -203,7 +209,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${spigot.version}</version>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Metrics -->
@ -216,7 +222,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.1.0</version>
<version>3.11.1</version>
<scope>test</scope>
</dependency>
<dependency>
@ -283,7 +289,7 @@
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.annotation</artifactId>
<version>2.2.200</version>
<version>2.2.600</version>
</dependency>
<!-- PaperLib -->
<dependency>
@ -296,7 +302,7 @@
<dependency>
<groupId>com.github.apachezy</groupId>
<artifactId>LangUtils</artifactId>
<version>3.1.3</version>
<version>3.2.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
@ -333,21 +339,26 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<release>16</release>
<!-- <source>${java.version}</source> <target>${java.version}</target> -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.0.0-M5</version>
<configuration>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -357,7 +368,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<version>3.3.0</version>
<configuration>
<source>8</source>
<show>private</show>
@ -393,7 +404,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<version>3.3.0-SNAPSHOT</version>
<configuration>
<minimizeJar>true</minimizeJar>
<relocations>
@ -412,6 +423,8 @@
</relocations>
<artifactSet>
<excludes>
<exclude>org.apache.maven.shared:*</exclude>
<exclude>org.apache.maven:*</exclude>
<exclude>com.google.code.gson:*</exclude>
<exclude>org.mongodb:*</exclude>
<exclude>org.eclipse.jdt:*</exclude>
@ -449,7 +462,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<version>0.8.7</version>
<configuration>
<append>true</append>
<excludes>

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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"]

View File

@ -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