Read desc
Added method to reflection manager to check if after 1.7 Fixed error with packet use entity Fixed error with walk sounds
This commit is contained in:
parent
3541e82c48
commit
b29e8e6115
@ -110,7 +110,7 @@ public class PacketsManager {
|
||||
try {
|
||||
Player observer = event.getPlayer();
|
||||
StructureModifier<Entity> entityModifer = event.getPacket().getEntityModifier(observer.getWorld());
|
||||
org.bukkit.entity.Entity entity = entityModifer.read(1);
|
||||
org.bukkit.entity.Entity entity = entityModifer.read(ReflectionManager.isAfter17() ? 1 : 0);
|
||||
if (entity instanceof ExperienceOrb || entity instanceof Item || entity instanceof Arrow) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -535,7 +535,12 @@ public class PacketsManager {
|
||||
int typeId = soundLoc.getWorld().getBlockTypeIdAt(soundLoc.getBlockX(),
|
||||
soundLoc.getBlockY() - 1, soundLoc.getBlockZ());
|
||||
Class blockClass = ReflectionManager.getNmsClass("Block");
|
||||
Object block = ((Object[]) blockClass.getField("byId").get(null))[typeId];
|
||||
Object block;
|
||||
if (ReflectionManager.isAfter17()) {
|
||||
block = blockClass.getMethod("REGISTRY", int.class).invoke(null, typeId);
|
||||
} else {
|
||||
block = ((Object[]) blockClass.getField("byId").get(null))[typeId];
|
||||
}
|
||||
if (block != null) {
|
||||
Object step = blockClass.getField("stepSound").get(block);
|
||||
mods.write(0, step.getClass().getMethod("getStepSound").invoke(step));
|
||||
|
@ -15,6 +15,7 @@ public class ReflectionManager {
|
||||
private static String bukkitVersion = Bukkit.getServer().getClass().getName().split("\\.")[3];
|
||||
private static Class itemClass;
|
||||
private static Method soundMethod;
|
||||
private static boolean after17 = true;
|
||||
static {
|
||||
for (Method method : getNmsClass("EntityLiving").getDeclaredMethods()) {
|
||||
try {
|
||||
@ -43,6 +44,17 @@ public class ReflectionManager {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (bukkitVersion.startsWith("1.")) {
|
||||
try {
|
||||
if (Integer.parseInt(bukkitVersion.split("\\.")[1]) < 7) {
|
||||
after17 = false;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
}public static boolean isAfter17() {
|
||||
return after17;
|
||||
}
|
||||
|
||||
public static Object createEntityInstance(String entityName) {
|
||||
@ -51,20 +63,10 @@ public class ReflectionManager {
|
||||
Object entityObject;
|
||||
Object world = getWorld(Bukkit.getWorlds().get(0));
|
||||
if (entityName.equals("Player")) {
|
||||
boolean useOld = false;
|
||||
if (bukkitVersion.startsWith("1.")) {
|
||||
try {
|
||||
if (Integer.parseInt(bukkitVersion.split("\\.")[1]) < 7) {
|
||||
useOld = true;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
Object minecraftServer = getNmsClass("MinecraftServer").getMethod("getServer").invoke(null);
|
||||
Object playerinteractmanager = getNmsClass("PlayerInteractManager").getConstructor(getNmsClass("World"))
|
||||
.newInstance(world);
|
||||
if (useOld) {
|
||||
if (!isAfter17()) {
|
||||
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("World"), String.class,
|
||||
playerinteractmanager.getClass()).newInstance(minecraftServer, world, "LibsDisguises",
|
||||
playerinteractmanager);
|
||||
|
Loading…
Reference in New Issue
Block a user