Skip to content

Commit

Permalink
Fix Bukkit 1.7.10 support
Browse files Browse the repository at this point in the history
  • Loading branch information
56738 committed Dec 20, 2023
1 parent 86be7be commit aab58dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,10 @@ public Object createMessage(final @NotNull V viewer, final @NotNull Component me
findMcClassName("network.protocol.game.ClientboundChatPacket"),
findMcClassName("network.protocol.game.ClientboundSystemChatPacket")
);
// ClientboundSystemChatPacket constructor changed for 1.19.1
chatPacketConstructor = findConstructor(chatPacketClass, CLASS_CHAT_COMPONENT, boolean.class);
if (MESSAGE_TYPE_CHAT == Integer.valueOf(0)) {
// ClientboundSystemChatPacket constructor changed for 1.19.1
chatPacketConstructor = findConstructor(chatPacketClass, CLASS_CHAT_COMPONENT, boolean.class);
}
if (chatPacketConstructor == null) {
// ClientboundSystemChatPacket constructor changed for 1.19
chatPacketConstructor = findConstructor(chatPacketClass, CLASS_CHAT_COMPONENT, int.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.ComponentSerializer;
Expand Down Expand Up @@ -131,7 +133,12 @@ public static boolean isSupported() {
gson = gsonField.get(null);
}
}
for (final Class<?> serializerClass : CLASS_CHAT_COMPONENT.getClasses()) {
final List<Class<?>> candidates = new ArrayList<>();
if (chatSerializerClass != null) {
candidates.add(chatSerializerClass);
}
candidates.addAll(Arrays.asList(CLASS_CHAT_COMPONENT.getClasses()));
for (final Class<?> serializerClass : candidates) {
final Method[] declaredMethods = serializerClass.getDeclaredMethods();
final Method deserialize = Arrays.stream(declaredMethods)
.filter(m -> Modifier.isStatic(m.getModifiers()))
Expand Down

0 comments on commit aab58dd

Please sign in to comment.