mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-29 03:49:07 +00:00
Back up for big changes
This commit is contained in:
@@ -37,22 +37,7 @@ public class ReflectionUtils {
|
||||
public static Class<?> bukkitClass;
|
||||
|
||||
public static void load() {
|
||||
// spigot map
|
||||
try {
|
||||
Class<?> bar = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss");
|
||||
Field remove = bar.getDeclaredField("f");
|
||||
remove.setAccessible(true);
|
||||
removeBossBarPacket = remove.get(null);
|
||||
Class<?> packetBossClassF = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$f");
|
||||
progressConstructor = packetBossClassF.getDeclaredConstructor(float.class);
|
||||
progressConstructor.setAccessible(true);
|
||||
Class<?> packetBossClassE = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$e");
|
||||
updateConstructor = packetBossClassE.getDeclaredConstructor(MinecraftReflection.getIChatBaseComponentClass());
|
||||
updateConstructor.setAccessible(true);
|
||||
iChatComponentMethod = MinecraftReflection.getChatSerializerClass().getMethod("a", String.class);
|
||||
iChatComponentMethod.setAccessible(true);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException e1) {
|
||||
// mojmap
|
||||
if (CustomFishingPlugin.get().getVersionManager().isMojmap()) {
|
||||
try {
|
||||
Class<?> bar = Class.forName("net.minecraft.network.protocol.game.ClientboundBossEventPacket");
|
||||
Field remove = bar.getDeclaredField("REMOVE_OPERATION");
|
||||
@@ -64,13 +49,29 @@ public class ReflectionUtils {
|
||||
Class<?> packetBossClassE = Class.forName("net.minecraft.network.protocol.game.ClientboundBossEventPacket$UpdateNameOperation");
|
||||
updateConstructor = packetBossClassE.getDeclaredConstructor(MinecraftReflection.getIChatBaseComponentClass());
|
||||
updateConstructor.setAccessible(true);
|
||||
iChatComponentMethod = MinecraftReflection.getChatSerializerClass().getMethod("fromJson", String.class);
|
||||
Class<?> craftChatMessageClass = Class.forName("org.bukkit.craftbukkit.util.CraftChatMessage");
|
||||
iChatComponentMethod = craftChatMessageClass.getDeclaredMethod("fromJSON", String.class);
|
||||
iChatComponentMethod.setAccessible(true);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException e2) {
|
||||
LogUtils.severe("Error occurred when loading reflections", e2);
|
||||
e2.printStackTrace();
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException exception) {
|
||||
LogUtils.severe("Error occurred when loading reflections", exception);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Class<?> bar = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss");
|
||||
Field remove = bar.getDeclaredField("f");
|
||||
remove.setAccessible(true);
|
||||
removeBossBarPacket = remove.get(null);
|
||||
Class<?> packetBossClassF = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$f");
|
||||
progressConstructor = packetBossClassF.getDeclaredConstructor(float.class);
|
||||
progressConstructor.setAccessible(true);
|
||||
Class<?> packetBossClassE = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$e");
|
||||
updateConstructor = packetBossClassE.getDeclaredConstructor(MinecraftReflection.getIChatBaseComponentClass());
|
||||
updateConstructor.setAccessible(true);
|
||||
iChatComponentMethod = MinecraftReflection.getChatSerializerClass().getMethod("a", String.class);
|
||||
iChatComponentMethod.setAccessible(true);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException exception) {
|
||||
LogUtils.severe("Error occurred when loading reflections", exception);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (CustomFishingPlugin.get().getVersionManager().isSpigot()) return;
|
||||
try {
|
||||
@@ -82,11 +83,8 @@ public class ReflectionUtils {
|
||||
gsonInstance = gsonMethod.invoke(null);
|
||||
gsonDeserializeMethod = gsonComponentSerializerImplClass.getMethod("deserialize", String.class);
|
||||
gsonDeserializeMethod.setAccessible(true);
|
||||
} catch (ClassNotFoundException exception) {
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException exception) {
|
||||
LogUtils.severe("Error occurred when loading reflections", exception);
|
||||
exception.printStackTrace();
|
||||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user