Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
851de9575e
Commit
6903a0b04e
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren