From bbcd423987023d08c3efd9adf1eae6dc6933cbdf Mon Sep 17 00:00:00 2001 From: Alastair Date: Sat, 13 May 2017 18:19:08 +0100 Subject: [PATCH] Added support for 1_8_R1 --- Resources/plugin.yml | 2 +- pom.xml | 2 +- .../advancedportals/AdvancedPortalsPlugin.java | 2 ++ .../sekwah/advancedportals/compat/CraftBukkit.java | 14 +++++++++++++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Resources/plugin.yml b/Resources/plugin.yml index b83acd48..39b1b5aa 100644 --- a/Resources/plugin.yml +++ b/Resources/plugin.yml @@ -1,6 +1,6 @@ main: com.sekwah.advancedportals.AdvancedPortalsPlugin name: AdvancedPortals -version: 0.0.24 +version: 0.0.25 author: sekwah41 description: An advanced portals plugin for bukkit. commands: diff --git a/pom.xml b/pom.xml index 67ce6f1e..bf755e3f 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - 0.0.24-snapshot + 0.0.25-snapshot UTF-8 1.7 diff --git a/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java b/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java index 45fe46ed..5ae1c2d8 100644 --- a/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java +++ b/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java @@ -61,7 +61,9 @@ public class AdvancedPortalsPlugin extends JavaPlugin { } catch (ClassNotFoundException e) { + e.printStackTrace(); this.getLogger().warning("This version of craftbukkit is not yet supported, please notify sekwah and tell him about this version v:" + version); + this.getLogger().warning("Along with the above stacktrace"); this.setEnabled(false); } catch (IllegalArgumentException | NoSuchFieldException | SecurityException | NoSuchMethodException e) { diff --git a/src/com/sekwah/advancedportals/compat/CraftBukkit.java b/src/com/sekwah/advancedportals/compat/CraftBukkit.java index 794cd2c5..1c07b542 100644 --- a/src/com/sekwah/advancedportals/compat/CraftBukkit.java +++ b/src/com/sekwah/advancedportals/compat/CraftBukkit.java @@ -39,7 +39,17 @@ public class CraftBukkit { String minecraftPackage = "net.minecraft.server." + bukkitImpl + "."; Class chatBaseComponent = Class.forName(minecraftPackage + "IChatBaseComponent"); // string to packet methods - this.serializeMessage = this.findClass(chatBaseComponent, "ChatSerializer").getMethod("a", String.class); + Class chatSerialClass = this.findClass(chatBaseComponent, "ChatSerializer"); + + if(chatSerialClass == null){ + plugin.getLogger().info("Old version detected, changing chat method"); + this.serializeMessage = chatBaseComponent.getMethod("a", String.class); + } + else{ + plugin.getLogger().info("Old version detected, changing chat method"); + this.serializeMessage = chatBaseComponent.getMethod("a", String.class); + } + this.chatPacketConstructor = Class.forName(minecraftPackage + "PacketPlayOutChat").getConstructor(chatBaseComponent, byte.class); this.playerGetHandle = Class.forName(craftBukkitPackage + "entity.CraftPlayer").getMethod("getHandle"); @@ -47,6 +57,8 @@ public class CraftBukkit { Class packet = Class.forName(minecraftPackage + "Packet"); this.sendPacket = playerConnection.getType().getMethod("sendPacket", packet); } catch (Exception e) { + e.printStackTrace(); + plugin.getLogger().warning("Attempting to use backup porekit locations"); // Fall back on your Porekit Class textBaseComponent = Class.forName("net.minecraft.util.text.ITextComponent"); // string to packet methods this.serializeMessage = this.findClass(textBaseComponent, "Serializer").getMethod("func_150699_a", String.class); // md: jsonToComponent