Throw channel register/unregister events only once.
@@ -83,21 +83,19 @@ public void onCustomPacketRegistration(CustomPacketRegistrationEvent<?> event) {
Platform.Type.CLIENT : Platform.Type.SERVER);
if (event.getOperation().equals("REGISTER")) {
-
- channels.addAll(event.getRegistrations());
-
for (String channel : event.getRegistrations()) {
+ if (channels.add(channel)) {
SpongeImpl.postEvent(SpongeEventFactory.createChannelRegistrationEventRegister(currentCause, channel));
}
+ }
} else if (event.getOperation().equals("UNREGISTER")) {
-
- channels.removeAll(event.getRegistrations());
-
for (String channel : event.getRegistrations()) {
+ if (channels.remove(channel)) {
SpongeImpl.postEvent(SpongeEventFactory.createChannelRegistrationEventUnregister(currentCause, channel));
}
}
}
+ }
protected static CPacketCustomPayload getRegPacketClient(String channelName) {
return new CPacketCustomPayload("REGISTER", new PacketBuffer(wrappedBuffer(channelName.getBytes(Charsets.UTF_8))));
