From 556a501f75aaca8239795627938b9ed770d423c9 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Tue, 20 Jul 2021 17:37:00 -0400 Subject: [PATCH] Fix #61 --- 1_14_R1/pom.xml | 12 +------- .../version_1_14_R1/NMSInterface_1_14_R1.java | 27 ++--------------- 1_15_R1/pom.xml | 12 +------- .../version_1_15_R1/NMSInterface_1_15_R1.java | 27 ++--------------- 1_16_R1/pom.xml | 12 +------- .../version_1_16_R1/NMSInterface_1_16_R1.java | 27 ++--------------- 1_16_R2/pom.xml | 12 +------- .../version_1_16_R2/NMSInterface_1_16_R2.java | 29 +++---------------- 1_16_R3/pom.xml | 12 +------- .../version_1_16_R3/NMSInterface_1_16_R3.java | 29 +++---------------- 1_17_1_R1/pom.xml | 12 +------- .../NMSInterface_1_17_1_R1.java | 27 ++--------------- 1_17_R1/pom.xml | 12 +------- .../version_1_17_R1/NMSInterface_1_17_R1.java | 27 ++--------------- Plugin/pom.xml | 2 +- Utility/pom.xml | 2 +- pom.xml | 2 +- 17 files changed, 33 insertions(+), 250 deletions(-) diff --git a/1_14_R1/pom.xml b/1_14_R1/pom.xml index 6d16bec..9124931 100644 --- a/1_14_R1/pom.xml +++ b/1_14_R1/pom.xml @@ -7,7 +7,7 @@ tamablefoxes-parent net.seanomik - 2.1.4-SNAPSHOT + 2.1.5-SNAPSHOT tamablefoxes_v1_14_R1 @@ -41,15 +41,5 @@ anvilgui 1.5.1-SNAPSHOT - - org.ow2.asm - asm - 9.1 - - - org.ow2.asm - asm-tree - 9.1 - \ No newline at end of file diff --git a/1_14_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/NMSInterface_1_14_R1.java b/1_14_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/NMSInterface_1_14_R1.java index b88cfaf..d39a982 100644 --- a/1_14_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/NMSInterface_1_14_R1.java +++ b/1_14_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/NMSInterface_1_14_R1.java @@ -4,45 +4,24 @@ import net.minecraft.server.v1_14_R1.EntityFox; import net.minecraft.server.v1_14_R1.EntityTypes; import net.seanomik.tamablefoxes.util.FieldHelper; import net.seanomik.tamablefoxes.util.NMSInterface; -import net.seanomik.tamablefoxes.util.Utils; +import net.seanomik.tamablefoxes.util.io.Config; import net.seanomik.tamablefoxes.util.io.LanguageConfig; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity; -// In IntelliJ, these show up as an error, but it compiles fine. -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.tree.ClassNode; - -import java.io.IOException; import java.lang.reflect.Field; public class NMSInterface_1_14_R1 implements NMSInterface { @Override public void registerCustomFoxEntity() { - Class clazz = null; - try { - // This must be `EntityFox` since after being compiled, the class goes back to `EntityFox` instead of `Fox` - ClassReader cr = new ClassReader(EntityFox.class.getResourceAsStream("EntityFox.class")); - ClassNode node = new ClassNode(); - cr.accept(node, 0); - - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - node.accept(cw); - clazz = new ClassDefiner(ClassLoader.getSystemClassLoader()).get(node.name.replace("/", "."), cw.toByteArray()); - } catch (IOException e) { - e.printStackTrace(); - } - try { // Replace the fox entity Field field = EntityTypes.FOX.getClass().getDeclaredField("aZ"); // aZ = factory - Class finalClazz = clazz; FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b) EntityTamableFox::new); - Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced()); + Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced()); } catch (Exception e) { - Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace()); + Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace()); e.printStackTrace(); } } diff --git a/1_15_R1/pom.xml b/1_15_R1/pom.xml index d8f5b58..6f8e4ed 100644 --- a/1_15_R1/pom.xml +++ b/1_15_R1/pom.xml @@ -7,7 +7,7 @@ tamablefoxes-parent net.seanomik - 2.1.4-SNAPSHOT + 2.1.5-SNAPSHOT tamablefoxes_v1_15_R1 @@ -41,15 +41,5 @@ anvilgui 1.5.1-SNAPSHOT - - org.ow2.asm - asm - 9.1 - - - org.ow2.asm - asm-tree - 9.1 - \ No newline at end of file diff --git a/1_15_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/NMSInterface_1_15_R1.java b/1_15_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/NMSInterface_1_15_R1.java index 53f6788..fff742e 100644 --- a/1_15_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/NMSInterface_1_15_R1.java +++ b/1_15_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/NMSInterface_1_15_R1.java @@ -4,45 +4,24 @@ import net.minecraft.server.v1_15_R1.EntityFox; import net.minecraft.server.v1_15_R1.EntityTypes; import net.seanomik.tamablefoxes.util.FieldHelper; import net.seanomik.tamablefoxes.util.NMSInterface; -import net.seanomik.tamablefoxes.util.Utils; +import net.seanomik.tamablefoxes.util.io.Config; import net.seanomik.tamablefoxes.util.io.LanguageConfig; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity; -// In IntelliJ, these show up as an error, but it compiles fine. -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.tree.ClassNode; - -import java.io.IOException; import java.lang.reflect.Field; public class NMSInterface_1_15_R1 implements NMSInterface { @Override public void registerCustomFoxEntity() { - Class clazz = null; - try { - // This must be `EntityFox` since after being compiled, the class goes back to `EntityFox` instead of `Fox` - ClassReader cr = new ClassReader(EntityFox.class.getResourceAsStream("EntityFox.class")); - ClassNode node = new ClassNode(); - cr.accept(node, 0); - - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - node.accept(cw); - clazz = new ClassDefiner(ClassLoader.getSystemClassLoader()).get(node.name.replace("/", "."), cw.toByteArray()); - } catch (IOException e) { - e.printStackTrace(); - } - try { // Replace the fox entity Field field = EntityTypes.FOX.getClass().getDeclaredField("ba"); // ba = factory - Class finalClazz = clazz; FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b) EntityTamableFox::new); - Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced()); + Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced()); } catch (Exception e) { - Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace()); + Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace()); e.printStackTrace(); } } diff --git a/1_16_R1/pom.xml b/1_16_R1/pom.xml index 0a7d2fe..daa1f85 100644 --- a/1_16_R1/pom.xml +++ b/1_16_R1/pom.xml @@ -7,7 +7,7 @@ tamablefoxes-parent net.seanomik - 2.1.4-SNAPSHOT + 2.1.5-SNAPSHOT tamablefoxes_v1_16_R1 @@ -41,15 +41,5 @@ anvilgui 1.5.1-SNAPSHOT - - org.ow2.asm - asm - 9.1 - - - org.ow2.asm - asm-tree - 9.1 - \ No newline at end of file diff --git a/1_16_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/NMSInterface_1_16_R1.java b/1_16_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/NMSInterface_1_16_R1.java index 83033af..ed55032 100644 --- a/1_16_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/NMSInterface_1_16_R1.java +++ b/1_16_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/NMSInterface_1_16_R1.java @@ -4,45 +4,24 @@ import net.minecraft.server.v1_16_R1.EntityFox; import net.minecraft.server.v1_16_R1.EntityTypes; import net.seanomik.tamablefoxes.util.FieldHelper; import net.seanomik.tamablefoxes.util.NMSInterface; -import net.seanomik.tamablefoxes.util.Utils; +import net.seanomik.tamablefoxes.util.io.Config; import net.seanomik.tamablefoxes.util.io.LanguageConfig; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEntity; -// In IntelliJ, these show up as an error, but it compiles fine. -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.tree.ClassNode; - -import java.io.IOException; import java.lang.reflect.Field; public class NMSInterface_1_16_R1 implements NMSInterface { @Override public void registerCustomFoxEntity() { - Class clazz = null; - try { - // This must be `EntityFox` since after being compiled, the class goes back to `EntityFox` instead of `Fox` - ClassReader cr = new ClassReader(EntityFox.class.getResourceAsStream("EntityFox.class")); - ClassNode node = new ClassNode(); - cr.accept(node, 0); - - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - node.accept(cw); - clazz = new ClassDefiner(ClassLoader.getSystemClassLoader()).get(node.name.replace("/", "."), cw.toByteArray()); - } catch (IOException e) { - e.printStackTrace(); - } - try { // Replace the fox entity Field field = EntityTypes.FOX.getClass().getDeclaredField("be"); // be = factory - Class finalClazz = clazz; FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b) EntityTamableFox::new); - Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced()); + Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced()); } catch (Exception e) { - Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace()); + Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace()); e.printStackTrace(); } } diff --git a/1_16_R2/pom.xml b/1_16_R2/pom.xml index 9d128a4..27a5a79 100644 --- a/1_16_R2/pom.xml +++ b/1_16_R2/pom.xml @@ -7,7 +7,7 @@ tamablefoxes-parent net.seanomik - 2.1.4-SNAPSHOT + 2.1.5-SNAPSHOT tamablefoxes_v1_16_R2 @@ -41,15 +41,5 @@ anvilgui 1.5.1-SNAPSHOT - - org.ow2.asm - asm - 9.1 - - - org.ow2.asm - asm-tree - 9.1 - \ No newline at end of file diff --git a/1_16_R2/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/NMSInterface_1_16_R2.java b/1_16_R2/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/NMSInterface_1_16_R2.java index 8dc3bd6..2e51f28 100644 --- a/1_16_R2/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/NMSInterface_1_16_R2.java +++ b/1_16_R2/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/NMSInterface_1_16_R2.java @@ -4,45 +4,24 @@ import net.minecraft.server.v1_16_R2.EntityFox; import net.minecraft.server.v1_16_R2.EntityTypes; import net.seanomik.tamablefoxes.util.FieldHelper; import net.seanomik.tamablefoxes.util.NMSInterface; -import net.seanomik.tamablefoxes.util.Utils; +import net.seanomik.tamablefoxes.util.io.Config; import net.seanomik.tamablefoxes.util.io.LanguageConfig; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_16_R2.entity.CraftEntity; -// In IntelliJ, these show up as an error, but it compiles fine. -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.tree.ClassNode; - -import java.io.IOException; import java.lang.reflect.Field; public class NMSInterface_1_16_R2 implements NMSInterface { @Override public void registerCustomFoxEntity() { - Class clazz = null; - try { - // This must be `EntityFox` since after being compiled, the class goes back to `EntityFox` instead of `Fox` - ClassReader cr = new ClassReader(EntityFox.class.getResourceAsStream("EntityFox.class")); - ClassNode node = new ClassNode(); - cr.accept(node, 0); - - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - node.accept(cw); - clazz = new ClassDefiner(ClassLoader.getSystemClassLoader()).get(node.name.replace("/", "."), cw.toByteArray()); - } catch (IOException e) { - e.printStackTrace(); - } - try { // Replace the fox entity - Field field = EntityTypes.FOX.getClass().getDeclaredField("bf"); // bm = factory - Class finalClazz = clazz; + Field field = EntityTypes.FOX.getClass().getDeclaredField("bf"); // bf = factory FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b) EntityTamableFox::new); - Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced()); + Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced()); } catch (Exception e) { - Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace()); + Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace()); e.printStackTrace(); } } diff --git a/1_16_R3/pom.xml b/1_16_R3/pom.xml index 242cae7..2703179 100644 --- a/1_16_R3/pom.xml +++ b/1_16_R3/pom.xml @@ -7,7 +7,7 @@ net.seanomik tamablefoxes-parent - 2.1.4-SNAPSHOT + 2.1.5-SNAPSHOT tamablefoxes_v1_16_R3 @@ -41,15 +41,5 @@ anvilgui 1.5.1-SNAPSHOT - - org.ow2.asm - asm - 9.1 - - - org.ow2.asm - asm-tree - 9.1 - \ No newline at end of file diff --git a/1_16_R3/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R3/NMSInterface_1_16_R3.java b/1_16_R3/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R3/NMSInterface_1_16_R3.java index 3557298..cf3d99a 100644 --- a/1_16_R3/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R3/NMSInterface_1_16_R3.java +++ b/1_16_R3/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R3/NMSInterface_1_16_R3.java @@ -4,45 +4,24 @@ import net.minecraft.server.v1_16_R3.EntityFox; import net.minecraft.server.v1_16_R3.EntityTypes; import net.seanomik.tamablefoxes.util.FieldHelper; import net.seanomik.tamablefoxes.util.NMSInterface; -import net.seanomik.tamablefoxes.util.Utils; +import net.seanomik.tamablefoxes.util.io.Config; import net.seanomik.tamablefoxes.util.io.LanguageConfig; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity; -// In IntelliJ, these show up as an error, but it compiles fine. -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.tree.ClassNode; - -import java.io.IOException; import java.lang.reflect.Field; public class NMSInterface_1_16_R3 implements NMSInterface { @Override public void registerCustomFoxEntity() { - Class clazz = null; - try { - // This must be `EntityFox` since after being compiled, the class goes back to `EntityFox` instead of `Fox` - ClassReader cr = new ClassReader(EntityFox.class.getResourceAsStream("EntityFox.class")); - ClassNode node = new ClassNode(); - cr.accept(node, 0); - - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - node.accept(cw); - clazz = new ClassDefiner(ClassLoader.getSystemClassLoader()).get(node.name.replace("/", "."), cw.toByteArray()); - } catch (IOException e) { - e.printStackTrace(); - } - try { // Replace the fox entity - Field field = EntityTypes.FOX.getClass().getDeclaredField("bf"); // bm = factory - Class finalClazz = clazz; + Field field = EntityTypes.FOX.getClass().getDeclaredField("bf"); // bf = factory FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b) EntityTamableFox::new); - Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced()); + Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced()); } catch (Exception e) { - Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace()); + Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace()); e.printStackTrace(); } } diff --git a/1_17_1_R1/pom.xml b/1_17_1_R1/pom.xml index 8ef89ed..61e8ce2 100644 --- a/1_17_1_R1/pom.xml +++ b/1_17_1_R1/pom.xml @@ -7,7 +7,7 @@ net.seanomik tamablefoxes-parent - 2.1.4-SNAPSHOT + 2.1.5-SNAPSHOT @@ -80,15 +80,5 @@ anvilgui 1.5.1-SNAPSHOT - - org.ow2.asm - asm - 9.1 - - - org.ow2.asm - asm-tree - 9.1 - \ No newline at end of file diff --git a/1_17_1_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_1_R1/NMSInterface_1_17_1_R1.java b/1_17_1_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_1_R1/NMSInterface_1_17_1_R1.java index 6be7faf..05f7542 100644 --- a/1_17_1_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_1_R1/NMSInterface_1_17_1_R1.java +++ b/1_17_1_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_1_R1/NMSInterface_1_17_1_R1.java @@ -4,45 +4,24 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.animal.Fox; import net.seanomik.tamablefoxes.util.FieldHelper; import net.seanomik.tamablefoxes.util.NMSInterface; -import net.seanomik.tamablefoxes.util.Utils; +import net.seanomik.tamablefoxes.util.io.Config; import net.seanomik.tamablefoxes.util.io.LanguageConfig; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity; -// In IntelliJ, these show up as an error, but it compiles fine. -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.tree.ClassNode; - -import java.io.IOException; import java.lang.reflect.Field; public class NMSInterface_1_17_1_R1 implements NMSInterface { @Override public void registerCustomFoxEntity() { - Class clazz = null; - try { - // This must be `EntityFox` since after being compiled, the class goes back to `EntityFox` instead of `Fox` - ClassReader cr = new ClassReader(Fox.class.getResourceAsStream("EntityFox.class")); - ClassNode node = new ClassNode(); - cr.accept(node, 0); - - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - node.accept(cw); - clazz = new ClassDefiner(ClassLoader.getSystemClassLoader()).get(node.name.replace("/", "."), cw.toByteArray()); - } catch (IOException e) { - e.printStackTrace(); - } - try { // Replace the fox entity Field field = EntityType.FOX.getClass().getDeclaredField("bm"); // bm = factory - Class finalClazz = clazz; FieldHelper.setFieldUsingUnsafe(field, EntityType.FOX, (EntityType.EntityFactory) EntityTamableFox::new); - Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced()); + Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced()); } catch (Exception e) { - Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace()); + Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace()); e.printStackTrace(); } } diff --git a/1_17_R1/pom.xml b/1_17_R1/pom.xml index 496f257..5fb7d27 100644 --- a/1_17_R1/pom.xml +++ b/1_17_R1/pom.xml @@ -7,7 +7,7 @@ net.seanomik tamablefoxes-parent - 2.1.4-SNAPSHOT + 2.1.5-SNAPSHOT @@ -80,15 +80,5 @@ anvilgui 1.5.1-SNAPSHOT - - org.ow2.asm - asm - 9.1 - - - org.ow2.asm - asm-tree - 9.1 - \ No newline at end of file diff --git a/1_17_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_R1/NMSInterface_1_17_R1.java b/1_17_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_R1/NMSInterface_1_17_R1.java index 76dc6e4..651a892 100644 --- a/1_17_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_R1/NMSInterface_1_17_R1.java +++ b/1_17_R1/src/main/java/net/seanomik/tamablefoxes/versions/version_1_17_R1/NMSInterface_1_17_R1.java @@ -4,45 +4,24 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.animal.Fox; import net.seanomik.tamablefoxes.util.FieldHelper; import net.seanomik.tamablefoxes.util.NMSInterface; -import net.seanomik.tamablefoxes.util.Utils; +import net.seanomik.tamablefoxes.util.io.Config; import net.seanomik.tamablefoxes.util.io.LanguageConfig; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity; -// In IntelliJ, these show up as an error, but it compiles fine. -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.tree.ClassNode; - -import java.io.IOException; import java.lang.reflect.Field; public class NMSInterface_1_17_R1 implements NMSInterface { @Override public void registerCustomFoxEntity() { - Class clazz = null; - try { - // This must be `EntityFox` since after being compiled, the class goes back to `EntityFox` instead of `Fox` - ClassReader cr = new ClassReader(Fox.class.getResourceAsStream("EntityFox.class")); - ClassNode node = new ClassNode(); - cr.accept(node, 0); - - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - node.accept(cw); - clazz = new ClassDefiner(ClassLoader.getSystemClassLoader()).get(node.name.replace("/", "."), cw.toByteArray()); - } catch (IOException e) { - e.printStackTrace(); - } - try { // Replace the fox entity Field field = EntityType.FOX.getClass().getDeclaredField("bm"); // bm = factory - Class finalClazz = clazz; FieldHelper.setFieldUsingUnsafe(field, EntityType.FOX, (EntityType.EntityFactory) EntityTamableFox::new); - Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced()); + Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced()); } catch (Exception e) { - Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace()); + Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace()); e.printStackTrace(); } } diff --git a/Plugin/pom.xml b/Plugin/pom.xml index 4a5db29..8facfe9 100644 --- a/Plugin/pom.xml +++ b/Plugin/pom.xml @@ -7,7 +7,7 @@ net.seanomik tamablefoxes-parent - 2.1.4-SNAPSHOT + 2.1.5-SNAPSHOT tamablefoxes diff --git a/Utility/pom.xml b/Utility/pom.xml index 0634dce..d111ba2 100644 --- a/Utility/pom.xml +++ b/Utility/pom.xml @@ -7,7 +7,7 @@ net.seanomik tamablefoxes-parent - 2.1.4-SNAPSHOT + 2.1.5-SNAPSHOT tamablefoxes-util diff --git a/pom.xml b/pom.xml index ac2770f..d1051ea 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.seanomik tamablefoxes-parent - 2.1.4-SNAPSHOT + 2.1.5-SNAPSHOT pom