Fix some issues

This commit is contained in:
DaniFoldi 2022-01-03 12:57:00 +01:00
parent 2d5004fede
commit 8bf1815c49
4 changed files with 15 additions and 7 deletions

View File

@ -195,7 +195,7 @@
<dependency> <dependency>
<groupId>org.inventivetalent</groupId> <groupId>org.inventivetalent</groupId>
<artifactId>reflectionhelper</artifactId> <artifactId>reflectionhelper</artifactId>
<version>1.18.4-SNAPSHOT</version> <version>1.18.7-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -182,7 +182,7 @@ public class ShopChest extends JavaPlugin {
case "v1_16_R2": case "v1_16_R2":
case "v1_16_R3": case "v1_16_R3":
case "v1_17_R1": case "v1_17_R1":
//case "v1_18_R1": case "v1_18_R1":
break; break;
default: default:
debug("Server version not officially supported: " + Utils.getServerVersion() + "!"); debug("Server version not officially supported: " + Utils.getServerVersion() + "!");

View File

@ -48,7 +48,7 @@ public class UpdateChecker {
return UpdateCheckerResult.ERROR; return UpdateCheckerResult.ERROR;
} }
if (compareVersion(version) == -1) { if (compareVersion(version) == 1) {
plugin.debug("No update found"); plugin.debug("No update found");
return UpdateCheckerResult.FALSE; return UpdateCheckerResult.FALSE;
} else { } else {

View File

@ -57,7 +57,6 @@ public class Utils {
static Class<?> entityClass = nmsClassResolver.resolveSilent("world.entity.Entity"); static Class<?> entityClass = nmsClassResolver.resolveSilent("world.entity.Entity");
static Class<?> entityArmorStandClass = nmsClassResolver.resolveSilent("world.entity.decoration.EntityArmorStand"); static Class<?> entityArmorStandClass = nmsClassResolver.resolveSilent("world.entity.decoration.EntityArmorStand");
static Class<?> entityItemClass = nmsClassResolver.resolveSilent("world.entity.item.EntityItem"); static Class<?> entityItemClass = nmsClassResolver.resolveSilent("world.entity.item.EntityItem");
static Class<?> itemEntityClass = nmsClassResolver.resolveSilent("world.entity.item.ItemEntity");
static Class<?> dataWatcherClass = nmsClassResolver.resolveSilent("network.syncher.DataWatcher"); static Class<?> dataWatcherClass = nmsClassResolver.resolveSilent("network.syncher.DataWatcher");
static Class<?> dataWatcherObjectClass = nmsClassResolver.resolveSilent("network.syncher.DataWatcherObject"); static Class<?> dataWatcherObjectClass = nmsClassResolver.resolveSilent("network.syncher.DataWatcherObject");
static Class<?> chatSerializerClass = nmsClassResolver.resolveSilent("ChatSerializer", "network.chat.IChatBaseComponent$ChatSerializer"); static Class<?> chatSerializerClass = nmsClassResolver.resolveSilent("ChatSerializer", "network.chat.IChatBaseComponent$ChatSerializer");
@ -418,7 +417,12 @@ public class Utils {
a.invoke(dataWatcher, 4, (byte) 1); // silent a.invoke(dataWatcher, 4, (byte) 1); // silent
a.invoke(dataWatcher, 10, nmsItemStack == null ? armorStandFlags : nmsItemStack); // item / armor stand flags a.invoke(dataWatcher, 10, nmsItemStack == null ? armorStandFlags : nmsItemStack); // item / armor stand flags
} else { } else {
Method register = dataWatcherClass.getMethod("register", dataWatcherObjectClass, Object.class); Method register;
if (majorVersion < 18) {
register = dataWatcherClass.getMethod("register", dataWatcherObjectClass, Object.class);
} else {
register = dataWatcherClass.getMethod("a",dataWatcherObjectClass, Object.class);
}
String[] dataWatcherObjectFieldNames; String[] dataWatcherObjectFieldNames;
if ("v1_9_R1".equals(version)) { if ("v1_9_R1".equals(version)) {
@ -456,7 +460,7 @@ public class Utils {
Field fSilent = entityClass.getDeclaredField(dataWatcherObjectFieldNames[4]); Field fSilent = entityClass.getDeclaredField(dataWatcherObjectFieldNames[4]);
Field fNoGravity = majorVersion >= 10 ? entityClass.getDeclaredField(dataWatcherObjectFieldNames[5]) : null; Field fNoGravity = majorVersion >= 10 ? entityClass.getDeclaredField(dataWatcherObjectFieldNames[5]) : null;
//Field fItem = entityItemClass.getDeclaredField(dataWatcherObjectFieldNames[6]); //Field fItem = entityItemClass.getDeclaredField(dataWatcherObjectFieldNames[6]);
Field fItem = itemEntityClass.getDeclaredField(dataWatcherObjectFieldNames[6]); Field fItem = entityItemClass.getDeclaredField(dataWatcherObjectFieldNames[6]);
Field fArmorStandFlags = entityArmorStandClass.getDeclaredField(dataWatcherObjectFieldNames[7]); Field fArmorStandFlags = entityArmorStandClass.getDeclaredField(dataWatcherObjectFieldNames[7]);
fEntityFlags.setAccessible(true); fEntityFlags.setAccessible(true);
@ -636,7 +640,11 @@ public class Utils {
Field fConnection = (new FieldResolver(nmsPlayer.getClass())).resolve("playerConnection", "b"); Field fConnection = (new FieldResolver(nmsPlayer.getClass())).resolve("playerConnection", "b");
Object playerConnection = fConnection.get(nmsPlayer); Object playerConnection = fConnection.get(nmsPlayer);
if (getMajorVersion() < 18) {
playerConnection.getClass().getMethod("sendPacket", packetClass).invoke(playerConnection, packet); playerConnection.getClass().getMethod("sendPacket", packetClass).invoke(playerConnection, packet);
} else {
}
return true; return true;
} catch (NoSuchMethodException | NoSuchFieldException | IllegalAccessException | InvocationTargetException e) { } catch (NoSuchMethodException | NoSuchFieldException | IllegalAccessException | InvocationTargetException e) {