Fixed NMSUtils#getEffectId and NMSUtils#getMobEffectListById (Used in WrappedPacketOutRemoveEntityEffect) on 1.18
This commit is contained in:
1 parent
30981f8283
commit
eb96c5216b
4 files changed
+13
-11
No files matched your search
@@ -396,8 +396,7 @@ public class WrappedPacket implements WrapperPacketReader, WrapperPacketWriter {
|
||||
public void writeEnumConstant(int index, Enum<?> enumConstant) {
|
||||
try {
|
||||
write(enumConstant.getClass(), index, enumConstant);
|
||||
}
|
||||
catch (WrapperFieldNotFoundException ex) {
|
||||
} catch (WrapperFieldNotFoundException ex) {
|
||||
write(enumConstant.getDeclaringClass(), index, enumConstant);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -37,9 +37,8 @@ public final class WrappedPacketInClientCommand extends WrappedPacket {
|
||||
@Override
|
||||
protected void load() {
|
||||
v_1_16 = version.isNewerThanOrEquals(ServerVersion.v_1_16);
|
||||
try {
|
||||
enumClientCommandClass = NMSUtils.getNMSEnumClass("EnumClientCommand");
|
||||
} catch (ClassNotFoundException e) {
|
||||
enumClientCommandClass = NMSUtils.getNMSEnumClassWithoutException("EnumClientCommand");
|
||||
if (enumClientCommandClass == null) {
|
||||
//Probably a subclass
|
||||
enumClientCommandClass = SubclassUtil.getEnumSubClass(PacketTypeClasses.Play.Client.CLIENT_COMMAND, "EnumClientCommand");
|
||||
}
|
||||
|
||||
+2
-1
@@ -133,11 +133,12 @@ public final class WrappedPacketInUseEntity extends WrappedPacketEntityAbstracti
|
||||
return action;
|
||||
}
|
||||
|
||||
//TODO Finish this
|
||||
protected void setAction(EntityUseAction action) {
|
||||
this.action = action;
|
||||
Enum<?> enumConst = EnumUtil.valueByIndex((Class<? extends Enum<?>>) enumEntityUseActionClass, action.ordinal());
|
||||
if (v_1_17) {
|
||||
//TODO Add 1.17 support
|
||||
//TODO Add 1.17+ support
|
||||
}
|
||||
else {
|
||||
writeEnumConstant(0, enumConst);
|
||||
|
||||
@@ -329,11 +329,11 @@ public final class NMSUtils {
|
||||
|
||||
try {
|
||||
if (mobEffectListClass != null) {
|
||||
getMobEffectListId = mobEffectListClass.getMethod("getId", mobEffectListClass);
|
||||
getMobEffectListById = mobEffectListClass.getMethod("fromId", int.class);
|
||||
getMobEffectListId = Reflection.getMethod(mobEffectListClass, 0, mobEffectListClass);
|
||||
getMobEffectListById = Reflection.getMethod(mobEffectListClass, 0, int.class);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
try {
|
||||
entityPlayerPingField = entityPlayerClass.getField("ping");
|
||||
@@ -403,7 +403,10 @@ public final class NMSUtils {
|
||||
}
|
||||
|
||||
public static double[] recentTPS() {
|
||||
return new WrappedPacket(new NMSPacket(getMinecraftServerInstance(Bukkit.getServer())), minecraftServerClass).readDoubleArray(0);
|
||||
WrappedPacket minecraftServerInstanceReader = new WrappedPacket(
|
||||
new NMSPacket(getMinecraftServerInstance(Bukkit.getServer())),
|
||||
minecraftServerClass);
|
||||
return minecraftServerInstanceReader.readDoubleArray(0);
|
||||
}
|
||||
|
||||
public static Class<?> getNMSClass(String name) throws ClassNotFoundException {
|
||||
|
||||
Reference in new issue
Block a user