mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-23 02:19:05 +00:00
Separate proxy architecture.
This commit is contained in:
parent
4e9d70adfb
commit
d7a55622be
2
.settings/.gitignore
vendored
2
.settings/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
/org.eclipse.core.resources.prefs
|
||||
/org.eclipse.m2e.core.prefs
|
@ -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
|
||||
|
6
pom.xml
6
pom.xml
@ -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>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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");
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
@ -38,7 +41,7 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr
|
||||
private File bungeePlayerDataDirectory;
|
||||
|
||||
@Inject
|
||||
private UUIDService uuidService;
|
||||
private ProxyUuidService uuidService;
|
||||
@Inject
|
||||
private VentureChatProxyFlatFileController proxyFlatFileController;
|
||||
@Inject
|
||||
@ -46,17 +49,20 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@ -94,27 +100,26 @@ public class VentureChatBungee extends Plugin implements Listener, VentureChatPr
|
||||
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
|
||||
|
@ -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);
|
||||
|
@ -8,7 +8,6 @@ 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
|
||||
@ -16,47 +15,24 @@ 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 (FormatUtils.uuidIsOffline(uuid) && !plugin.getConfig().getBoolean("offline_server_acknowledgement", false));
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 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<>();
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
public void addNameToMap(VentureChatPlayer mcp) {
|
||||
namesMap.put(mcp.getName(), mcp.getUuid());
|
||||
}
|
||||
public void removeNameFromMap(String name) {
|
||||
namesMap.remove(name);
|
||||
}
|
||||
|
||||
public void removeNameFromMap(String name) {
|
||||
namesMap.remove(name);
|
||||
}
|
||||
public void clearNameMap() {
|
||||
namesMap.clear();
|
||||
}
|
||||
|
||||
public void clearNameMap() {
|
||||
namesMap.clear();
|
||||
}
|
||||
public void addMineverseChatPlayerToMap(VentureChatPlayer mcp) {
|
||||
playerMap.put(mcp.getUuid(), mcp);
|
||||
}
|
||||
|
||||
public void addMineverseChatPlayerToMap(VentureChatPlayer mcp) {
|
||||
playerMap.put(mcp.getUuid(), mcp);
|
||||
}
|
||||
public void clearMineverseChatPlayerMap() {
|
||||
playerMap.clear();
|
||||
}
|
||||
|
||||
public void clearMineverseChatPlayerMap() {
|
||||
playerMap.clear();
|
||||
}
|
||||
public Collection<VentureChatPlayer> getMineverseChatPlayers() {
|
||||
return playerMap.values();
|
||||
}
|
||||
|
||||
public Collection<VentureChatPlayer> getMineverseChatPlayers() {
|
||||
return playerMap.values();
|
||||
}
|
||||
public void addMineverseChatOnlinePlayerToMap(VentureChatPlayer mcp) {
|
||||
onlinePlayerMap.put(mcp.getUuid(), mcp);
|
||||
}
|
||||
|
||||
public void addMineverseChatOnlinePlayerToMap(VentureChatPlayer mcp) {
|
||||
onlinePlayerMap.put(mcp.getUuid(), mcp);
|
||||
}
|
||||
public void removeMineverseChatOnlinePlayerToMap(VentureChatPlayer mcp) {
|
||||
onlinePlayerMap.remove(mcp.getUuid());
|
||||
}
|
||||
|
||||
public void removeMineverseChatOnlinePlayerToMap(VentureChatPlayer mcp) {
|
||||
onlinePlayerMap.remove(mcp.getUuid());
|
||||
}
|
||||
public void clearOnlineMineverseChatPlayerMap() {
|
||||
onlinePlayerMap.clear();
|
||||
}
|
||||
|
||||
public void clearOnlineMineverseChatPlayerMap() {
|
||||
onlinePlayerMap.clear();
|
||||
}
|
||||
public Collection<VentureChatPlayer> getOnlineMineverseChatPlayers() {
|
||||
return onlinePlayerMap.values();
|
||||
}
|
||||
|
||||
public Collection<VentureChatPlayer> getOnlineMineverseChatPlayers() {
|
||||
return onlinePlayerMap.values();
|
||||
}
|
||||
/**
|
||||
* 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 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 UUID.
|
||||
*
|
||||
* @param uuid {@link UUID}.
|
||||
* @return {@link VentureChatPlayer}
|
||||
*/
|
||||
public VentureChatPlayer getMineverseChatPlayer(UUID uuid) {
|
||||
return playerMap.get(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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 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 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 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 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 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 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 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 List<String> getNetworkPlayerNames() {
|
||||
return networkPlayerNames;
|
||||
}
|
||||
|
||||
public void clearNetworkPlayerNames() {
|
||||
networkPlayerNames.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public List<String> getNetworkPlayerNames() {
|
||||
return networkPlayerNames;
|
||||
}
|
||||
|
||||
public void clearNetworkPlayerNames() {
|
||||
networkPlayerNames.clear();
|
||||
}
|
||||
|
||||
public void addNetworkPlayerName(String 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);
|
||||
}
|
||||
public void addNetworkPlayerName(String name) {
|
||||
networkPlayerNames.add(name);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
name: VentureChat
|
||||
main: mineverse.Aust1n46.chat.proxy.VentureChatBungee
|
||||
main: venture.Aust1n46.chat.proxy.VentureChatBungee
|
||||
version: ${project.version}
|
||||
author: Aust1n46
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user