SteamWar/BauSystem2.0
Archiviert
12
0

Fix ProtocolAPI
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-12-26 15:18:30 +01:00
Ursprung 851de9575e
Commit 6903a0b04e

Datei anzeigen

@ -36,7 +36,23 @@ public class ProtocolAPI {
public static final TinyProtocol tinyProtocol = TinyProtocol.instance; public static final TinyProtocol tinyProtocol = TinyProtocol.instance;
public static void setOutgoingHandler(Class<?> packetClass, BiFunction<Player, Object, Object> handler) { static {
TinyProtocol.instance.setOutFilter((receiver, channel, packet) -> {
BiFunction<Player, Object, Object> handler = outgoingHandler.get(packet.getClass());
if (handler == null)
return packet;
return handler.apply(receiver, packet);
});
TinyProtocol.instance.setInFilter((sender, channel, packet) -> {
BiFunction<Player, Object, Object> handler = incomingHandler.get(packet.getClass());
if (handler == null)
return packet;
return handler.apply(sender, packet);
});
}
public static void setOutgoingHandler
(Class<?> packetClass, BiFunction<Player, Object, Object> handler) {
outgoingHandler.put(packetClass, handler); outgoingHandler.put(packetClass, handler);
} }
@ -44,7 +60,8 @@ public class ProtocolAPI {
outgoingHandler.remove(packetClass); outgoingHandler.remove(packetClass);
} }
public static void setIncomingHandler(Class<?> packetClass, BiFunction<Player, Object, Object> handler) { public static void setIncomingHandler
(Class<?> packetClass, BiFunction<Player, Object, Object> handler) {
incomingHandler.put(packetClass, handler); incomingHandler.put(packetClass, handler);
} }