Organize proxy models and controllers.

This commit is contained in:
Aust1n46 2022-01-15 17:27:41 -06:00
parent eb24e66bc8
commit 68f46a9b27
8 changed files with 40 additions and 46 deletions

View File

@ -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";

View File

@ -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;

View File

@ -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

View File

@ -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)) {

View File

@ -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;
}

View File

@ -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<VentureChatProxyServer> getServers();
public VentureChatProxyServer getServer(String serverName);
public void sendConsoleMessage(String message);
public boolean isOfflineServerAcknowledgementSet();
}

View File

@ -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;
}
}

View File

@ -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