From 0e3a97b2699138ba83812d675d61e6f4667e0f72 Mon Sep 17 00:00:00 2001 From: Aust1n46 Date: Sat, 28 Aug 2021 22:37:24 -0400 Subject: [PATCH] Add player data support to Velocity impl. --- TODO.txt | 2 + pom.xml | 3 +- .../chat/bungee/MineverseChatBungee.java | 35 +++---- .../chat/bungee/VentureChatProxySource.java | 4 + .../chat/bungee/VentureChatVelocity.java | 65 ++++++++++++- ...eePlayerData.java => ProxyPlayerData.java} | 96 +++++++++---------- .../Aust1n46/chat/listeners/ChatListener.java | 2 +- .../Aust1n46/chat/utilities/Format.java | 4 + .../Aust1n46/chat/utilities/UUIDFetcher.java | 29 +++--- src/main/resources/velocityconfig.yml | 11 +++ 10 files changed, 164 insertions(+), 87 deletions(-) rename src/main/java/mineverse/Aust1n46/chat/database/{BungeePlayerData.java => ProxyPlayerData.java} (55%) create mode 100644 src/main/resources/velocityconfig.yml diff --git a/TODO.txt b/TODO.txt index bf7e1a2..75771a6 100644 --- a/TODO.txt +++ b/TODO.txt @@ -108,3 +108,5 @@ Add clans channel from SimpleClans Look into changing Bukkit chat event to not be cancelled. Expand on EssentialsDiscord integration to allow for custom MessageTypes for each channel + +Expand placeholder matching regex in convertToJson method diff --git a/pom.xml b/pom.xml index ec0bb04..caa00ca 100644 --- a/pom.xml +++ b/pom.xml @@ -61,6 +61,7 @@ com.zaxxer:HikariCP + net.md-5:bungeecord-config @@ -185,7 +186,7 @@ bungeecord-api 1.13-SNAPSHOT jar - provided + compile net.md-5 diff --git a/src/main/java/mineverse/Aust1n46/chat/bungee/MineverseChatBungee.java b/src/main/java/mineverse/Aust1n46/chat/bungee/MineverseChatBungee.java index e2146b1..ea0cfc1 100644 --- a/src/main/java/mineverse/Aust1n46/chat/bungee/MineverseChatBungee.java +++ b/src/main/java/mineverse/Aust1n46/chat/bungee/MineverseChatBungee.java @@ -7,9 +7,11 @@ import java.nio.file.Files; import java.util.List; import java.util.stream.Collectors; -import mineverse.Aust1n46.chat.database.BungeePlayerData; +import mineverse.Aust1n46.chat.database.ProxyPlayerData; +import mineverse.Aust1n46.chat.utilities.Format; import mineverse.Aust1n46.chat.utilities.UUIDFetcher; import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.Server; import net.md_5.bungee.api.event.PluginMessageEvent; @@ -29,13 +31,11 @@ import net.md_5.bungee.event.EventHandler; * @author Aust1n46 */ public class MineverseChatBungee extends Plugin implements Listener, VentureChatProxySource { - private static MineverseChatBungee instance; private static Configuration bungeeConfig; + private File BUNGEE_PLAYER_DATA_DIRECTORY_PATH; @Override public void onEnable() { - instance = this; - if(!getDataFolder().exists()) { getDataFolder().mkdir(); } @@ -50,8 +50,9 @@ public class MineverseChatBungee extends Plugin implements Listener, VentureChat e.printStackTrace(); } - BungeePlayerData.loadLegacyBungeePlayerData(); - BungeePlayerData.loadBungeePlayerData(); + BUNGEE_PLAYER_DATA_DIRECTORY_PATH = new File(getDataFolder().getAbsolutePath() + "/PlayerData"); + ProxyPlayerData.loadLegacyBungeePlayerData(BUNGEE_PLAYER_DATA_DIRECTORY_PATH, this); + ProxyPlayerData.loadProxyPlayerData(BUNGEE_PLAYER_DATA_DIRECTORY_PATH, this); this.getProxy().registerChannel(VentureChatProxy.PLUGIN_MESSAGING_CHANNEL_STRING); this.getProxy().getPluginManager().registerListener(this, this); @@ -59,15 +60,7 @@ public class MineverseChatBungee extends Plugin implements Listener, VentureChat @Override public void onDisable() { - BungeePlayerData.saveBungeePlayerData(); - } - - public static MineverseChatBungee getInstance() { - return instance; - } - - public static Configuration getBungeeConfig() { - return bungeeConfig; + ProxyPlayerData.saveProxyPlayerData(BUNGEE_PLAYER_DATA_DIRECTORY_PATH, this); } @EventHandler @@ -82,7 +75,7 @@ public class MineverseChatBungee extends Plugin implements Listener, VentureChat @EventHandler public void onPlayerJoinNetwork(PostLoginEvent event) { - UUIDFetcher.checkOfflineUUIDWarningBungee(event.getPlayer().getUniqueId()); + UUIDFetcher.checkOfflineUUIDWarningProxy(event.getPlayer().getUniqueId(), this); } private void updatePlayerNames() { @@ -133,4 +126,14 @@ public class MineverseChatBungee extends Plugin implements Listener, VentureChat ProxyServer server = (ProxyServer) getProxy().getServers().get(serverName); return new VentureChatProxyServer(serverName, server.getPlayers().isEmpty()); } + + @Override + public void sendConsoleMessage(String message) { + ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll(message))); + } + + @Override + public boolean isOfflineServerAcknowledgementSet() { + return bungeeConfig.getBoolean("offline_server_acknowledgement"); + } } diff --git a/src/main/java/mineverse/Aust1n46/chat/bungee/VentureChatProxySource.java b/src/main/java/mineverse/Aust1n46/chat/bungee/VentureChatProxySource.java index 884af39..d710703 100644 --- a/src/main/java/mineverse/Aust1n46/chat/bungee/VentureChatProxySource.java +++ b/src/main/java/mineverse/Aust1n46/chat/bungee/VentureChatProxySource.java @@ -8,4 +8,8 @@ public interface VentureChatProxySource { public List getServers(); public VentureChatProxyServer getServer(String serverName); + + public void sendConsoleMessage(String message); + + public boolean isOfflineServerAcknowledgementSet(); } diff --git a/src/main/java/mineverse/Aust1n46/chat/bungee/VentureChatVelocity.java b/src/main/java/mineverse/Aust1n46/chat/bungee/VentureChatVelocity.java index 9982f6d..8174ab1 100644 --- a/src/main/java/mineverse/Aust1n46/chat/bungee/VentureChatVelocity.java +++ b/src/main/java/mineverse/Aust1n46/chat/bungee/VentureChatVelocity.java @@ -2,6 +2,10 @@ package mineverse.Aust1n46.chat.bungee; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -15,7 +19,9 @@ import com.velocitypowered.api.event.connection.PluginMessageEvent; import com.velocitypowered.api.event.connection.PluginMessageEvent.ForwardResult; import com.velocitypowered.api.event.player.ServerPostConnectEvent; import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; +import com.velocitypowered.api.event.proxy.ProxyShutdownEvent; import com.velocitypowered.api.plugin.Plugin; +import com.velocitypowered.api.plugin.annotation.DataDirectory; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.proxy.ServerConnection; @@ -23,20 +29,62 @@ import com.velocitypowered.api.proxy.messages.ChannelIdentifier; import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; import com.velocitypowered.api.proxy.server.RegisteredServer; +import mineverse.Aust1n46.chat.database.ProxyPlayerData; +import mineverse.Aust1n46.chat.utilities.Format; +import net.md_5.bungee.config.Configuration; +import net.md_5.bungee.config.ConfigurationProvider; +import net.md_5.bungee.config.YamlConfiguration; + @Plugin(id = "venturechat", name = "VentureChat", version = "3.1.0", description = "#1 Channels Chat plugin! Spigot + Bungee. Supports PlaceholderAPI + JSON formatting. Moderation GUI!", authors = {"Aust1n46"}) 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 Logger logger; + + @Inject + @DataDirectory + private Path dataPath; + private File velocityPlayerDataDirectory; + + private static Configuration velocityConfig; + @Inject public VentureChatVelocity(ProxyServer server, Logger logger) { this.proxyServer = server; + this.logger = logger; + } + + public static Configuration getVelocityConfig() { + return velocityConfig; } @Subscribe public void onInitialize(ProxyInitializeEvent event) { proxyServer.getChannelRegistrar().register(channelIdentifier); + + File dataFolder = dataPath.toFile(); + if(!dataFolder.exists()) { + dataFolder.mkdir(); + } + File config = new File(dataFolder, "velocityconfig.yml"); + try { + if(!config.exists()) { + Files.copy(getClass().getClassLoader().getResourceAsStream("velocityconfig.yml"), config.toPath()); + } + velocityConfig = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(dataFolder, "velocityconfig.yml")); + } + catch(Exception e) { + e.printStackTrace(); + } + + velocityPlayerDataDirectory = new File(dataPath.toAbsolutePath().toString() + "/PlayerData"); + ProxyPlayerData.loadProxyPlayerData(velocityPlayerDataDirectory, this); + } + + @Subscribe + public void onShutdown(ProxyShutdownEvent event) { + ProxyPlayerData.saveProxyPlayerData(velocityPlayerDataDirectory, this); } @Subscribe @@ -64,7 +112,10 @@ public class VentureChatVelocity implements VentureChatProxySource { } }); } - catch(Exception e) { + catch(IllegalStateException e) { + sendConsoleMessage("Velocity being finicky"); + } + catch (IOException e) { e.printStackTrace(); } } @@ -101,4 +152,14 @@ public class VentureChatVelocity implements VentureChatProxySource { RegisteredServer server = proxyServer.getServer(serverName).get(); return new VentureChatProxyServer(serverName, server.getPlayersConnected().isEmpty()); } + + @Override + public void sendConsoleMessage(String message) { + logger.info(Format.stripColor(message)); + } + + @Override + public boolean isOfflineServerAcknowledgementSet() { + return velocityConfig.getBoolean("offline_server_acknowledgement"); + } } diff --git a/src/main/java/mineverse/Aust1n46/chat/database/BungeePlayerData.java b/src/main/java/mineverse/Aust1n46/chat/database/ProxyPlayerData.java similarity index 55% rename from src/main/java/mineverse/Aust1n46/chat/database/BungeePlayerData.java rename to src/main/java/mineverse/Aust1n46/chat/database/ProxyPlayerData.java index 4233586..8b38c9d 100644 --- a/src/main/java/mineverse/Aust1n46/chat/database/BungeePlayerData.java +++ b/src/main/java/mineverse/Aust1n46/chat/database/ProxyPlayerData.java @@ -13,38 +13,32 @@ import java.util.UUID; import mineverse.Aust1n46.chat.api.MineverseChatAPI; import mineverse.Aust1n46.chat.api.SynchronizedMineverseChatPlayer; -import mineverse.Aust1n46.chat.bungee.MineverseChatBungee; +import mineverse.Aust1n46.chat.bungee.VentureChatProxySource; import mineverse.Aust1n46.chat.command.mute.MuteContainer; -import mineverse.Aust1n46.chat.utilities.Format; import mineverse.Aust1n46.chat.utilities.UUIDFetcher; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.config.Configuration; import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.YamlConfiguration; /** - * Class for reading and writing bungee player data. + * Class for reading and writing proxy player data. * * @author Aust1n46 */ -public class BungeePlayerData { - private static MineverseChatBungee bungee = MineverseChatBungee.getInstance(); - private static final String BUNGEE_PLAYER_DATA_DIRECTORY_PATH = bungee.getDataFolder().getAbsolutePath() + "/PlayerData"; - - public static void loadLegacyBungeePlayerData() { - File sync = new File(bungee.getDataFolder(), "BungeePlayers.yml"); +public class ProxyPlayerData { + public static void loadLegacyBungeePlayerData(File dataFolder, VentureChatProxySource source) { + File sync = new File(dataFolder, "BungeePlayers.yml"); if (!sync.exists()) { return; } try { - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - Detected Legacy Player Data!"))); - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - Converting to new structure and deleting old BungeePlayers.yml file!"))); + source.sendConsoleMessage("&8[&eVentureChat&8]&c - Detected Legacy Player Data!"); + source.sendConsoleMessage("&8[&eVentureChat&8]&c - Converting to new structure and deleting old BungeePlayers.yml file!"); Configuration playerData = ConfigurationProvider.getProvider(YamlConfiguration.class).load(sync); for (String uuidString : playerData.getKeys()) { UUID uuid = UUID.fromString(uuidString); - if (UUIDFetcher.shouldSkipOfflineUUIDBungee(uuid)) { - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - Skipping Offline UUID: " + uuid))); + if (UUIDFetcher.shouldSkipOfflineUUIDProxy(uuid, source)) { + source.sendConsoleMessage("&8[&eVentureChat&8]&c - Skipping Offline UUID: " + uuid); continue; } Set listening = new HashSet(); @@ -72,68 +66,68 @@ public class BungeePlayerData { } } catch (Exception e) { MineverseChatAPI.clearBungeePlayerMap(); - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - Error Loading Legacy Player Data!"))); - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - Deleted BungeePlayers.yml file!"))); + source.sendConsoleMessage("&8[&eVentureChat&8]&c - Error Loading Legacy Player Data!"); + source.sendConsoleMessage("&8[&eVentureChat&8]&c - Deleted BungeePlayers.yml file!"); } finally { sync.delete(); } } - public static void loadBungeePlayerData() { + public static void loadProxyPlayerData(File dataFolder, VentureChatProxySource source) { try { - File playerDataDirectory = new File(BUNGEE_PLAYER_DATA_DIRECTORY_PATH); + File playerDataDirectory = dataFolder; if (!playerDataDirectory.exists()) { playerDataDirectory.mkdirs(); } - Files.walk(Paths.get(BUNGEE_PLAYER_DATA_DIRECTORY_PATH)) + Files.walk(Paths.get(dataFolder.getAbsolutePath())) .filter(Files::isRegularFile) - .forEach((path) -> readBungeePlayerDataFile(path)); + .forEach((path) -> readProxyPlayerDataFile(path, source)); } catch (IOException e) { e.printStackTrace(); } } - private static void readBungeePlayerDataFile(Path path) { + private static void readProxyPlayerDataFile(Path path, VentureChatProxySource source) { SynchronizedMineverseChatPlayer smcp; - File bungeePlayerDataFile = path.toFile(); - if (!bungeePlayerDataFile.exists()) { + File proxyPlayerDataFile = path.toFile(); + if (!proxyPlayerDataFile.exists()) { return; } try { - Configuration bungeePlayerDataFileConfiguration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(bungeePlayerDataFile); - String uuidString = bungeePlayerDataFile.getName().replace(".yml", ""); + Configuration proxyPlayerDataFileConfiguration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(proxyPlayerDataFile); + String uuidString = proxyPlayerDataFile.getName().replace(".yml", ""); UUID uuid = UUID.fromString(uuidString); - if (UUIDFetcher.shouldSkipOfflineUUIDBungee(uuid)) { - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - Skipping Offline UUID: " + uuid))); - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - File will be skipped and deleted."))); - bungeePlayerDataFile.delete(); + if (UUIDFetcher.shouldSkipOfflineUUIDProxy(uuid, source)) { + source.sendConsoleMessage("&8[&eVentureChat&8]&c - Skipping Offline UUID: " + uuid); + source.sendConsoleMessage("&8[&eVentureChat&8]&c - File will be skipped and deleted."); + proxyPlayerDataFile.delete(); return; } Set listening = new HashSet(); - StringTokenizer l = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("channels"), ","); + StringTokenizer l = new StringTokenizer(proxyPlayerDataFileConfiguration.getString("channels"), ","); while (l.hasMoreTokens()) { String channel = l.nextToken(); listening.add(channel); } HashMap mutes = new HashMap(); - Configuration muteSection = bungeePlayerDataFileConfiguration.getSection("mutes"); + Configuration muteSection = proxyPlayerDataFileConfiguration.getSection("mutes"); for (String channelName : muteSection.getKeys()) { Configuration channelSection = muteSection.getSection(channelName); mutes.put(channelName, new MuteContainer(channelName, channelSection.getLong("time"), channelSection.getString("reason"))); } HashSet ignores = new HashSet(); - StringTokenizer n = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("ignores"), ","); + StringTokenizer n = new StringTokenizer(proxyPlayerDataFileConfiguration.getString("ignores"), ","); while (n.hasMoreTokens()) { String ignore = n.nextToken(); ignores.add(UUID.fromString(ignore)); } - boolean spy = bungeePlayerDataFileConfiguration.getBoolean("spy"); - boolean messageToggle = bungeePlayerDataFileConfiguration.getBoolean("messagetoggle"); + boolean spy = proxyPlayerDataFileConfiguration.getBoolean("spy"); + boolean messageToggle = proxyPlayerDataFileConfiguration.getBoolean("messagetoggle"); smcp = new SynchronizedMineverseChatPlayer(uuid, listening, mutes, ignores, spy, messageToggle); } catch (Exception e) { - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - Error Loading Data File: " + bungeePlayerDataFile.getName()))); - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - File will be skipped and deleted."))); - bungeePlayerDataFile.delete(); + source.sendConsoleMessage("&8[&eVentureChat&8]&c - Error Loading Data File: " + proxyPlayerDataFile.getName()); + source.sendConsoleMessage("&8[&eVentureChat&8]&c - File will be skipped and deleted."); + proxyPlayerDataFile.delete(); return; } if (smcp != null) { @@ -141,17 +135,17 @@ public class BungeePlayerData { } } - public static void saveBungeePlayerData() { + public static void saveProxyPlayerData(File dataFolder, VentureChatProxySource source) { try { for (SynchronizedMineverseChatPlayer p : MineverseChatAPI.getSynchronizedMineverseChatPlayers()) { - if (UUIDFetcher.shouldSkipOfflineUUIDBungee(p.getUUID())) { + if (UUIDFetcher.shouldSkipOfflineUUIDProxy(p.getUUID(), source)) { return; } - File bungeePlayerDataFile = new File(BUNGEE_PLAYER_DATA_DIRECTORY_PATH, p.getUUID() + ".yml"); - if (!bungeePlayerDataFile.exists()) { - bungeePlayerDataFile.createNewFile(); + File proxyPlayerDataFile = new File(dataFolder.getAbsolutePath(), p.getUUID() + ".yml"); + if (!proxyPlayerDataFile.exists()) { + proxyPlayerDataFile.createNewFile(); } - Configuration bungeePlayerDataFileConfiguration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(bungeePlayerDataFile); + Configuration proxyPlayerDataFileConfiguration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(proxyPlayerDataFile); String listen = ""; for (String s : p.getListening()) @@ -163,18 +157,18 @@ public class BungeePlayerData { listen = listen.substring(0, listen.length() - 1); if (ignore.length() > 0) ignore = ignore.substring(0, ignore.length() - 1); - bungeePlayerDataFileConfiguration.set("channels", listen); - Configuration muteSection = createSection(bungeePlayerDataFileConfiguration, "mutes"); + proxyPlayerDataFileConfiguration.set("channels", listen); + Configuration muteSection = createSection(proxyPlayerDataFileConfiguration, "mutes"); for (MuteContainer mute : p.getMutes()) { Configuration channelSection = createSection(muteSection, mute.getChannel()); channelSection.set("time", mute.getDuration()); channelSection.set("reason", mute.getReason()); } - bungeePlayerDataFileConfiguration.set("ignores", ignore); - bungeePlayerDataFileConfiguration.set("spy", p.isSpy()); - bungeePlayerDataFileConfiguration.set("messagetoggle", p.getMessageToggle()); - - ConfigurationProvider.getProvider(YamlConfiguration.class).save(bungeePlayerDataFileConfiguration, bungeePlayerDataFile); + proxyPlayerDataFileConfiguration.set("ignores", ignore); + proxyPlayerDataFileConfiguration.set("spy", p.isSpy()); + proxyPlayerDataFileConfiguration.set("messagetoggle", p.getMessageToggle()); + + ConfigurationProvider.getProvider(YamlConfiguration.class).save(proxyPlayerDataFileConfiguration, proxyPlayerDataFile); } } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/mineverse/Aust1n46/chat/listeners/ChatListener.java b/src/main/java/mineverse/Aust1n46/chat/listeners/ChatListener.java index b7d647b..df0d9ed 100644 --- a/src/main/java/mineverse/Aust1n46/chat/listeners/ChatListener.java +++ b/src/main/java/mineverse/Aust1n46/chat/listeners/ChatListener.java @@ -486,7 +486,7 @@ public class ChatListener implements Listener { String globalJSON = Format.convertToJson(mcp, format, chat); format = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), Format.FormatStringAll(format))); - String message = (format + chat).replaceAll("(\u00A7([a-z0-9]))", ""); // UTF-8 encoding issues. + String message = Format.stripColor(format + chat); // UTF-8 encoding issues. int hash = message.hashCode(); //Create VentureChatEvent diff --git a/src/main/java/mineverse/Aust1n46/chat/utilities/Format.java b/src/main/java/mineverse/Aust1n46/chat/utilities/Format.java index 3c976fa..03703ab 100644 --- a/src/main/java/mineverse/Aust1n46/chat/utilities/Format.java +++ b/src/main/java/mineverse/Aust1n46/chat/utilities/Format.java @@ -878,4 +878,8 @@ public class Format { return Sound.valueOf(DEFAULT_MESSAGE_SOUND); } } + + public static String stripColor(String message) { + return message.replaceAll("(\u00A7([a-z0-9]))", ""); + } } diff --git a/src/main/java/mineverse/Aust1n46/chat/utilities/UUIDFetcher.java b/src/main/java/mineverse/Aust1n46/chat/utilities/UUIDFetcher.java index 76abb3b..c240330 100644 --- a/src/main/java/mineverse/Aust1n46/chat/utilities/UUIDFetcher.java +++ b/src/main/java/mineverse/Aust1n46/chat/utilities/UUIDFetcher.java @@ -20,12 +20,9 @@ import org.json.simple.parser.JSONParser; import com.google.common.collect.ImmutableList; import mineverse.Aust1n46.chat.MineverseChat; -import mineverse.Aust1n46.chat.bungee.MineverseChatBungee; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.chat.TextComponent; +import mineverse.Aust1n46.chat.bungee.VentureChatProxySource; -//This class is used to query the Mojang servers to verify UUID's. -public class UUIDFetcher implements Callable> { //unimplemented +public class UUIDFetcher implements Callable> { private static final double PROFILES_PER_REQUEST = 100; private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft"; private final JSONParser jsonParser = new JSONParser(); @@ -120,8 +117,8 @@ public class UUIDFetcher implements Callable> { //unimplemente return (uuidIsOffline(uuid) && !MineverseChat.getInstance().getConfig().getBoolean("offline_server_acknowledgement", false)); } - public static boolean shouldSkipOfflineUUIDBungee(UUID uuid) { - return (uuidIsOffline(uuid) && !MineverseChatBungee.getBungeeConfig().getBoolean("offline_server_acknowledgement", false)); + public static boolean shouldSkipOfflineUUIDProxy(UUID uuid, VentureChatProxySource source) { + return (uuidIsOffline(uuid) && !source.isOfflineServerAcknowledgementSet()); } public static void checkOfflineUUIDWarning(UUID uuid) { @@ -137,15 +134,15 @@ public class UUIDFetcher implements Callable> { //unimplemente } } - public static void checkOfflineUUIDWarningBungee(UUID uuid) { - if(shouldSkipOfflineUUIDBungee(uuid)) { - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - Detected Offline UUID!"))); - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - If you are using BungeeCord, make sure you have properly setup IP Forwarding."))); - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - https://www.spigotmc.org/wiki/bungeecord-ip-forwarding/"))); - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - You can access this wiki page from the log file or just Google it."))); - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - If you're running a \"cracked\" server, player data might not be stored properly, and thus, you are on your own."))); - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - If you run your server in offline mode, you will probably lose your player data when switching to online mode!"))); - ProxyServer.getInstance().getConsole().sendMessage(TextComponent.fromLegacyText(Format.FormatStringAll("&8[&eVentureChat&8]&c - No player data will be saved in offline mode unless you set the \"cracked\" server acknowledgement in the config!"))); + public static void checkOfflineUUIDWarningProxy(UUID uuid, VentureChatProxySource source) { + if(shouldSkipOfflineUUIDProxy(uuid, source)) { + source.sendConsoleMessage("&8[&eVentureChat&8]&c - Detected Offline UUID!"); + source.sendConsoleMessage("&8[&eVentureChat&8]&c - If you are using BungeeCord, make sure you have properly setup IP Forwarding."); + source.sendConsoleMessage("&8[&eVentureChat&8]&c - https://www.spigotmc.org/wiki/bungeecord-ip-forwarding/"); + source.sendConsoleMessage("&8[&eVentureChat&8]&c - You can access this wiki page from the log file or just Google it."); + source.sendConsoleMessage("&8[&eVentureChat&8]&c - If you're running a \"cracked\" server, player data might not be stored properly, and thus, you are on your own."); + source.sendConsoleMessage("&8[&eVentureChat&8]&c - If you run your server in offline mode, you will probably lose your player data when switching to online mode!"); + source.sendConsoleMessage("&8[&eVentureChat&8]&c - No player data will be saved in offline mode unless you set the \"cracked\" server acknowledgement in the config!"); return; } } diff --git a/src/main/resources/velocityconfig.yml b/src/main/resources/velocityconfig.yml new file mode 100644 index 0000000..ecb7295 --- /dev/null +++ b/src/main/resources/velocityconfig.yml @@ -0,0 +1,11 @@ +#=============================================================== +# MineverseChat Velocity Config = +# Author: Aust1n46 = +#=============================================================== + +# If you're running a "cracked" server, player data might not be stored properly, and thus, you are on your own. +# If you run your server in offline mode, you might have to reset your player data when switching to online mode! +# If you see this warning by accident and you are using Velocity, make sure you have properly setup IP Forwarding. +# https://www.spigotmc.org/wiki/bungeecord-ip-forwarding/ +# No player data will be saved in offline mode unless you set this acknowledgement to 'true' +offline_server_acknowledgement: false \ No newline at end of file