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.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
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.compliance=1.8

View File

@ -260,5 +260,11 @@
<version>4.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</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.model.SynchronizedVentureChatPlayer;
import venture.Aust1n46.chat.proxy.VentureChatProxySource;
import venture.Aust1n46.chat.service.UUIDService;
import venture.Aust1n46.chat.service.VentureChatPlayerApiService;
import venture.Aust1n46.chat.service.proxy.ProxyUuidService;
import venture.Aust1n46.chat.service.proxy.VentureChatProxyPlayerApiService;
/**
* Class for reading and writing proxy player data.
@ -29,9 +29,9 @@ import venture.Aust1n46.chat.service.VentureChatPlayerApiService;
*/
public class VentureChatProxyFlatFileController {
@Inject
private UUIDService uuidService;
private ProxyUuidService uuidService;
@Inject
private VentureChatPlayerApiService playerApiService;
private VentureChatProxyPlayerApiService playerApiService;
public void loadLegacyBungeePlayerData(File dataFolder, VentureChatProxySource source) {
File sync = new File(dataFolder, "BungeePlayers.yml");

View File

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

View File

@ -37,6 +37,7 @@ import venture.Aust1n46.chat.service.VentureChatPlayerApiService;
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.
@SuppressWarnings("deprecation")
@Singleton
public class ChatListener implements Listener {
private final boolean essentialsDiscordHook = Bukkit.getPluginManager().isPluginEnabled("EssentialsDiscord");
@ -54,8 +55,7 @@ public class ChatListener implements Listener {
private ConfigService configService;
// 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) {
event.setCancelled(true);
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@ -564,7 +564,6 @@ public class ChatListener implements Listener {
System.out.println(out.size() + " bytes size with json");
}
out.writeUTF(plugin.getVaultPermission().getPrimaryGroup(mcp.getPlayer())); // look into not sending this
@SuppressWarnings("deprecation") // Paper Deprecated
final String displayName = mcp.getPlayer().getDisplayName();
out.writeUTF(displayName);
pluginMessageController.sendPluginMessage(byteOutStream);

View File

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

View File

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

View File

@ -7,7 +7,9 @@ import java.nio.file.Files;
import java.util.List;
import java.util.stream.Collectors;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import net.md_5.bungee.api.ProxyServer;
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.YamlConfiguration;
import net.md_5.bungee.event.EventHandler;
import venture.Aust1n46.chat.VentureChatBungeePluginModule;
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;
/**
@ -36,34 +39,37 @@ import venture.Aust1n46.chat.utilities.FormatUtils;
public class VentureChatBungee extends Plugin implements Listener, VentureChatProxySource {
private static Configuration bungeeConfig;
private File bungeePlayerDataDirectory;
@Inject
private ProxyUuidService uuidService;
@Inject
private UUIDService uuidService;
@Inject
private VentureChatProxyFlatFileController proxyFlatFileController;
@Inject
private VentureChatProxy proxy;
@Override
public void onEnable() {
if(!getDataFolder().exists()) {
final VentureChatBungeePluginModule pluginModule = new VentureChatBungeePluginModule(this);
final Injector injector = Guice.createInjector(pluginModule);
injector.injectMembers(this);
if (!getDataFolder().exists()) {
getDataFolder().mkdir();
}
File config = new File(getDataFolder(), "bungeeconfig.yml");
try {
if(!config.exists()) {
if (!config.exists()) {
Files.copy(getResourceAsStream("bungeeconfig.yml"), config.toPath());
}
bungeeConfig = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "bungeeconfig.yml"));
}
catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
bungeePlayerDataDirectory = new File(getDataFolder().getAbsolutePath() + "/PlayerData");
proxyFlatFileController.loadLegacyBungeePlayerData(bungeePlayerDataDirectory, this);
proxyFlatFileController.loadProxyPlayerData(bungeePlayerDataDirectory, this);
this.getProxy().registerChannel(VentureChatProxy.PLUGIN_MESSAGING_CHANNEL_STRING);
this.getProxy().getPluginManager().registerListener(this, this);
}
@ -72,49 +78,48 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr
public void onDisable() {
proxyFlatFileController.saveProxyPlayerData(bungeePlayerDataDirectory, this);
}
@EventHandler
public void onPlayerJoin(ServerSwitchEvent event) {
updatePlayerNames();
}
@EventHandler
public void onPlayerLeave(ServerDisconnectEvent event) {
updatePlayerNames();
}
@EventHandler
public void onPlayerJoinNetwork(PostLoginEvent event) {
uuidService.checkOfflineUUIDWarningProxy(event.getPlayer().getUniqueId(), this);
}
private void updatePlayerNames() {
try {
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(outstream);
out.writeUTF("PlayerNames");
out.writeInt(getProxy().getPlayers().size());
for(ProxiedPlayer pp : getProxy().getPlayers()) {
for (ProxiedPlayer pp : getProxy().getPlayers()) {
out.writeUTF(pp.getName());
}
for(String send : getProxy().getServers().keySet()) {
if(getProxy().getServers().get(send).getPlayers().size() > 0) {
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());
}
}
}
catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}
@EventHandler
public void onPluginMessage(PluginMessageEvent event) {
if(!event.getTag().equals(VentureChatProxy.PLUGIN_MESSAGING_CHANNEL_STRING) && !event.getTag().contains("viaversion:")) {
if (!event.getTag().equals(VentureChatProxy.PLUGIN_MESSAGING_CHANNEL_STRING) && !event.getTag().contains("viaversion:")) {
return;
}
if(!(event.getSender() instanceof Server)) {
if (!(event.getSender() instanceof Server)) {
return;
}
String serverName = ((Server) event.getSender()).getInfo().getName();
@ -128,7 +133,8 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr
@Override
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

View File

@ -12,7 +12,7 @@ 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.service.VentureChatPlayerApiService;
import venture.Aust1n46.chat.service.proxy.VentureChatProxyPlayerApiService;
public class VentureChatProxy {
public static String PLUGIN_MESSAGING_CHANNEL_NAMESPACE = "venturechat";
@ -20,7 +20,7 @@ public class VentureChatProxy {
public static String PLUGIN_MESSAGING_CHANNEL_STRING = "venturechat:data";
@Inject
private VentureChatPlayerApiService playerApiService;
private VentureChatProxyPlayerApiService playerApiService;
public void onPluginMessage(byte[] data, String serverName, VentureChatProxySource source) {
ByteArrayInputStream instream = new ByteArrayInputStream(data);

View File

@ -8,55 +8,31 @@ import com.google.inject.Inject;
import com.google.inject.Singleton;
import venture.Aust1n46.chat.initiators.application.VentureChat;
import venture.Aust1n46.chat.proxy.VentureChatProxySource;
import venture.Aust1n46.chat.utilities.FormatUtils;
@Singleton
public class UUIDService {
@Inject
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) {
return (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) {
if(shouldSkipOfflineUUID(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 - 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 - 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 - 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!"));
return;
public boolean shouldSkipOfflineUUID(UUID uuid) {
return (FormatUtils.uuidIsOffline(uuid) && !plugin.getConfig().getBoolean("offline_server_acknowledgement", false));
}
public void checkOfflineUUIDWarning(UUID 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 - 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 - 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
.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!"));
return;
}
}
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

@ -8,7 +8,8 @@ import java.util.UUID;
import org.bukkit.entity.Player;
import venture.Aust1n46.chat.model.SynchronizedVentureChatPlayer;
import com.google.inject.Singleton;
import venture.Aust1n46.chat.model.VentureChatPlayer;
/**
@ -17,152 +18,125 @@ import venture.Aust1n46.chat.model.VentureChatPlayer;
*
* @author Aust1n46
*/
@Singleton
public class VentureChatPlayerApiService {
private static HashMap<UUID, VentureChatPlayer> playerMap = new HashMap<UUID, VentureChatPlayer>();
private static HashMap<String, UUID> namesMap = new HashMap<String, UUID>();
private static HashMap<UUID, VentureChatPlayer> onlinePlayerMap = new HashMap<UUID, VentureChatPlayer>();
private static List<String> networkPlayerNames = new ArrayList<String>();
private static HashMap<UUID, SynchronizedVentureChatPlayer> proxyPlayerMap = new HashMap<UUID, SynchronizedVentureChatPlayer>();
public void addNameToMap(VentureChatPlayer mcp) {
namesMap.put(mcp.getName(), mcp.getUuid());
}
private final HashMap<UUID, VentureChatPlayer> playerMap = new HashMap<>();
private final HashMap<String, UUID> namesMap = new HashMap<>();
private final HashMap<UUID, VentureChatPlayer> onlinePlayerMap = new HashMap<>();
private final List<String> networkPlayerNames = new ArrayList<>();
public void removeNameFromMap(String name) {
namesMap.remove(name);
}
public void addNameToMap(VentureChatPlayer mcp) {
namesMap.put(mcp.getName(), mcp.getUuid());
}
public void clearNameMap() {
namesMap.clear();
}
public void removeNameFromMap(String name) {
namesMap.remove(name);
}
public void addMineverseChatPlayerToMap(VentureChatPlayer mcp) {
playerMap.put(mcp.getUuid(), mcp);
}
public void clearNameMap() {
namesMap.clear();
}
public void clearMineverseChatPlayerMap() {
playerMap.clear();
}
public void addMineverseChatPlayerToMap(VentureChatPlayer mcp) {
playerMap.put(mcp.getUuid(), mcp);
}
public Collection<VentureChatPlayer> getMineverseChatPlayers() {
return playerMap.values();
}
public void clearMineverseChatPlayerMap() {
playerMap.clear();
}
public void addMineverseChatOnlinePlayerToMap(VentureChatPlayer mcp) {
onlinePlayerMap.put(mcp.getUuid(), mcp);
}
public Collection<VentureChatPlayer> getMineverseChatPlayers() {
return playerMap.values();
}
public void removeMineverseChatOnlinePlayerToMap(VentureChatPlayer mcp) {
onlinePlayerMap.remove(mcp.getUuid());
}
public void addMineverseChatOnlinePlayerToMap(VentureChatPlayer mcp) {
onlinePlayerMap.put(mcp.getUuid(), mcp);
}
public void clearOnlineMineverseChatPlayerMap() {
onlinePlayerMap.clear();
}
public void removeMineverseChatOnlinePlayerToMap(VentureChatPlayer mcp) {
onlinePlayerMap.remove(mcp.getUuid());
}
public Collection<VentureChatPlayer> getOnlineMineverseChatPlayers() {
return onlinePlayerMap.values();
}
public void clearOnlineMineverseChatPlayerMap() {
onlinePlayerMap.clear();
}
/**
* Get a MineverseChatPlayer wrapper from a Bukkit Player instance.
*
* @param player {@link Player} object.
* @return {@link VentureChatPlayer}
*/
public VentureChatPlayer getMineverseChatPlayer(Player player) {
return getMineverseChatPlayer(player.getUniqueId());
}
public Collection<VentureChatPlayer> getOnlineMineverseChatPlayers() {
return onlinePlayerMap.values();
}
/**
* Get a MineverseChatPlayer wrapper from a UUID.
*
* @param uuid {@link UUID}.
* @return {@link VentureChatPlayer}
*/
public VentureChatPlayer getMineverseChatPlayer(UUID uuid) {
return playerMap.get(uuid);
}
/**
* Get a MineverseChatPlayer wrapper from a Bukkit Player instance.
*
* @param player {@link Player} object.
* @return {@link VentureChatPlayer}
*/
public VentureChatPlayer getMineverseChatPlayer(Player player) {
return getMineverseChatPlayer(player.getUniqueId());
}
/**
* Get a MineverseChatPlayer wrapper from a user name.
*
* @param name {@link String}.
* @return {@link VentureChatPlayer}
*/
public VentureChatPlayer getMineverseChatPlayer(String name) {
return getMineverseChatPlayer(namesMap.get(name));
}
/**
* Get a MineverseChatPlayer wrapper from a UUID.
*
* @param uuid {@link UUID}.
* @return {@link VentureChatPlayer}
*/
public VentureChatPlayer getMineverseChatPlayer(UUID uuid) {
return playerMap.get(uuid);
}
/**
* Get a MineverseChatPlayer wrapper from a Bukkit Player instance. Only checks
* current online players. Much more efficient!
*
* @param player {@link Player} object.
* @return {@link VentureChatPlayer}
*/
public VentureChatPlayer getOnlineMineverseChatPlayer(final Player player) {
return getOnlineMineverseChatPlayer(player.getUniqueId());
}
/**
* Get a MineverseChatPlayer wrapper from a user name.
*
* @param name {@link String}.
* @return {@link VentureChatPlayer}
*/
public VentureChatPlayer getMineverseChatPlayer(String name) {
return getMineverseChatPlayer(namesMap.get(name));
}
/**
* Get a MineverseChatPlayer wrapper from a UUID. Only checks current online
* players. Much more efficient!
*
* @param uuid {@link UUID}.
* @return {@link VentureChatPlayer}
*/
public VentureChatPlayer getOnlineMineverseChatPlayer(UUID uuid) {
return onlinePlayerMap.get(uuid);
}
/**
* Get a MineverseChatPlayer wrapper from a Bukkit Player instance. Only checks
* current online players. Much more efficient!
*
* @param player {@link Player} object.
* @return {@link VentureChatPlayer}
*/
public VentureChatPlayer getOnlineMineverseChatPlayer(final Player player) {
return getOnlineMineverseChatPlayer(player.getUniqueId());
}
/**
* Get a MineverseChatPlayer wrapper from a user name. Only checks current
* online players. Much more efficient!
*
* @param name {@link String}.
* @return {@link VentureChatPlayer}
*/
public VentureChatPlayer getOnlineMineverseChatPlayer(String name) {
return getOnlineMineverseChatPlayer(namesMap.get(name));
}
/**
* Get a MineverseChatPlayer wrapper from a UUID. Only checks current online
* players. Much more efficient!
*
* @param uuid {@link UUID}.
* @return {@link VentureChatPlayer}
*/
public VentureChatPlayer getOnlineMineverseChatPlayer(UUID uuid) {
return onlinePlayerMap.get(uuid);
}
public List<String> getNetworkPlayerNames() {
return networkPlayerNames;
}
/**
* Get a MineverseChatPlayer wrapper from a user name. Only checks current
* online players. Much more efficient!
*
* @param name {@link String}.
* @return {@link VentureChatPlayer}
*/
public VentureChatPlayer getOnlineMineverseChatPlayer(String name) {
return getOnlineMineverseChatPlayer(namesMap.get(name));
}
public void clearNetworkPlayerNames() {
networkPlayerNames.clear();
}
public List<String> getNetworkPlayerNames() {
return networkPlayerNames;
}
public void addNetworkPlayerName(String name) {
networkPlayerNames.add(name);
}
public void clearNetworkPlayerNames() {
networkPlayerNames.clear();
}
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);
}
public void addNetworkPlayerName(String name) {
networkPlayerNames.add(name);
}
}

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;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -300,4 +301,15 @@ public class FormatUtils {
public static String stripColor(String message) {
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
main: mineverse.Aust1n46.chat.proxy.VentureChatBungee
main: venture.Aust1n46.chat.proxy.VentureChatBungee
version: ${project.version}
author: Aust1n46
author: Aust1n46

View File

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