diff --git a/src/com/massivecraft/massivecore/nms/NmsBasics.java b/src/com/massivecraft/massivecore/nms/NmsBasics.java index 371da20c..d7286b11 100644 --- a/src/com/massivecraft/massivecore/nms/NmsBasics.java +++ b/src/com/massivecraft/massivecore/nms/NmsBasics.java @@ -1,6 +1,7 @@ package com.massivecraft.massivecore.nms; import org.bukkit.World; +import org.bukkit.block.Sign; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.scoreboard.Objective; @@ -55,6 +56,11 @@ public class NmsBasics extends Mixin throw this.notImplemented(); } + public T getHandle(Sign sign) + { + throw this.notImplemented(); + } + // -------------------------------------------- // // GET BUKKIT // -------------------------------------------- // diff --git a/src/com/massivecraft/massivecore/nms/NmsBasics17R4P.java b/src/com/massivecraft/massivecore/nms/NmsBasics17R4P.java index 4730e5a3..ef93ba5d 100644 --- a/src/com/massivecraft/massivecore/nms/NmsBasics17R4P.java +++ b/src/com/massivecraft/massivecore/nms/NmsBasics17R4P.java @@ -3,6 +3,7 @@ package com.massivecraft.massivecore.nms; import java.lang.reflect.Field; import java.lang.reflect.Method; import org.bukkit.World; +import org.bukkit.block.Sign; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.scoreboard.Objective; @@ -52,6 +53,11 @@ public class NmsBasics17R4P extends NmsBasics // org.bukkit.craftbukkit.scoreboard.CraftObjective#objective private Field fieldCraftObjectiveHandle; + // org.bukkit.craftbukkit.block.CraftSign + private Class classCraftSign; + // org.bukkit.craftbukkit.block.CraftSign#sign + private Field fieldclassCraftSignHandle; + // GET BUKKIT // net.minecraft.server.Entity private Class classNmsEntity; @@ -99,6 +105,9 @@ public class NmsBasics17R4P extends NmsBasics this.classCraftObjective = PackageType.CRAFTBUKKIT_SCOREBOARD.getClass("CraftObjective"); this.fieldCraftObjectiveHandle = ReflectionUtil.getField(this.classCraftObjective, "objective"); + this.classCraftSign = PackageType.CRAFTBUKKIT_BLOCK.getClass("CraftSign"); + this.fieldclassCraftSignHandle = ReflectionUtil.getField(this.classCraftSign, "sign"); + // GET BUKKIT this.classNmsEntity = PackageType.MINECRAFT_SERVER.getClass("Entity"); this.methodNmsEntityGetBukkitEntity = ReflectionUtil.getMethod(this.classNmsEntity, "getBukkitEntity"); @@ -122,33 +131,45 @@ public class NmsBasics17R4P extends NmsBasics @Override public T getHandle(Entity entity) { + if (entity == null) return null; return ReflectionUtil.invokeMethod(this.methodCraftEntityGetHandle, entity); } @Override public T getHandle(World world) { + if (world == null) return null; return ReflectionUtil.getField(this.fieldCraftWorldWorld, world); } @Override public T getHandle(Scoreboard scoreboard) { + if (scoreboard == null) return null; return ReflectionUtil.getField(this.fieldCraftScoreboardHandle, scoreboard); } @Override public T getHandle(Team team) { + if (team == null) return null; return ReflectionUtil.getField(this.fieldCraftTeamHandle, team); } @Override public T getHandle(Objective objective) { + if (objective == null) return null; return ReflectionUtil.getField(this.fieldCraftObjectiveHandle, objective); } + @Override + public T getHandle(Sign sign) + { + if (sign == null) return null; + return ReflectionUtil.getField(this.fieldclassCraftSignHandle, sign); + } + // -------------------------------------------- // // GET BUKKIT // -------------------------------------------- // @@ -156,6 +177,7 @@ public class NmsBasics17R4P extends NmsBasics @Override public T getBukkit(Object handle) { + if (handle == null) return null; return ReflectionUtil.invokeMethod(this.methodNmsEntityGetBukkitEntity, handle); }