From 96182351699644dd19946d702e82639927259425 Mon Sep 17 00:00:00 2001 From: Nico Britze Date: Wed, 14 Feb 2024 16:58:39 +0100 Subject: [PATCH] Improve compatibility with third party BungeeCord forks. --- .../simplix/protocolize/api/SimpleMappingProvider.java | 9 +++------ .../bungee/packet/BungeeCordProtocolizePacket.java | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/protocolize-api/src/main/java/dev/simplix/protocolize/api/SimpleMappingProvider.java b/protocolize-api/src/main/java/dev/simplix/protocolize/api/SimpleMappingProvider.java index 51247a0..59a06b6 100644 --- a/protocolize-api/src/main/java/dev/simplix/protocolize/api/SimpleMappingProvider.java +++ b/protocolize-api/src/main/java/dev/simplix/protocolize/api/SimpleMappingProvider.java @@ -28,12 +28,9 @@ public synchronized void registerMapping(Object mappable, ProtocolMapping mappin @Override public T mapping(Object mappable, int protocolVersion) { - for (ProtocolMapping mapping : mappingMultimap.get(mappable)) { - if (mapping.inRange(protocolVersion)) { - return (T) mapping; - } - } - return null; + return (T) mappingMultimap.get(mappable).parallelStream() + .filter(protocolMapping -> protocolMapping.inRange(protocolVersion)) + .findFirst().orElse(null); } @Override diff --git a/protocolize-bungeecord/src/main/java/dev/simplix/protocolize/bungee/packet/BungeeCordProtocolizePacket.java b/protocolize-bungeecord/src/main/java/dev/simplix/protocolize/bungee/packet/BungeeCordProtocolizePacket.java index aa57508..e2e2ece 100644 --- a/protocolize-bungeecord/src/main/java/dev/simplix/protocolize/bungee/packet/BungeeCordProtocolizePacket.java +++ b/protocolize-bungeecord/src/main/java/dev/simplix/protocolize/bungee/packet/BungeeCordProtocolizePacket.java @@ -58,6 +58,7 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco DebugUtil.writeDump(buf, new CorruptedFrameException("Protocolize is unable to read packet " + obtainProtocolizePacketClass().getName() + " at protocol version " + protocolVersion + " in direction " + direction.name())); } + buf.resetReaderIndex(); } catch (Throwable throwable) { BadPacketException badPacketException = new BadPacketException("Protocolize is unable to read packet " + obtainProtocolizePacketClass().getName() + " at protocol version " + protocolVersion + " in direction " + direction.name(), throwable);