diff --git a/src/main/java/io/github/_4drian3d/unsignedvelocity/UnSignedVelocity.java b/src/main/java/io/github/_4drian3d/unsignedvelocity/UnSignedVelocity.java index 8156f2d..e391e76 100644 --- a/src/main/java/io/github/_4drian3d/unsignedvelocity/UnSignedVelocity.java +++ b/src/main/java/io/github/_4drian3d/unsignedvelocity/UnSignedVelocity.java @@ -12,7 +12,7 @@ import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.proxy.VelocityServer; import io.github._4drian3d.unsignedvelocity.configuration.Configuration; -import io.github._4drian3d.unsignedvelocity.listener.LoadableEventListener; +import io.github._4drian3d.unsignedvelocity.listener.LoadablePacketListener; import io.github._4drian3d.unsignedvelocity.listener.packet.chat.ChatListener; import io.github._4drian3d.unsignedvelocity.listener.packet.command.CommandListener; import io.github._4drian3d.unsignedvelocity.listener.packet.login.LoginListener; @@ -86,8 +86,8 @@ public void onProxyInitialize(ProxyInitializeEvent event) { ServerDataListener.class, ServerResponseListener.class ).map(injector::getInstance) - .filter(LoadableEventListener::canBeLoaded) - .forEach(listener -> listener.register(this)); + .filter(LoadablePacketListener::canBeLoaded) + .forEach(LoadablePacketListener::register); PacketEvents.getAPI().init(); diff --git a/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/LoadableEventListener.java b/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/LoadableEventListener.java deleted file mode 100644 index fbf996f..0000000 --- a/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/LoadableEventListener.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.github._4drian3d.unsignedvelocity.listener; - -import io.github._4drian3d.unsignedvelocity.UnSignedVelocity; - -public interface LoadableEventListener { - void register(UnSignedVelocity plugin); - - boolean canBeLoaded(); -} diff --git a/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/LoadablePacketListener.java b/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/LoadablePacketListener.java new file mode 100644 index 0000000..f37a92d --- /dev/null +++ b/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/LoadablePacketListener.java @@ -0,0 +1,12 @@ +package io.github._4drian3d.unsignedvelocity.listener; + +import com.github.retrooper.packetevents.PacketEvents; +import com.github.retrooper.packetevents.event.PacketListenerCommon; + +public interface LoadablePacketListener { + default void register() { + PacketEvents.getAPI().getEventManager().registerListener((PacketListenerCommon) this); + } + + boolean canBeLoaded(); +} diff --git a/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/chat/ChatListener.java b/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/chat/ChatListener.java index db5ecf3..44e1d04 100644 --- a/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/chat/ChatListener.java +++ b/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/chat/ChatListener.java @@ -1,6 +1,5 @@ package io.github._4drian3d.unsignedvelocity.listener.packet.chat; -import com.github.retrooper.packetevents.PacketEvents; import com.github.retrooper.packetevents.event.PacketListenerAbstract; import com.github.retrooper.packetevents.event.PacketListenerPriority; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -11,12 +10,12 @@ import com.google.inject.Inject; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; import io.github._4drian3d.unsignedvelocity.UnSignedVelocity; -import io.github._4drian3d.unsignedvelocity.listener.LoadableEventListener; +import io.github._4drian3d.unsignedvelocity.listener.LoadablePacketListener; import io.github._4drian3d.unsignedvelocity.utils.ConnectionUtil; import java.time.Instant; -public final class ChatListener extends PacketListenerAbstract implements LoadableEventListener { +public final class ChatListener extends PacketListenerAbstract implements LoadablePacketListener { private final UnSignedVelocity plugin; @Inject @@ -25,9 +24,6 @@ public ChatListener(UnSignedVelocity plugin) { this.plugin = plugin; } - @Override - public void register(UnSignedVelocity plugin) { PacketEvents.getAPI().getEventManager().registerListener(new ChatListener(plugin)); } - @Override public boolean canBeLoaded() { return plugin.getConfiguration().applyChatMessages(); diff --git a/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/command/CommandListener.java b/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/command/CommandListener.java index e09c69e..72bf5c8 100644 --- a/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/command/CommandListener.java +++ b/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/command/CommandListener.java @@ -1,6 +1,5 @@ package io.github._4drian3d.unsignedvelocity.listener.packet.command; -import com.github.retrooper.packetevents.PacketEvents; import com.github.retrooper.packetevents.event.PacketListenerAbstract; import com.github.retrooper.packetevents.event.PacketListenerPriority; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -11,12 +10,12 @@ import com.google.inject.Inject; import com.velocitypowered.proxy.connection.client.ConnectedPlayer; import io.github._4drian3d.unsignedvelocity.UnSignedVelocity; -import io.github._4drian3d.unsignedvelocity.listener.LoadableEventListener; +import io.github._4drian3d.unsignedvelocity.listener.LoadablePacketListener; import io.github._4drian3d.unsignedvelocity.utils.ConnectionUtil; import java.time.Instant; -public final class CommandListener extends PacketListenerAbstract implements LoadableEventListener { +public final class CommandListener extends PacketListenerAbstract implements LoadablePacketListener { private final UnSignedVelocity plugin; @Inject @@ -25,9 +24,6 @@ public CommandListener(UnSignedVelocity plugin) { this.plugin = plugin; } - @Override - public void register(UnSignedVelocity plugin) { PacketEvents.getAPI().getEventManager().registerListener(new CommandListener(plugin)); } - @Override public boolean canBeLoaded() { return plugin.getConfiguration().removeSignedCommandInformation(); diff --git a/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/data/ServerDataListener.java b/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/data/ServerDataListener.java index bdecab9..ca51fe2 100644 --- a/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/data/ServerDataListener.java +++ b/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/data/ServerDataListener.java @@ -1,6 +1,5 @@ package io.github._4drian3d.unsignedvelocity.listener.packet.data; -import com.github.retrooper.packetevents.PacketEvents; import com.github.retrooper.packetevents.event.PacketListenerAbstract; import com.github.retrooper.packetevents.event.PacketListenerPriority; import com.github.retrooper.packetevents.event.PacketSendEvent; @@ -11,9 +10,9 @@ import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerServerData; import com.google.inject.Inject; import io.github._4drian3d.unsignedvelocity.UnSignedVelocity; -import io.github._4drian3d.unsignedvelocity.listener.LoadableEventListener; +import io.github._4drian3d.unsignedvelocity.listener.LoadablePacketListener; -public final class ServerDataListener extends PacketListenerAbstract implements LoadableEventListener { +public final class ServerDataListener extends PacketListenerAbstract implements LoadablePacketListener { private final UnSignedVelocity plugin; @Inject @@ -22,9 +21,6 @@ public ServerDataListener(UnSignedVelocity plugin) { this.plugin = plugin; } - @Override - public void register(UnSignedVelocity plugin) { PacketEvents.getAPI().getEventManager().registerListener(new ServerDataListener(plugin)); } - @Override public boolean canBeLoaded() { return plugin.getConfiguration().sendSecureChatData(); diff --git a/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/login/LoginListener.java b/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/login/LoginListener.java index 562f9b8..2c5a4ce 100644 --- a/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/login/LoginListener.java +++ b/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/login/LoginListener.java @@ -1,6 +1,5 @@ package io.github._4drian3d.unsignedvelocity.listener.packet.login; -import com.github.retrooper.packetevents.PacketEvents; import com.github.retrooper.packetevents.event.PacketListenerAbstract; import com.github.retrooper.packetevents.event.PacketListenerPriority; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -13,13 +12,13 @@ import com.github.retrooper.packetevents.wrapper.login.server.WrapperLoginServerEncryptionRequest; import com.google.inject.Inject; import io.github._4drian3d.unsignedvelocity.UnSignedVelocity; -import io.github._4drian3d.unsignedvelocity.listener.LoadableEventListener; +import io.github._4drian3d.unsignedvelocity.listener.LoadablePacketListener; import io.github._4drian3d.unsignedvelocity.utils.ClientVersionUtil; import java.security.PublicKey; import java.util.WeakHashMap; -public final class LoginListener extends PacketListenerAbstract implements LoadableEventListener { +public final class LoginListener extends PacketListenerAbstract implements LoadablePacketListener { private final UnSignedVelocity plugin; public static final WeakHashMap SERVER_ENCRYPTED_VERIFY_TOKENS_CACHE = new WeakHashMap<>(); @@ -29,9 +28,6 @@ public LoginListener(UnSignedVelocity plugin) { this.plugin = plugin; } - @Override - public void register(UnSignedVelocity plugin) { PacketEvents.getAPI().getEventManager().registerListener(new LoginListener(plugin)); } - @Override public boolean canBeLoaded() { return plugin.getConfiguration().removeSignedKey(); diff --git a/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/status/ServerResponseListener.java b/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/status/ServerResponseListener.java index 4a11171..196cb92 100644 --- a/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/status/ServerResponseListener.java +++ b/src/main/java/io/github/_4drian3d/unsignedvelocity/listener/packet/status/ServerResponseListener.java @@ -1,6 +1,5 @@ package io.github._4drian3d.unsignedvelocity.listener.packet.status; -import com.github.retrooper.packetevents.PacketEvents; import com.github.retrooper.packetevents.event.PacketListenerAbstract; import com.github.retrooper.packetevents.event.PacketListenerPriority; import com.github.retrooper.packetevents.event.PacketSendEvent; @@ -11,9 +10,9 @@ import com.google.gson.JsonObject; import com.google.inject.Inject; import io.github._4drian3d.unsignedvelocity.UnSignedVelocity; -import io.github._4drian3d.unsignedvelocity.listener.LoadableEventListener; +import io.github._4drian3d.unsignedvelocity.listener.LoadablePacketListener; -public final class ServerResponseListener extends PacketListenerAbstract implements LoadableEventListener { +public final class ServerResponseListener extends PacketListenerAbstract implements LoadablePacketListener { private final UnSignedVelocity plugin; @Inject @@ -22,9 +21,6 @@ public ServerResponseListener(UnSignedVelocity plugin) { this.plugin = plugin; } - @Override - public void register(UnSignedVelocity plugin) { PacketEvents.getAPI().getEventManager().registerListener(new ServerResponseListener(plugin)); } - @Override public boolean canBeLoaded() { return plugin.getConfiguration().sendSafeServerStatus();