mirror of
https://github.com/NEZNAMY/TAB.git
synced 2026-11-26 10:29:49 -05:00
replaced unnecessary reflection
This commit is contained in:
1 parent
225e179566
commit
9ab5bbf586
13 files changed
+36
-16
No files matched your search
@@ -24,6 +24,7 @@ public abstract class MethodAPI {
|
||||
public abstract double[] getRecentTps();
|
||||
public abstract void sendPacket(Player p, Object nmsPacket);
|
||||
public abstract Object newPacketPlayOutEntityDestroy(int[] ids);
|
||||
public abstract Object newPacketPlayOutChat(Object chatComponent, Object position);
|
||||
|
||||
public double getTPS() {
|
||||
if (!spigot) return -1;
|
||||
|
||||
@@ -37,4 +37,7 @@ public class MethodAPI_v1_10_R1 extends MethodAPI {
|
||||
public Object newPacketPlayOutEntityDestroy(int[] ids) {
|
||||
return new PacketPlayOutEntityDestroy(ids);
|
||||
}
|
||||
public Object newPacketPlayOutChat(Object chatComponent, Object position) {
|
||||
return new PacketPlayOutChat((IChatBaseComponent) chatComponent, (Byte) position);
|
||||
}
|
||||
}
|
||||
@@ -37,4 +37,7 @@ public class MethodAPI_v1_11_R1 extends MethodAPI {
|
||||
public Object newPacketPlayOutEntityDestroy(int[] ids) {
|
||||
return new PacketPlayOutEntityDestroy(ids);
|
||||
}
|
||||
public Object newPacketPlayOutChat(Object chatComponent, Object position) {
|
||||
return new PacketPlayOutChat((IChatBaseComponent) chatComponent, (Byte) position);
|
||||
}
|
||||
}
|
||||
@@ -37,4 +37,7 @@ public class MethodAPI_v1_12_R1 extends MethodAPI {
|
||||
public Object newPacketPlayOutEntityDestroy(int[] ids) {
|
||||
return new PacketPlayOutEntityDestroy(ids);
|
||||
}
|
||||
public Object newPacketPlayOutChat(Object chatComponent, Object position) {
|
||||
return new PacketPlayOutChat((IChatBaseComponent) chatComponent, (ChatMessageType) position);
|
||||
}
|
||||
}
|
||||
@@ -37,4 +37,7 @@ public class MethodAPI_v1_13_R1 extends MethodAPI {
|
||||
public Object newPacketPlayOutEntityDestroy(int[] ids) {
|
||||
return new PacketPlayOutEntityDestroy(ids);
|
||||
}
|
||||
public Object newPacketPlayOutChat(Object chatComponent, Object position) {
|
||||
return new PacketPlayOutChat((IChatBaseComponent) chatComponent, (ChatMessageType) position);
|
||||
}
|
||||
}
|
||||
@@ -37,4 +37,7 @@ public class MethodAPI_v1_13_R2 extends MethodAPI {
|
||||
public Object newPacketPlayOutEntityDestroy(int[] ids) {
|
||||
return new PacketPlayOutEntityDestroy(ids);
|
||||
}
|
||||
public Object newPacketPlayOutChat(Object chatComponent, Object position) {
|
||||
return new PacketPlayOutChat((IChatBaseComponent) chatComponent, (ChatMessageType) position);
|
||||
}
|
||||
}
|
||||
@@ -37,4 +37,7 @@ public class MethodAPI_v1_14_R1 extends MethodAPI {
|
||||
public Object newPacketPlayOutEntityDestroy(int[] ids) {
|
||||
return new PacketPlayOutEntityDestroy(ids);
|
||||
}
|
||||
public Object newPacketPlayOutChat(Object chatComponent, Object position) {
|
||||
return new PacketPlayOutChat((IChatBaseComponent) chatComponent, (ChatMessageType) position);
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,9 @@ public class MethodAPI_v1_8_R1 extends MethodAPI {
|
||||
public Object newPacketPlayOutEntityDestroy(int[] ids) {
|
||||
return new PacketPlayOutEntityDestroy(ids);
|
||||
}
|
||||
public Object newPacketPlayOutChat(Object chatComponent, Object position) {
|
||||
return new PacketPlayOutChat((IChatBaseComponent) chatComponent, (Byte) position);
|
||||
}
|
||||
|
||||
private static Field NetworkManager_CHANNEL;
|
||||
|
||||
|
||||
@@ -37,4 +37,7 @@ public class MethodAPI_v1_8_R2 extends MethodAPI {
|
||||
public Object newPacketPlayOutEntityDestroy(int[] ids) {
|
||||
return new PacketPlayOutEntityDestroy(ids);
|
||||
}
|
||||
public Object newPacketPlayOutChat(Object chatComponent, Object position) {
|
||||
return new PacketPlayOutChat((IChatBaseComponent) chatComponent, (Byte) position);
|
||||
}
|
||||
}
|
||||
@@ -37,4 +37,7 @@ public class MethodAPI_v1_8_R3 extends MethodAPI {
|
||||
public Object newPacketPlayOutEntityDestroy(int[] ids) {
|
||||
return new PacketPlayOutEntityDestroy(ids);
|
||||
}
|
||||
public Object newPacketPlayOutChat(Object chatComponent, Object position) {
|
||||
return new PacketPlayOutChat((IChatBaseComponent) chatComponent, (Byte) position);
|
||||
}
|
||||
}
|
||||
@@ -37,4 +37,7 @@ public class MethodAPI_v1_9_R1 extends MethodAPI {
|
||||
public Object newPacketPlayOutEntityDestroy(int[] ids) {
|
||||
return new PacketPlayOutEntityDestroy(ids);
|
||||
}
|
||||
public Object newPacketPlayOutChat(Object chatComponent, Object position) {
|
||||
return new PacketPlayOutChat((IChatBaseComponent) chatComponent, (Byte) position);
|
||||
}
|
||||
}
|
||||
@@ -37,4 +37,7 @@ public class MethodAPI_v1_9_R2 extends MethodAPI {
|
||||
public Object newPacketPlayOutEntityDestroy(int[] ids) {
|
||||
return new PacketPlayOutEntityDestroy(ids);
|
||||
}
|
||||
public Object newPacketPlayOutChat(Object chatComponent, Object position) {
|
||||
return new PacketPlayOutChat((IChatBaseComponent) chatComponent, (Byte) position);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package me.neznamy.tab.shared.packets;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import me.neznamy.tab.bukkit.packets.EnumAPI;
|
||||
import me.neznamy.tab.bukkit.packets.method.MethodAPI;
|
||||
import me.neznamy.tab.shared.Shared;
|
||||
@@ -23,9 +21,9 @@ public class PacketPlayOutChat extends UniversalPacketPlayOut{
|
||||
}
|
||||
public Object toNMS() throws Exception {
|
||||
if (versionNumber >= 12) {
|
||||
return newPacketPlayOutChat.newInstance(component, type.toNMS());
|
||||
return MethodAPI.getInstance().newPacketPlayOutChat(component, type.toNMS());
|
||||
} else {
|
||||
return newPacketPlayOutChat.newInstance(component, type.toByte());
|
||||
return MethodAPI.getInstance().newPacketPlayOutChat(component, type.toByte());
|
||||
}
|
||||
}
|
||||
public Object toBungee(int clientVersion) {
|
||||
@@ -52,16 +50,4 @@ public class PacketPlayOutChat extends UniversalPacketPlayOut{
|
||||
return nmsEquivalent;
|
||||
}
|
||||
}
|
||||
|
||||
private static Constructor<?> newPacketPlayOutChat;
|
||||
|
||||
static {
|
||||
try {
|
||||
if (versionNumber >= 8) {
|
||||
newPacketPlayOutChat = getConstructor(getNMSClass("PacketPlayOutChat"), 2);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Shared.error("Failed to initialize PacketPlayOutChat", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user