Fix compatibility with CraftBukkit 1.12.1 in NmsBasics module that was lost due to CraftBlockEntityState feature.
This commit is contained in:
parent
4fe9e627dc
commit
43b88fb5ab
@ -53,11 +53,18 @@ public class NmsBasics17R4P extends NmsBasics
|
|||||||
// org.bukkit.craftbukkit.scoreboard.CraftObjective#objective
|
// org.bukkit.craftbukkit.scoreboard.CraftObjective#objective
|
||||||
private Field fieldCraftObjectiveHandle;
|
private Field fieldCraftObjectiveHandle;
|
||||||
|
|
||||||
|
// SIGN for 1.12.0 and below
|
||||||
// org.bukkit.craftbukkit.block.CraftSign
|
// org.bukkit.craftbukkit.block.CraftSign
|
||||||
private Class<?> classCraftSign;
|
private Class<?> classCraftSign;
|
||||||
// org.bukkit.craftbukkit.block.CraftSign#sign
|
// org.bukkit.craftbukkit.block.CraftSign#sign
|
||||||
private Field fieldCraftSignHandle;
|
private Field fieldCraftSignHandle;
|
||||||
|
|
||||||
|
// SIGN for 1.12.1 and above
|
||||||
|
// org.bukkit.craftbukkit.block.CraftBlockEntityState
|
||||||
|
private Class<?> classCraftBlockEntityState;
|
||||||
|
// org.bukkit.craftbukkit.block.CraftBlockEntityState#tileEntity
|
||||||
|
private Field fieldCraftBlockEntityStateHandle;
|
||||||
|
|
||||||
// GET BUKKIT
|
// GET BUKKIT
|
||||||
// net.minecraft.server.Entity
|
// net.minecraft.server.Entity
|
||||||
private Class<?> classNmsEntity;
|
private Class<?> classNmsEntity;
|
||||||
@ -89,7 +96,6 @@ public class NmsBasics17R4P extends NmsBasics
|
|||||||
public void setup() throws Throwable
|
public void setup() throws Throwable
|
||||||
{
|
{
|
||||||
// GET HANDLE
|
// GET HANDLE
|
||||||
|
|
||||||
this.classCraftEntity = PackageType.CRAFTBUKKIT_ENTITY.getClass("CraftEntity");
|
this.classCraftEntity = PackageType.CRAFTBUKKIT_ENTITY.getClass("CraftEntity");
|
||||||
this.methodCraftEntityGetHandle = ReflectionUtil.getMethod(this.classCraftEntity, "getHandle");
|
this.methodCraftEntityGetHandle = ReflectionUtil.getMethod(this.classCraftEntity, "getHandle");
|
||||||
|
|
||||||
@ -105,8 +111,18 @@ public class NmsBasics17R4P extends NmsBasics
|
|||||||
this.classCraftObjective = PackageType.CRAFTBUKKIT_SCOREBOARD.getClass("CraftObjective");
|
this.classCraftObjective = PackageType.CRAFTBUKKIT_SCOREBOARD.getClass("CraftObjective");
|
||||||
this.fieldCraftObjectiveHandle = ReflectionUtil.getField(this.classCraftObjective, "objective");
|
this.fieldCraftObjectiveHandle = ReflectionUtil.getField(this.classCraftObjective, "objective");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// SIGN for 1.12.0 and below
|
||||||
this.classCraftSign = PackageType.CRAFTBUKKIT_BLOCK.getClass("CraftSign");
|
this.classCraftSign = PackageType.CRAFTBUKKIT_BLOCK.getClass("CraftSign");
|
||||||
this.fieldCraftSignHandle = ReflectionUtil.getField(this.classCraftSign, "sign");
|
this.fieldCraftSignHandle = ReflectionUtil.getField(this.classCraftSign, "sign");
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
// SIGN for 1.12.1 and above
|
||||||
|
this.classCraftBlockEntityState = PackageType.CRAFTBUKKIT_BLOCK.getClass("CraftBlockEntityState");
|
||||||
|
this.fieldCraftBlockEntityStateHandle = ReflectionUtil.getField(this.classCraftBlockEntityState, "tileEntity");
|
||||||
|
}
|
||||||
|
|
||||||
// GET BUKKIT
|
// GET BUKKIT
|
||||||
this.classNmsEntity = PackageType.MINECRAFT_SERVER.getClass("Entity");
|
this.classNmsEntity = PackageType.MINECRAFT_SERVER.getClass("Entity");
|
||||||
@ -167,7 +183,21 @@ public class NmsBasics17R4P extends NmsBasics
|
|||||||
public <T> T getHandle(Sign sign)
|
public <T> T getHandle(Sign sign)
|
||||||
{
|
{
|
||||||
if (sign == null) return null;
|
if (sign == null) return null;
|
||||||
return ReflectionUtil.getField(this.fieldCraftSignHandle, sign);
|
|
||||||
|
Field field;
|
||||||
|
|
||||||
|
if (this.fieldCraftSignHandle != null)
|
||||||
|
{
|
||||||
|
// SIGN for 1.12.0 and below
|
||||||
|
field = this.fieldCraftSignHandle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// SIGN for 1.12.1 and above
|
||||||
|
field = this.fieldCraftBlockEntityStateHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReflectionUtil.getField(field, sign);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
Loading…
Reference in New Issue
Block a user