From ed9db8d9289a64f7e2da560bb4ff1bd973a319cd Mon Sep 17 00:00:00 2001 From: MinusKube Date: Wed, 12 Oct 2022 23:48:30 +0200 Subject: [PATCH] Add support for 1.18 and 1.19, update version to 1.2.3 --- README.md | 6 +++--- build.gradle | 2 +- .../netherboard/bukkit/util/NMS.java | 21 ++++++++++++------- bukkit/src/main/resources/plugin.yml | 2 +- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 35ab129..db1482a 100644 --- a/README.md +++ b/README.md @@ -83,10 +83,10 @@ repositories { } dependencies { - compile 'fr.minuskube:netherboard-bukkit:1.2.2' + compile 'fr.minuskube:netherboard-bukkit:1.2.3' // Or if you use Sponge: - // compile 'fr.minuskube:netherboard-sponge:1.2.2' + // compile 'fr.minuskube:netherboard-sponge:1.2.3' } ``` @@ -102,7 +102,7 @@ dependencies { netherboard-sponge --> - 1.2.2 + 1.2.3 ``` diff --git a/build.gradle b/build.gradle index 7ab8b7a..355eb1c 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ subprojects { sourceCompatibility = '1.8' group 'fr.minuskube' - version '1.2.2' + version '1.2.3' repositories { mavenCentral() diff --git a/bukkit/src/main/java/fr/minuskube/netherboard/bukkit/util/NMS.java b/bukkit/src/main/java/fr/minuskube/netherboard/bukkit/util/NMS.java index def91a3..9dcfcea 100644 --- a/bukkit/src/main/java/fr/minuskube/netherboard/bukkit/util/NMS.java +++ b/bukkit/src/main/java/fr/minuskube/netherboard/bukkit/util/NMS.java @@ -73,15 +73,18 @@ public class NMS { Class playerConnectionClass = getClass("net.minecraft.server.network", "PlayerConnection"); Class packetClass = getClass("net.minecraft.network.protocol", "Packet"); - sbScore = scoreClass.getConstructor(sbClass, objClass, String.class); - sbScoreSet = scoreClass.getMethod("setScore", int.class); - packetObj = packetObjClass.getConstructor(objClass, int.class); - packetDisplay = packetDisplayClass.getConstructor(int.class, objClass); - sendPacket = playerConnectionClass.getMethod("sendPacket", packetClass); + if (VERSION.isBelow1_18()) { + sbScoreSet = scoreClass.getMethod("setScore", int.class); + sendPacket = playerConnectionClass.getMethod("sendPacket", packetClass); + } + else { + sbScoreSet = scoreClass.getMethod("a", int.class); + sendPacket = playerConnectionClass.getMethod("a", packetClass); + } if (VERSION.isBelow1_17()) { playerScores = sbClass.getDeclaredField("playerScores"); @@ -158,9 +161,7 @@ public static Object getHandle(Object obj) throws NoSuchMethodException, if(!HANDLES.containsKey(clazz)) { Method method = clazz.getDeclaredMethod("getHandle"); - - if(!method.isAccessible()) - method.setAccessible(true); + method.setAccessible(true); HANDLES.put(clazz, method); } @@ -213,6 +214,10 @@ public boolean isBelow1_17() { major.equals("1.16"); } + public boolean isBelow1_18() { + return major.equals("1.17") || isBelow1_17(); + } + } } diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 1507f9a..bd967de 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: Netherboard -version: 1.2.2 +version: 1.2.3 description: Scoreboard API for your Bukkit Plugins. author: MinusKube website: https://github.com/MinusKube/netherboard