From 3ca4a7d99f2d2eae3bbbdaacb6541a8db828a202 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 6 Aug 2022 21:30:24 +0200 Subject: [PATCH] Reflections --- SpigotCore_19/src/de/steamwar/core/ChatWrapper19.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/SpigotCore_19/src/de/steamwar/core/ChatWrapper19.java b/SpigotCore_19/src/de/steamwar/core/ChatWrapper19.java index e883f54..38393ba 100644 --- a/SpigotCore_19/src/de/steamwar/core/ChatWrapper19.java +++ b/SpigotCore_19/src/de/steamwar/core/ChatWrapper19.java @@ -26,6 +26,9 @@ import net.minecraft.network.chat.contents.LiteralContents; import net.minecraft.network.protocol.game.ClientboundServerDataPacket; public class ChatWrapper19 implements ChatWrapper { + + private static final Reflection.FieldAccessor accessor = Reflection.getField(ClientboundServerDataPacket.class, "c",Boolean.class); + @Override public Object stringToChatComponent(String text) { return IChatMutableComponent.a(new LiteralContents(text)); @@ -40,11 +43,7 @@ public class ChatWrapper19 implements ChatWrapper { @Override public Object modifyServerDataPacket(Object o) { ClientboundServerDataPacket clientboundServerDataPacket = (ClientboundServerDataPacket) o; - try{ - o.getClass().getDeclaredField("c").setBoolean(clientboundServerDataPacket,true); - }catch (NoSuchFieldException | IllegalAccessException e) { - //ignore - } + accessor.set(clientboundServerDataPacket,true); return clientboundServerDataPacket; } }