Separate proxy architecture.

This commit is contained in:
Aust1n46 2022-01-15 03:13:12 -06:00
parent 4e9d70adfb
commit d7a55622be
18 changed files with 275 additions and 219 deletions

View File

@ -1,2 +0,0 @@
/org.eclipse.core.resources.prefs
/org.eclipse.m2e.core.prefs

View File

@ -1,8 +1,5 @@
eclipse.preferences.version=1 #Sat Jan 15 01:48:59 CST 2022
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.source=1.8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.compliance=1.8

View File

@ -260,5 +260,11 @@
<version>4.2.0</version> <version>4.2.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,18 @@
package venture.Aust1n46.chat;
import com.google.inject.AbstractModule;
import venture.Aust1n46.chat.proxy.VentureChatBungee;
public class VentureChatBungeePluginModule extends AbstractModule {
private final VentureChatBungee plugin;
public VentureChatBungeePluginModule(final VentureChatBungee plugin) {
this.plugin = plugin;
}
@Override
protected void configure() {
this.bind(VentureChatBungee.class).toInstance(plugin);
}
}

View File

@ -19,8 +19,8 @@ import net.md_5.bungee.config.YamlConfiguration;
import venture.Aust1n46.chat.controllers.commands.MuteContainer; import venture.Aust1n46.chat.controllers.commands.MuteContainer;
import venture.Aust1n46.chat.model.SynchronizedVentureChatPlayer; import venture.Aust1n46.chat.model.SynchronizedVentureChatPlayer;
import venture.Aust1n46.chat.proxy.VentureChatProxySource; import venture.Aust1n46.chat.proxy.VentureChatProxySource;
import venture.Aust1n46.chat.service.UUIDService; import venture.Aust1n46.chat.service.proxy.ProxyUuidService;
import venture.Aust1n46.chat.service.VentureChatPlayerApiService; import venture.Aust1n46.chat.service.proxy.VentureChatProxyPlayerApiService;
/** /**
* Class for reading and writing proxy player data. * Class for reading and writing proxy player data.
@ -29,9 +29,9 @@ import venture.Aust1n46.chat.service.VentureChatPlayerApiService;
*/ */
public class VentureChatProxyFlatFileController { public class VentureChatProxyFlatFileController {
@Inject @Inject
private UUIDService uuidService; private ProxyUuidService uuidService;
@Inject @Inject
private VentureChatPlayerApiService playerApiService; private VentureChatProxyPlayerApiService playerApiService;
public void loadLegacyBungeePlayerData(File dataFolder, VentureChatProxySource source) { public void loadLegacyBungeePlayerData(File dataFolder, VentureChatProxySource source) {
File sync = new File(dataFolder, "BungeePlayers.yml"); File sync = new File(dataFolder, "BungeePlayers.yml");

View File

@ -17,6 +17,7 @@ public class Me implements VentureCommand {
@Inject @Inject
private VentureChatPlayerApiService playerApiService; private VentureChatPlayerApiService playerApiService;
@SuppressWarnings("deprecation")
@Override @Override
public void execute(CommandSender sender, String command, String[] args) { public void execute(CommandSender sender, String command, String[] args) {
if (sender.hasPermission("venturechat.me")) { if (sender.hasPermission("venturechat.me")) {

View File

@ -37,6 +37,7 @@ import venture.Aust1n46.chat.service.VentureChatPlayerApiService;
import venture.Aust1n46.chat.utilities.FormatUtils; import venture.Aust1n46.chat.utilities.FormatUtils;
//This class listens to chat through the chat event and handles the bulk of the chat channels and formatting. //This class listens to chat through the chat event and handles the bulk of the chat channels and formatting.
@SuppressWarnings("deprecation")
@Singleton @Singleton
public class ChatListener implements Listener { public class ChatListener implements Listener {
private final boolean essentialsDiscordHook = Bukkit.getPluginManager().isPluginEnabled("EssentialsDiscord"); private final boolean essentialsDiscordHook = Bukkit.getPluginManager().isPluginEnabled("EssentialsDiscord");
@ -54,7 +55,6 @@ public class ChatListener implements Listener {
private ConfigService configService; private ConfigService configService;
// this event isn't always asynchronous even though the event's name starts with "Async" // this event isn't always asynchronous even though the event's name starts with "Async"
// blame md_5 for that one
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event) { public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event) {
event.setCancelled(true); event.setCancelled(true);
@ -564,7 +564,6 @@ public class ChatListener implements Listener {
System.out.println(out.size() + " bytes size with json"); System.out.println(out.size() + " bytes size with json");
} }
out.writeUTF(plugin.getVaultPermission().getPrimaryGroup(mcp.getPlayer())); // look into not sending this out.writeUTF(plugin.getVaultPermission().getPrimaryGroup(mcp.getPlayer())); // look into not sending this
@SuppressWarnings("deprecation") // Paper Deprecated
final String displayName = mcp.getPlayer().getDisplayName(); final String displayName = mcp.getPlayer().getDisplayName();
out.writeUTF(displayName); out.writeUTF(displayName);
pluginMessageController.sendPluginMessage(byteOutStream); pluginMessageController.sendPluginMessage(byteOutStream);

View File

@ -246,11 +246,14 @@ public class CommandListener implements CommandExecutor, Listener {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void InventoryClick(InventoryClickEvent e) { public void InventoryClick(InventoryClickEvent e) {
ItemStack item = e.getCurrentItem(); if(!e.getView().getTitle().contains("VentureChat")) {
if(item == null || !e.getView().getTitle().contains("VentureChat")) {
return; return;
} }
e.setCancelled(true); e.setCancelled(true);
ItemStack item = e.getCurrentItem();
if (item == null) {
return;
}
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer((Player) e.getWhoClicked()); VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer((Player) e.getWhoClicked());
String playerName = e.getView().getTitle().replace(" GUI", "").replace("VentureChat: ", ""); String playerName = e.getView().getTitle().replace(" GUI", "").replace("VentureChat: ", "");
VentureChatPlayer target = playerApiService.getMineverseChatPlayer(playerName); VentureChatPlayer target = playerApiService.getMineverseChatPlayer(playerName);

View File

@ -18,6 +18,7 @@ public class SignListener implements Listener {
@Inject @Inject
private VentureChatPlayerApiService playerApiService; private VentureChatPlayerApiService playerApiService;
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onSignChange(SignChangeEvent event) { public void onSignChange(SignChangeEvent event) {
VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer(event.getPlayer()); VentureChatPlayer mcp = playerApiService.getOnlineMineverseChatPlayer(event.getPlayer());

View File

@ -7,7 +7,9 @@ import java.nio.file.Files;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.google.inject.Guice;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Injector;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
@ -24,8 +26,9 @@ import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration; import net.md_5.bungee.config.YamlConfiguration;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
import venture.Aust1n46.chat.VentureChatBungeePluginModule;
import venture.Aust1n46.chat.controllers.VentureChatProxyFlatFileController; import venture.Aust1n46.chat.controllers.VentureChatProxyFlatFileController;
import venture.Aust1n46.chat.service.UUIDService; import venture.Aust1n46.chat.service.proxy.ProxyUuidService;
import venture.Aust1n46.chat.utilities.FormatUtils; import venture.Aust1n46.chat.utilities.FormatUtils;
/** /**
@ -38,7 +41,7 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr
private File bungeePlayerDataDirectory; private File bungeePlayerDataDirectory;
@Inject @Inject
private UUIDService uuidService; private ProxyUuidService uuidService;
@Inject @Inject
private VentureChatProxyFlatFileController proxyFlatFileController; private VentureChatProxyFlatFileController proxyFlatFileController;
@Inject @Inject
@ -46,6 +49,10 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr
@Override @Override
public void onEnable() { public void onEnable() {
final VentureChatBungeePluginModule pluginModule = new VentureChatBungeePluginModule(this);
final Injector injector = Guice.createInjector(pluginModule);
injector.injectMembers(this);
if (!getDataFolder().exists()) { if (!getDataFolder().exists()) {
getDataFolder().mkdir(); getDataFolder().mkdir();
} }
@ -55,8 +62,7 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr
Files.copy(getResourceAsStream("bungeeconfig.yml"), config.toPath()); Files.copy(getResourceAsStream("bungeeconfig.yml"), config.toPath());
} }
bungeeConfig = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "bungeeconfig.yml")); bungeeConfig = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "bungeeconfig.yml"));
} } catch (Exception e) {
catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -103,8 +109,7 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr
getProxy().getServers().get(send).sendData(VentureChatProxy.PLUGIN_MESSAGING_CHANNEL_STRING, outstream.toByteArray()); getProxy().getServers().get(send).sendData(VentureChatProxy.PLUGIN_MESSAGING_CHANNEL_STRING, outstream.toByteArray());
} }
} }
} } catch (Exception e) {
catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -128,7 +133,8 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr
@Override @Override
public List<VentureChatProxyServer> getServers() { public List<VentureChatProxyServer> getServers() {
return getProxy().getServers().values().stream().map(bungeeServer -> new VentureChatProxyServer(bungeeServer.getName(), bungeeServer.getPlayers().isEmpty())).collect(Collectors.toList()); return getProxy().getServers().values().stream().map(bungeeServer -> new VentureChatProxyServer(bungeeServer.getName(), bungeeServer.getPlayers().isEmpty()))
.collect(Collectors.toList());
} }
@Override @Override

View File

@ -12,7 +12,7 @@ import com.google.inject.Inject;
import venture.Aust1n46.chat.controllers.commands.MuteContainer; import venture.Aust1n46.chat.controllers.commands.MuteContainer;
import venture.Aust1n46.chat.model.SynchronizedVentureChatPlayer; import venture.Aust1n46.chat.model.SynchronizedVentureChatPlayer;
import venture.Aust1n46.chat.model.TemporaryDataInstance; import venture.Aust1n46.chat.model.TemporaryDataInstance;
import venture.Aust1n46.chat.service.VentureChatPlayerApiService; import venture.Aust1n46.chat.service.proxy.VentureChatProxyPlayerApiService;
public class VentureChatProxy { public class VentureChatProxy {
public static String PLUGIN_MESSAGING_CHANNEL_NAMESPACE = "venturechat"; public static String PLUGIN_MESSAGING_CHANNEL_NAMESPACE = "venturechat";
@ -20,7 +20,7 @@ public class VentureChatProxy {
public static String PLUGIN_MESSAGING_CHANNEL_STRING = "venturechat:data"; public static String PLUGIN_MESSAGING_CHANNEL_STRING = "venturechat:data";
@Inject @Inject
private VentureChatPlayerApiService playerApiService; private VentureChatProxyPlayerApiService playerApiService;
public void onPluginMessage(byte[] data, String serverName, VentureChatProxySource source) { public void onPluginMessage(byte[] data, String serverName, VentureChatProxySource source) {
ByteArrayInputStream instream = new ByteArrayInputStream(data); ByteArrayInputStream instream = new ByteArrayInputStream(data);

View File

@ -8,7 +8,6 @@ import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import venture.Aust1n46.chat.initiators.application.VentureChat; import venture.Aust1n46.chat.initiators.application.VentureChat;
import venture.Aust1n46.chat.proxy.VentureChatProxySource;
import venture.Aust1n46.chat.utilities.FormatUtils; import venture.Aust1n46.chat.utilities.FormatUtils;
@Singleton @Singleton
@ -16,46 +15,23 @@ public class UUIDService {
@Inject @Inject
private VentureChat plugin; private VentureChat plugin;
/**
* Returns whether the passed UUID is a v3 UUID. Offline UUIDs are v3, online are v4.
*
* @param uuid the UUID to check
* @return whether the UUID is a v3 UUID & thus is offline
*/
public boolean uuidIsOffline(UUID uuid) {
return uuid.version() == 3;
}
public boolean shouldSkipOfflineUUID(UUID uuid) { public boolean shouldSkipOfflineUUID(UUID uuid) {
return (uuidIsOffline(uuid) && !plugin.getConfig().getBoolean("offline_server_acknowledgement", false)); return (FormatUtils.uuidIsOffline(uuid) && !plugin.getConfig().getBoolean("offline_server_acknowledgement", false));
}
public boolean shouldSkipOfflineUUIDProxy(UUID uuid, VentureChatProxySource source) {
return (uuidIsOffline(uuid) && !source.isOfflineServerAcknowledgementSet());
} }
public void checkOfflineUUIDWarning(UUID uuid) { public void checkOfflineUUIDWarning(UUID uuid) {
if (shouldSkipOfflineUUID(uuid)) { if (shouldSkipOfflineUUID(uuid)) {
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Detected Offline UUID!")); Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - Detected Offline UUID!"));
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - If you are using BungeeCord, make sure you have properly setup IP Forwarding.")); Bukkit.getConsoleSender()
.sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - If you are using BungeeCord, make sure you have properly setup IP Forwarding."));
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - https://www.spigotmc.org/wiki/bungeecord-ip-forwarding/")); Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - https://www.spigotmc.org/wiki/bungeecord-ip-forwarding/"));
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - You can access this wiki page from the log file or just Google it.")); Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - You can access this wiki page from the log file or just Google it."));
Bukkit.getConsoleSender().sendMessage(FormatUtils.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.")); Bukkit.getConsoleSender().sendMessage(FormatUtils
Bukkit.getConsoleSender().sendMessage(FormatUtils.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!")); .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."));
Bukkit.getConsoleSender().sendMessage(FormatUtils.FormatStringAll("&8[&eVentureChat&8]&c - No player data will be saved in offline mode unless you set the \"cracked\" server acknowledgement in the config!")); Bukkit.getConsoleSender().sendMessage(FormatUtils
return; .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!"));
} Bukkit.getConsoleSender().sendMessage(FormatUtils
} .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 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; return;
} }
} }

View File

@ -8,7 +8,8 @@ import java.util.UUID;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import venture.Aust1n46.chat.model.SynchronizedVentureChatPlayer; import com.google.inject.Singleton;
import venture.Aust1n46.chat.model.VentureChatPlayer; import venture.Aust1n46.chat.model.VentureChatPlayer;
/** /**
@ -17,13 +18,12 @@ import venture.Aust1n46.chat.model.VentureChatPlayer;
* *
* @author Aust1n46 * @author Aust1n46
*/ */
@Singleton
public class VentureChatPlayerApiService { public class VentureChatPlayerApiService {
private static HashMap<UUID, VentureChatPlayer> playerMap = new HashMap<UUID, VentureChatPlayer>(); private final HashMap<UUID, VentureChatPlayer> playerMap = new HashMap<>();
private static HashMap<String, UUID> namesMap = new HashMap<String, UUID>(); private final HashMap<String, UUID> namesMap = new HashMap<>();
private static HashMap<UUID, VentureChatPlayer> onlinePlayerMap = new HashMap<UUID, VentureChatPlayer>(); private final HashMap<UUID, VentureChatPlayer> onlinePlayerMap = new HashMap<>();
private final List<String> networkPlayerNames = new ArrayList<>();
private static List<String> networkPlayerNames = new ArrayList<String>();
private static HashMap<UUID, SynchronizedVentureChatPlayer> proxyPlayerMap = new HashMap<UUID, SynchronizedVentureChatPlayer>();
public void addNameToMap(VentureChatPlayer mcp) { public void addNameToMap(VentureChatPlayer mcp) {
namesMap.put(mcp.getName(), mcp.getUuid()); namesMap.put(mcp.getName(), mcp.getUuid());
@ -128,10 +128,6 @@ public class VentureChatPlayerApiService {
return getOnlineMineverseChatPlayer(namesMap.get(name)); return getOnlineMineverseChatPlayer(namesMap.get(name));
} }
public List<String> getNetworkPlayerNames() { public List<String> getNetworkPlayerNames() {
return networkPlayerNames; return networkPlayerNames;
} }
@ -143,26 +139,4 @@ public class VentureChatPlayerApiService {
public void addNetworkPlayerName(String name) { public void addNetworkPlayerName(String name) {
networkPlayerNames.add(name); networkPlayerNames.add(name);
} }
public void addSynchronizedMineverseChatPlayerToMap(SynchronizedVentureChatPlayer smcp) {
proxyPlayerMap.put(smcp.getUUID(), smcp);
}
public void clearProxyPlayerMap() {
proxyPlayerMap.clear();
}
public Collection<SynchronizedVentureChatPlayer> getSynchronizedMineverseChatPlayers() {
return proxyPlayerMap.values();
}
/**
* Get a SynchronizedMineverseChatPlayer from a UUID.
*
* @param uuid {@link UUID}
* @return {@link SynchronizedVentureChatPlayer}
*/
public SynchronizedVentureChatPlayer getSynchronizedMineverseChatPlayer(UUID uuid) {
return proxyPlayerMap.get(uuid);
}
} }

View File

@ -0,0 +1,29 @@
package venture.Aust1n46.chat.service.proxy;
import java.util.UUID;
import com.google.inject.Singleton;
import venture.Aust1n46.chat.proxy.VentureChatProxySource;
import venture.Aust1n46.chat.utilities.FormatUtils;
@Singleton
public class ProxyUuidService {
public boolean shouldSkipOfflineUUIDProxy(UUID uuid, VentureChatProxySource source) {
return (FormatUtils.uuidIsOffline(uuid) && !source.isOfflineServerAcknowledgementSet());
}
public 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;
}
}
}

View File

@ -0,0 +1,36 @@
package venture.Aust1n46.chat.service.proxy;
import java.util.Collection;
import java.util.HashMap;
import java.util.UUID;
import com.google.inject.Singleton;
import venture.Aust1n46.chat.model.SynchronizedVentureChatPlayer;
@Singleton
public class VentureChatProxyPlayerApiService {
private final HashMap<UUID, SynchronizedVentureChatPlayer> proxyPlayerMap = new HashMap<>();
public void addSynchronizedMineverseChatPlayerToMap(SynchronizedVentureChatPlayer smcp) {
proxyPlayerMap.put(smcp.getUUID(), smcp);
}
public void clearProxyPlayerMap() {
proxyPlayerMap.clear();
}
public Collection<SynchronizedVentureChatPlayer> getSynchronizedMineverseChatPlayers() {
return proxyPlayerMap.values();
}
/**
* Get a SynchronizedMineverseChatPlayer from a UUID.
*
* @param uuid {@link UUID}
* @return {@link SynchronizedVentureChatPlayer}
*/
public SynchronizedVentureChatPlayer getSynchronizedMineverseChatPlayer(UUID uuid) {
return proxyPlayerMap.get(uuid);
}
}

View File

@ -1,5 +1,6 @@
package venture.Aust1n46.chat.utilities; package venture.Aust1n46.chat.utilities;
import java.util.UUID;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -300,4 +301,15 @@ public class FormatUtils {
public static String stripColor(String message) { public static String stripColor(String message) {
return message.replaceAll("(\u00A7([a-z0-9]))", ""); return message.replaceAll("(\u00A7([a-z0-9]))", "");
} }
/**
* Returns whether the passed UUID is a v3 UUID. Offline UUIDs are v3, online
* are v4.
*
* @param uuid the UUID to check
* @return whether the UUID is a v3 UUID & thus is offline
*/
public static boolean uuidIsOffline(UUID uuid) {
return uuid.version() == 3;
}
} }

View File

@ -1,4 +1,4 @@
name: VentureChat name: VentureChat
main: mineverse.Aust1n46.chat.proxy.VentureChatBungee main: venture.Aust1n46.chat.proxy.VentureChatBungee
version: ${project.version} version: ${project.version}
author: Aust1n46 author: Aust1n46

View File

@ -1,7 +1,7 @@
name: VentureChat name: VentureChat
version: ${project.version} version: ${project.version}
api-version: 1.13 api-version: 1.13
main: venture.Aust1n46.chat.VentureChat main: venture.Aust1n46.chat.initiators.application.VentureChat
depend: [Vault, ProtocolLib, PlaceholderAPI] depend: [Vault, ProtocolLib, PlaceholderAPI]
softdepend: [Towny, Factions, EssentialsDiscord] softdepend: [Towny, Factions, EssentialsDiscord]
author: Aust1n46 author: Aust1n46