From 68f46a9b278f366f175eb5c54c7bc5c76aba061d Mon Sep 17 00:00:00 2001 From: Aust1n46 Date: Sat, 15 Jan 2022 17:27:41 -0600 Subject: [PATCH] Organize proxy models and controllers. --- .../proxy/VentureChatProxyController.java} | 6 ++++-- .../VentureChatProxyFlatFileController.java | 4 ++-- .../application/VentureChatBungee.java | 18 +++++++++--------- .../application/VentureChatVelocity.java | 16 ++++++++-------- .../chat/model/VentureChatProxyServer.java | 11 +++++++++++ .../VentureChatProxySource.java | 10 +++++----- .../chat/proxy/VentureChatProxyServer.java | 19 ------------------- .../chat/service/proxy/ProxyUuidService.java | 2 +- 8 files changed, 40 insertions(+), 46 deletions(-) rename src/main/java/venture/Aust1n46/chat/{proxy/VentureChatProxy.java => controllers/proxy/VentureChatProxyController.java} (98%) rename src/main/java/venture/Aust1n46/chat/controllers/{ => proxy}/VentureChatProxyFlatFileController.java (98%) create mode 100644 src/main/java/venture/Aust1n46/chat/model/VentureChatProxyServer.java rename src/main/java/venture/Aust1n46/chat/{proxy => model}/VentureChatProxySource.java (88%) delete mode 100644 src/main/java/venture/Aust1n46/chat/proxy/VentureChatProxyServer.java diff --git a/src/main/java/venture/Aust1n46/chat/proxy/VentureChatProxy.java b/src/main/java/venture/Aust1n46/chat/controllers/proxy/VentureChatProxyController.java similarity index 98% rename from src/main/java/venture/Aust1n46/chat/proxy/VentureChatProxy.java rename to src/main/java/venture/Aust1n46/chat/controllers/proxy/VentureChatProxyController.java index 928a56b..e8f39f8 100644 --- a/src/main/java/venture/Aust1n46/chat/proxy/VentureChatProxy.java +++ b/src/main/java/venture/Aust1n46/chat/controllers/proxy/VentureChatProxyController.java @@ -1,4 +1,4 @@ -package venture.Aust1n46.chat.proxy; +package venture.Aust1n46.chat.controllers.proxy; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -12,9 +12,11 @@ import com.google.inject.Inject; import venture.Aust1n46.chat.controllers.commands.MuteContainer; import venture.Aust1n46.chat.model.SynchronizedVentureChatPlayer; import venture.Aust1n46.chat.model.TemporaryDataInstance; +import venture.Aust1n46.chat.model.VentureChatProxyServer; +import venture.Aust1n46.chat.model.VentureChatProxySource; import venture.Aust1n46.chat.service.proxy.VentureChatProxyPlayerApiService; -public class VentureChatProxy { +public class VentureChatProxyController { public static String PLUGIN_MESSAGING_CHANNEL_NAMESPACE = "venturechat"; public static String PLUGIN_MESSAGING_CHANNEL_NAME = "data"; public static String PLUGIN_MESSAGING_CHANNEL_STRING = "venturechat:data"; diff --git a/src/main/java/venture/Aust1n46/chat/controllers/VentureChatProxyFlatFileController.java b/src/main/java/venture/Aust1n46/chat/controllers/proxy/VentureChatProxyFlatFileController.java similarity index 98% rename from src/main/java/venture/Aust1n46/chat/controllers/VentureChatProxyFlatFileController.java rename to src/main/java/venture/Aust1n46/chat/controllers/proxy/VentureChatProxyFlatFileController.java index 5a89ab6..7ff9361 100644 --- a/src/main/java/venture/Aust1n46/chat/controllers/VentureChatProxyFlatFileController.java +++ b/src/main/java/venture/Aust1n46/chat/controllers/proxy/VentureChatProxyFlatFileController.java @@ -1,4 +1,4 @@ -package venture.Aust1n46.chat.controllers; +package venture.Aust1n46.chat.controllers.proxy; import java.io.File; import java.io.IOException; @@ -18,7 +18,7 @@ import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.YamlConfiguration; import venture.Aust1n46.chat.controllers.commands.MuteContainer; import venture.Aust1n46.chat.model.SynchronizedVentureChatPlayer; -import venture.Aust1n46.chat.proxy.VentureChatProxySource; +import venture.Aust1n46.chat.model.VentureChatProxySource; import venture.Aust1n46.chat.service.proxy.ProxyUuidService; import venture.Aust1n46.chat.service.proxy.VentureChatProxyPlayerApiService; diff --git a/src/main/java/venture/Aust1n46/chat/initiators/application/VentureChatBungee.java b/src/main/java/venture/Aust1n46/chat/initiators/application/VentureChatBungee.java index 8724559..a505ff0 100644 --- a/src/main/java/venture/Aust1n46/chat/initiators/application/VentureChatBungee.java +++ b/src/main/java/venture/Aust1n46/chat/initiators/application/VentureChatBungee.java @@ -26,11 +26,11 @@ import net.md_5.bungee.config.Configuration; import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.YamlConfiguration; import net.md_5.bungee.event.EventHandler; -import venture.Aust1n46.chat.controllers.VentureChatProxyFlatFileController; +import venture.Aust1n46.chat.controllers.proxy.VentureChatProxyController; +import venture.Aust1n46.chat.controllers.proxy.VentureChatProxyFlatFileController; import venture.Aust1n46.chat.guice.VentureChatBungeePluginModule; -import venture.Aust1n46.chat.proxy.VentureChatProxy; -import venture.Aust1n46.chat.proxy.VentureChatProxyServer; -import venture.Aust1n46.chat.proxy.VentureChatProxySource; +import venture.Aust1n46.chat.model.VentureChatProxyServer; +import venture.Aust1n46.chat.model.VentureChatProxySource; import venture.Aust1n46.chat.service.proxy.ProxyUuidService; import venture.Aust1n46.chat.utilities.FormatUtils; @@ -48,7 +48,7 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr @Inject private VentureChatProxyFlatFileController proxyFlatFileController; @Inject - private VentureChatProxy proxy; + private VentureChatProxyController proxy; @Override public void onEnable() { @@ -73,7 +73,7 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr proxyFlatFileController.loadLegacyBungeePlayerData(bungeePlayerDataDirectory, this); proxyFlatFileController.loadProxyPlayerData(bungeePlayerDataDirectory, this); - this.getProxy().registerChannel(VentureChatProxy.PLUGIN_MESSAGING_CHANNEL_STRING); + this.getProxy().registerChannel(VentureChatProxyController.PLUGIN_MESSAGING_CHANNEL_STRING); this.getProxy().getPluginManager().registerListener(this, this); } @@ -109,7 +109,7 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr for (String send : getProxy().getServers().keySet()) { if (getProxy().getServers().get(send).getPlayers().size() > 0) { - getProxy().getServers().get(send).sendData(VentureChatProxy.PLUGIN_MESSAGING_CHANNEL_STRING, outstream.toByteArray()); + getProxy().getServers().get(send).sendData(VentureChatProxyController.PLUGIN_MESSAGING_CHANNEL_STRING, outstream.toByteArray()); } } } catch (Exception e) { @@ -119,7 +119,7 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr @EventHandler public void onPluginMessage(PluginMessageEvent event) { - if (!event.getTag().equals(VentureChatProxy.PLUGIN_MESSAGING_CHANNEL_STRING) && !event.getTag().contains("viaversion:")) { + if (!event.getTag().equals(VentureChatProxyController.PLUGIN_MESSAGING_CHANNEL_STRING) && !event.getTag().contains("viaversion:")) { return; } if (!(event.getSender() instanceof Server)) { @@ -131,7 +131,7 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr @Override public void sendPluginMessage(String serverName, byte[] data) { - getProxy().getServers().get(serverName).sendData(VentureChatProxy.PLUGIN_MESSAGING_CHANNEL_STRING, data); + getProxy().getServers().get(serverName).sendData(VentureChatProxyController.PLUGIN_MESSAGING_CHANNEL_STRING, data); } @Override diff --git a/src/main/java/venture/Aust1n46/chat/initiators/application/VentureChatVelocity.java b/src/main/java/venture/Aust1n46/chat/initiators/application/VentureChatVelocity.java index e08835f..a9d1d1a 100644 --- a/src/main/java/venture/Aust1n46/chat/initiators/application/VentureChatVelocity.java +++ b/src/main/java/venture/Aust1n46/chat/initiators/application/VentureChatVelocity.java @@ -32,10 +32,10 @@ import com.velocitypowered.api.proxy.server.RegisteredServer; import net.md_5.bungee.config.Configuration; import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.YamlConfiguration; -import venture.Aust1n46.chat.controllers.VentureChatProxyFlatFileController; -import venture.Aust1n46.chat.proxy.VentureChatProxy; -import venture.Aust1n46.chat.proxy.VentureChatProxyServer; -import venture.Aust1n46.chat.proxy.VentureChatProxySource; +import venture.Aust1n46.chat.controllers.proxy.VentureChatProxyController; +import venture.Aust1n46.chat.controllers.proxy.VentureChatProxyFlatFileController; +import venture.Aust1n46.chat.model.VentureChatProxyServer; +import venture.Aust1n46.chat.model.VentureChatProxySource; import venture.Aust1n46.chat.utilities.FormatUtils; /** @@ -45,14 +45,14 @@ import venture.Aust1n46.chat.utilities.FormatUtils; */ public class VentureChatVelocity implements VentureChatProxySource { private final ProxyServer proxyServer; - private final ChannelIdentifier channelIdentifier = MinecraftChannelIdentifier.create(VentureChatProxy.PLUGIN_MESSAGING_CHANNEL_NAMESPACE, - VentureChatProxy.PLUGIN_MESSAGING_CHANNEL_NAME); + private final ChannelIdentifier channelIdentifier = MinecraftChannelIdentifier.create(VentureChatProxyController.PLUGIN_MESSAGING_CHANNEL_NAMESPACE, + VentureChatProxyController.PLUGIN_MESSAGING_CHANNEL_NAME); private final Logger logger; @Inject private VentureChatProxyFlatFileController proxyFlatFileController; @Inject - private VentureChatProxy proxy; + private VentureChatProxyController proxy; @Inject @DataDirectory @@ -136,7 +136,7 @@ public class VentureChatVelocity implements VentureChatProxySource { @Subscribe public void onPluginMessage(PluginMessageEvent event) { String channelIdentifierId = event.getIdentifier().getId(); - if (!channelIdentifierId.equals(VentureChatProxy.PLUGIN_MESSAGING_CHANNEL_STRING) && !channelIdentifierId.contains("viaversion:")) { + if (!channelIdentifierId.equals(VentureChatProxyController.PLUGIN_MESSAGING_CHANNEL_STRING) && !channelIdentifierId.contains("viaversion:")) { return; } if (!(event.getSource() instanceof ServerConnection)) { diff --git a/src/main/java/venture/Aust1n46/chat/model/VentureChatProxyServer.java b/src/main/java/venture/Aust1n46/chat/model/VentureChatProxyServer.java new file mode 100644 index 0000000..e1b8138 --- /dev/null +++ b/src/main/java/venture/Aust1n46/chat/model/VentureChatProxyServer.java @@ -0,0 +1,11 @@ +package venture.Aust1n46.chat.model; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class VentureChatProxyServer { + private String name; + private boolean empty; +} diff --git a/src/main/java/venture/Aust1n46/chat/proxy/VentureChatProxySource.java b/src/main/java/venture/Aust1n46/chat/model/VentureChatProxySource.java similarity index 88% rename from src/main/java/venture/Aust1n46/chat/proxy/VentureChatProxySource.java rename to src/main/java/venture/Aust1n46/chat/model/VentureChatProxySource.java index 441235e..b7890ce 100644 --- a/src/main/java/venture/Aust1n46/chat/proxy/VentureChatProxySource.java +++ b/src/main/java/venture/Aust1n46/chat/model/VentureChatProxySource.java @@ -1,15 +1,15 @@ -package venture.Aust1n46.chat.proxy; +package venture.Aust1n46.chat.model; import java.util.List; public interface VentureChatProxySource { public void sendPluginMessage(String serverName, byte[] data); - + public List getServers(); - + public VentureChatProxyServer getServer(String serverName); - + public void sendConsoleMessage(String message); - + public boolean isOfflineServerAcknowledgementSet(); } diff --git a/src/main/java/venture/Aust1n46/chat/proxy/VentureChatProxyServer.java b/src/main/java/venture/Aust1n46/chat/proxy/VentureChatProxyServer.java deleted file mode 100644 index 1971b72..0000000 --- a/src/main/java/venture/Aust1n46/chat/proxy/VentureChatProxyServer.java +++ /dev/null @@ -1,19 +0,0 @@ -package venture.Aust1n46.chat.proxy; - -public class VentureChatProxyServer { - private String name; - private boolean empty; - - public VentureChatProxyServer(String name, boolean empty) { - this.name = name; - this.empty = empty; - } - - public boolean isEmpty() { - return empty; - } - - public String getName() { - return name; - } -} diff --git a/src/main/java/venture/Aust1n46/chat/service/proxy/ProxyUuidService.java b/src/main/java/venture/Aust1n46/chat/service/proxy/ProxyUuidService.java index 1156b67..7b4091a 100644 --- a/src/main/java/venture/Aust1n46/chat/service/proxy/ProxyUuidService.java +++ b/src/main/java/venture/Aust1n46/chat/service/proxy/ProxyUuidService.java @@ -4,7 +4,7 @@ import java.util.UUID; import com.google.inject.Singleton; -import venture.Aust1n46.chat.proxy.VentureChatProxySource; +import venture.Aust1n46.chat.model.VentureChatProxySource; import venture.Aust1n46.chat.utilities.FormatUtils; @Singleton