mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-23 02:19:05 +00:00
Updated Bungee player data saving system.
This commit is contained in:
parent
17ea0c8c05
commit
6f5fb0976a
@ -4,13 +4,10 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.StringTokenizer;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||||
@ -19,6 +16,7 @@ import mineverse.Aust1n46.chat.bungee.command.GlobalMute;
|
|||||||
import mineverse.Aust1n46.chat.bungee.command.GlobalMuteAll;
|
import mineverse.Aust1n46.chat.bungee.command.GlobalMuteAll;
|
||||||
import mineverse.Aust1n46.chat.bungee.command.GlobalUnmute;
|
import mineverse.Aust1n46.chat.bungee.command.GlobalUnmute;
|
||||||
import mineverse.Aust1n46.chat.bungee.command.GlobalUnmuteAll;
|
import mineverse.Aust1n46.chat.bungee.command.GlobalUnmuteAll;
|
||||||
|
import mineverse.Aust1n46.chat.database.BungeePlayerData;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -28,111 +26,51 @@ import net.md_5.bungee.api.event.ServerDisconnectEvent;
|
|||||||
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
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 net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
//This is the main class for the BungeeCord version of the plugin.
|
//This is the main class for the BungeeCord version of the plugin.
|
||||||
public class MineverseChatBungee extends Plugin implements Listener {
|
public class MineverseChatBungee extends Plugin implements Listener {
|
||||||
|
private static MineverseChatBungee instance;
|
||||||
public Map<String, String> ignore = new HashMap<String, String>();
|
public Map<String, String> ignore = new HashMap<String, String>();
|
||||||
public Map<String, Boolean> spy = new HashMap<String, Boolean>();
|
public Map<String, Boolean> spy = new HashMap<String, Boolean>();
|
||||||
private Configuration bungeeconfig;
|
|
||||||
private Configuration playerData;
|
|
||||||
public static Set<SynchronizedMineverseChatPlayer> players = new HashSet<SynchronizedMineverseChatPlayer>();
|
public static Set<SynchronizedMineverseChatPlayer> players = new HashSet<SynchronizedMineverseChatPlayer>();
|
||||||
public static String PLUGIN_MESSAGING_CHANNEL = "venturechat:data";
|
public static String PLUGIN_MESSAGING_CHANNEL = "venturechat:data";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
if(!getDataFolder().exists()) {
|
instance = this;
|
||||||
getDataFolder().mkdir();
|
|
||||||
}
|
BungeePlayerData.loadLegacyBungeePlayerData();
|
||||||
File config = new File(getDataFolder(), "bungeeconfig.yml");
|
BungeePlayerData.loadBungeePlayerData();
|
||||||
File sync = new File(getDataFolder(), "BungeePlayers.yml");
|
|
||||||
try {
|
|
||||||
if(!config.exists()) {
|
|
||||||
Files.copy(getResourceAsStream("bungeeconfig.yml"), config.toPath());
|
|
||||||
}
|
|
||||||
bungeeconfig = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "bungeeconfig.yml"));
|
|
||||||
if(!sync.exists()) {
|
|
||||||
Files.copy(getResourceAsStream("BungeePlayers.yml"), sync.toPath());
|
|
||||||
}
|
|
||||||
playerData = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "BungeePlayers.yml"));
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
for(String uuidString : playerData.getKeys()) {
|
|
||||||
UUID uuid = UUID.fromString(uuidString);
|
|
||||||
Set<String> listening = new HashSet<String>();
|
|
||||||
StringTokenizer l = new StringTokenizer(playerData.getString(uuidString + ".channels"), ",");
|
|
||||||
while(l.hasMoreTokens()) {
|
|
||||||
String channel = l.nextToken();
|
|
||||||
listening.add(channel);
|
|
||||||
}
|
|
||||||
HashMap<String, Integer> mutes = new HashMap<String, Integer>();
|
|
||||||
StringTokenizer m = new StringTokenizer(playerData.getString(uuidString + ".mutes"), ",");
|
|
||||||
while(m.hasMoreTokens()) {
|
|
||||||
String[] parts = m.nextToken().split(":");
|
|
||||||
mutes.put(parts[0], Integer.parseInt(parts[1]));
|
|
||||||
}
|
|
||||||
HashSet<UUID> ignores = new HashSet<UUID>();
|
|
||||||
StringTokenizer n = new StringTokenizer(playerData.getString(uuidString + ".ignores"), ",");
|
|
||||||
while(n.hasMoreTokens()) {
|
|
||||||
String ignore = n.nextToken();
|
|
||||||
ignores.add(UUID.fromString(ignore));
|
|
||||||
}
|
|
||||||
boolean spy = playerData.getBoolean(uuidString + ".spy");
|
|
||||||
boolean messageToggle = playerData.getBoolean(uuidString + ".messagetoggle");
|
|
||||||
players.add(new SynchronizedMineverseChatPlayer(uuid, listening, mutes, ignores, spy, messageToggle));
|
|
||||||
}
|
|
||||||
this.getProxy().registerChannel(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL);
|
this.getProxy().registerChannel(MineverseChatBungee.PLUGIN_MESSAGING_CHANNEL);
|
||||||
this.getProxy().getPluginManager().registerListener(this, this);
|
this.getProxy().getPluginManager().registerListener(this, this);
|
||||||
if(bungeeconfig.getBoolean("muting")) {
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalMute(this, "globalmute"));
|
registerBungeeCordMuteCommands();
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalMute(this, "gmute"));
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalMuteAll(this, "globalmuteall"));
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalMuteAll(this, "gmuteall"));
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalUnmute(this, "globalunmute"));
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalUnmute(this, "gunmute"));
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalUnmuteAll(this, "globalunmuteall"));
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new GlobalUnmuteAll(this, "gunmuteall"));
|
|
||||||
}
|
|
||||||
if(bungeeconfig.getBoolean("nicknames")) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
for(SynchronizedMineverseChatPlayer p : players) {
|
BungeePlayerData.saveBungeePlayerData();
|
||||||
String listen = "";
|
}
|
||||||
for(String s : p.getListening())
|
|
||||||
listen += s + ",";
|
/**
|
||||||
String mute = "";
|
* Old BungeeCord mute commands that pretty much no one even knows about let alone uses...
|
||||||
for(String s : p.getMutes().keySet())
|
* Slated for removal when the mute system is reworked.
|
||||||
mute += s + ":0,";
|
*/
|
||||||
String ignore = "";
|
private void registerBungeeCordMuteCommands() {
|
||||||
for(UUID s : p.getIgnores())
|
getProxy().getPluginManager().registerCommand(this, new GlobalMute(this, "globalmute"));
|
||||||
ignore += s.toString() + ",";
|
getProxy().getPluginManager().registerCommand(this, new GlobalMute(this, "gmute"));
|
||||||
if(listen.length() > 0)
|
getProxy().getPluginManager().registerCommand(this, new GlobalMuteAll(this, "globalmuteall"));
|
||||||
listen = listen.substring(0, listen.length() - 1);
|
getProxy().getPluginManager().registerCommand(this, new GlobalMuteAll(this, "gmuteall"));
|
||||||
if(mute.length() > 0)
|
getProxy().getPluginManager().registerCommand(this, new GlobalUnmute(this, "globalunmute"));
|
||||||
mute = mute.substring(0, mute.length() - 1);
|
getProxy().getPluginManager().registerCommand(this, new GlobalUnmute(this, "gunmute"));
|
||||||
if(ignore.length() > 0)
|
getProxy().getPluginManager().registerCommand(this, new GlobalUnmuteAll(this, "globalunmuteall"));
|
||||||
ignore = ignore.substring(0, ignore.length() - 1);
|
getProxy().getPluginManager().registerCommand(this, new GlobalUnmuteAll(this, "gunmuteall"));
|
||||||
playerData.set(p.getUUID().toString() + ".channels", listen);
|
}
|
||||||
playerData.set(p.getUUID().toString() + ".mutes", mute);
|
|
||||||
playerData.set(p.getUUID().toString() + ".ignores", ignore);
|
public static MineverseChatBungee getInstance() {
|
||||||
playerData.set(p.getUUID().toString() + ".spy", p.isSpy());
|
return instance;
|
||||||
playerData.set(p.getUUID().toString() + ".messagetoggle", p.getMessageToggle());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(playerData, new File(getDataFolder(), "BungeePlayers.yml"));
|
|
||||||
}
|
|
||||||
catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
170
src/mineverse/Aust1n46/chat/database/BungeePlayerData.java
Normal file
170
src/mineverse/Aust1n46/chat/database/BungeePlayerData.java
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
package mineverse.Aust1n46.chat.database;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import mineverse.Aust1n46.chat.api.SynchronizedMineverseChatPlayer;
|
||||||
|
import mineverse.Aust1n46.chat.bungee.MineverseChatBungee;
|
||||||
|
import mineverse.Aust1n46.chat.utilities.Format;
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @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");
|
||||||
|
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!")));
|
||||||
|
Configuration playerData = ConfigurationProvider.getProvider(YamlConfiguration.class).load(sync);
|
||||||
|
for(String uuidString : playerData.getKeys()) {
|
||||||
|
UUID uuid = UUID.fromString(uuidString);
|
||||||
|
Set<String> listening = new HashSet<String>();
|
||||||
|
StringTokenizer l = new StringTokenizer(playerData.getString(uuidString + ".channels"), ",");
|
||||||
|
while(l.hasMoreTokens()) {
|
||||||
|
String channel = l.nextToken();
|
||||||
|
listening.add(channel);
|
||||||
|
}
|
||||||
|
HashMap<String, Integer> mutes = new HashMap<String, Integer>();
|
||||||
|
StringTokenizer m = new StringTokenizer(playerData.getString(uuidString + ".mutes"), ",");
|
||||||
|
while(m.hasMoreTokens()) {
|
||||||
|
String[] parts = m.nextToken().split(":");
|
||||||
|
mutes.put(parts[0], Integer.parseInt(parts[1]));
|
||||||
|
}
|
||||||
|
HashSet<UUID> ignores = new HashSet<UUID>();
|
||||||
|
StringTokenizer n = new StringTokenizer(playerData.getString(uuidString + ".ignores"), ",");
|
||||||
|
while(n.hasMoreTokens()) {
|
||||||
|
String ignore = n.nextToken();
|
||||||
|
ignores.add(UUID.fromString(ignore));
|
||||||
|
}
|
||||||
|
boolean spy = playerData.getBoolean(uuidString + ".spy");
|
||||||
|
boolean messageToggle = playerData.getBoolean(uuidString + ".messagetoggle");
|
||||||
|
MineverseChatBungee.players.add(new SynchronizedMineverseChatPlayer(uuid, listening, mutes, ignores, spy, messageToggle));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
MineverseChatBungee.players.clear();
|
||||||
|
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!")));
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
sync.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadBungeePlayerData() {
|
||||||
|
try {
|
||||||
|
File playerDataDirectory = new File(BUNGEE_PLAYER_DATA_DIRECTORY_PATH);
|
||||||
|
if(!playerDataDirectory.exists()) {
|
||||||
|
playerDataDirectory.mkdirs();
|
||||||
|
}
|
||||||
|
Files.walk(Paths.get(BUNGEE_PLAYER_DATA_DIRECTORY_PATH))
|
||||||
|
.filter(Files::isRegularFile)
|
||||||
|
.forEach((path) -> readBungeePlayerDataFile(path));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void readBungeePlayerDataFile(Path path) {
|
||||||
|
SynchronizedMineverseChatPlayer smcp;
|
||||||
|
File bungeePlayerDataFile = path.toFile();
|
||||||
|
if(!bungeePlayerDataFile.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Configuration bungeePlayerDataFileConfiguration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(bungeePlayerDataFile);
|
||||||
|
String uuidString = bungeePlayerDataFile.getName().replace(".yml", "");
|
||||||
|
UUID uuid = UUID.fromString(uuidString);
|
||||||
|
Set<String> listening = new HashSet<String>();
|
||||||
|
StringTokenizer l = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("channels"), ",");
|
||||||
|
while(l.hasMoreTokens()) {
|
||||||
|
String channel = l.nextToken();
|
||||||
|
listening.add(channel);
|
||||||
|
}
|
||||||
|
HashMap<String, Integer> mutes = new HashMap<String, Integer>();
|
||||||
|
StringTokenizer m = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("mutes"), ",");
|
||||||
|
while(m.hasMoreTokens()) {
|
||||||
|
String[] parts = m.nextToken().split(":");
|
||||||
|
mutes.put(parts[0], Integer.parseInt(parts[1]));
|
||||||
|
}
|
||||||
|
HashSet<UUID> ignores = new HashSet<UUID>();
|
||||||
|
StringTokenizer n = new StringTokenizer(bungeePlayerDataFileConfiguration.getString("ignores"), ",");
|
||||||
|
while(n.hasMoreTokens()) {
|
||||||
|
String ignore = n.nextToken();
|
||||||
|
ignores.add(UUID.fromString(ignore));
|
||||||
|
}
|
||||||
|
boolean spy = bungeePlayerDataFileConfiguration.getBoolean("spy");
|
||||||
|
boolean messageToggle = bungeePlayerDataFileConfiguration.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();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(smcp != null) {
|
||||||
|
MineverseChatBungee.players.add(smcp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void saveBungeePlayerData() {
|
||||||
|
try {
|
||||||
|
for(SynchronizedMineverseChatPlayer p : MineverseChatBungee.players) {
|
||||||
|
File bungeePlayerDataFile = new File(BUNGEE_PLAYER_DATA_DIRECTORY_PATH, p.getUUID() + ".yml");
|
||||||
|
if(!bungeePlayerDataFile.exists()) {
|
||||||
|
bungeePlayerDataFile.createNewFile();
|
||||||
|
}
|
||||||
|
Configuration bungeePlayerDataFileConfiguration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(bungeePlayerDataFile);
|
||||||
|
|
||||||
|
String listen = "";
|
||||||
|
for(String s : p.getListening())
|
||||||
|
listen += s + ",";
|
||||||
|
String mute = "";
|
||||||
|
for(String s : p.getMutes().keySet())
|
||||||
|
mute += s + ":0,";
|
||||||
|
String ignore = "";
|
||||||
|
for(UUID s : p.getIgnores())
|
||||||
|
ignore += s.toString() + ",";
|
||||||
|
if(listen.length() > 0)
|
||||||
|
listen = listen.substring(0, listen.length() - 1);
|
||||||
|
if(mute.length() > 0)
|
||||||
|
mute = mute.substring(0, mute.length() - 1);
|
||||||
|
if(ignore.length() > 0)
|
||||||
|
ignore = ignore.substring(0, ignore.length() - 1);
|
||||||
|
bungeePlayerDataFileConfiguration.set("channels", listen);
|
||||||
|
bungeePlayerDataFileConfiguration.set("mutes", mute);
|
||||||
|
bungeePlayerDataFileConfiguration.set("ignores", ignore);
|
||||||
|
bungeePlayerDataFileConfiguration.set("spy", p.isSpy());
|
||||||
|
bungeePlayerDataFileConfiguration.set("messagetoggle", p.getMessageToggle());
|
||||||
|
|
||||||
|
ConfigurationProvider.getProvider(YamlConfiguration.class).save(bungeePlayerDataFileConfiguration, bungeePlayerDataFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package mineverse.Aust1n46.chat.utilities;
|
package mineverse.Aust1n46.chat.utilities;
|
||||||
|
|
||||||
|
import static mineverse.Aust1n46.chat.MineverseChat.getInstance;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
@ -25,15 +27,13 @@ import mineverse.Aust1n46.chat.versions.VersionHandler;
|
|||||||
* Class containing chat formatting methods.
|
* Class containing chat formatting methods.
|
||||||
*/
|
*/
|
||||||
public class Format {
|
public class Format {
|
||||||
private static MineverseChat plugin = MineverseChat.getInstance();
|
|
||||||
|
|
||||||
public static final int LEGACY_COLOR_CODE_LENGTH = 2;
|
public static final int LEGACY_COLOR_CODE_LENGTH = 2;
|
||||||
public static final int HEX_COLOR_CODE_LENGTH = 14;
|
public static final int HEX_COLOR_CODE_LENGTH = 14;
|
||||||
public static final String DEFAULT_COLOR_CODE = String.valueOf(ChatColor.WHITE);
|
|
||||||
public static final String HEX_COLOR_CODE_PREFIX = "#";
|
public static final String HEX_COLOR_CODE_PREFIX = "#";
|
||||||
public static final char BUKKIT_COLOR_CODE_PREFIX_CHAR = '\u00A7';
|
public static final char BUKKIT_COLOR_CODE_PREFIX_CHAR = '\u00A7';
|
||||||
public static final String BUKKIT_COLOR_CODE_PREFIX = String.valueOf(BUKKIT_COLOR_CODE_PREFIX_CHAR);
|
public static final String BUKKIT_COLOR_CODE_PREFIX = String.valueOf(BUKKIT_COLOR_CODE_PREFIX_CHAR);
|
||||||
public static final String BUKKIT_HEX_COLOR_CODE_PREFIX = "x";
|
public static final String BUKKIT_HEX_COLOR_CODE_PREFIX = "x";
|
||||||
|
public static final String DEFAULT_COLOR_CODE = BUKKIT_COLOR_CODE_PREFIX + "f";
|
||||||
|
|
||||||
private static final Pattern LEGACY_CHAT_COLOR_DIGITS_PATTERN = Pattern.compile("&([0-9])");
|
private static final Pattern LEGACY_CHAT_COLOR_DIGITS_PATTERN = Pattern.compile("&([0-9])");
|
||||||
private static final Pattern LEGACY_CHAT_COLOR_PATTERN = Pattern.compile(
|
private static final Pattern LEGACY_CHAT_COLOR_PATTERN = Pattern.compile(
|
||||||
@ -70,7 +70,7 @@ public class Format {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Exception?" + e.getLocalizedMessage());
|
System.out.println("Exception?" + e.getLocalizedMessage());
|
||||||
if (plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
if (getInstance().getConfig().getString("loglevel", "info").equals("debug")) {
|
||||||
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll(
|
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll(
|
||||||
"&8[&eVentureChat&8]&e - Prefix and / or suffix don't exist, setting to nothing."));
|
"&8[&eVentureChat&8]&e - Prefix and / or suffix don't exist, setting to nothing."));
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ public class Format {
|
|||||||
json += "]}";
|
json += "]}";
|
||||||
json += "," + convertLinks(c);
|
json += "," + convertLinks(c);
|
||||||
json += "]";
|
json += "]";
|
||||||
if (plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
if (getInstance().getConfig().getString("loglevel", "info").equals("debug")) {
|
||||||
System.out.println(json);
|
System.out.println(json);
|
||||||
System.out.println("END OF JSON");
|
System.out.println("END OF JSON");
|
||||||
System.out.println("END OF JSON");
|
System.out.println("END OF JSON");
|
||||||
@ -436,12 +436,12 @@ public class Format {
|
|||||||
public static String formatModerationGUI(String json, Player player, String sender, String channelName, int hash) {
|
public static String formatModerationGUI(String json, Player player, String sender, String channelName, int hash) {
|
||||||
if (player.hasPermission("venturechat.gui")) {
|
if (player.hasPermission("venturechat.gui")) {
|
||||||
json = json.substring(0, json.length() - 1);
|
json = json.substring(0, json.length() - 1);
|
||||||
json += "," + Format.convertToJsonColors(Format.FormatStringAll(plugin.getConfig().getString("guiicon")),
|
json += "," + Format.convertToJsonColors(Format.FormatStringAll(getInstance().getConfig().getString("guiicon")),
|
||||||
",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/vchatgui " + sender + " " + channelName
|
",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/vchatgui " + sender + " " + channelName
|
||||||
+ " " + hash
|
+ " " + hash
|
||||||
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":["
|
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":["
|
||||||
+ Format.convertToJsonColors(
|
+ Format.convertToJsonColors(
|
||||||
Format.FormatStringAll(plugin.getConfig().getString("guitext")))
|
Format.FormatStringAll(getInstance().getConfig().getString("guitext")))
|
||||||
+ "]}}")
|
+ "]}}")
|
||||||
+ "]";
|
+ "]";
|
||||||
}
|
}
|
||||||
@ -613,7 +613,7 @@ public class Format {
|
|||||||
|
|
||||||
public static String FilterChat(String msg) {
|
public static String FilterChat(String msg) {
|
||||||
int t = 0;
|
int t = 0;
|
||||||
List<String> filters = plugin.getConfig().getStringList("filters");
|
List<String> filters = getInstance().getConfig().getStringList("filters");
|
||||||
for (String s : filters) {
|
for (String s : filters) {
|
||||||
t = 0;
|
t = 0;
|
||||||
String[] pparse = new String[2];
|
String[] pparse = new String[2];
|
||||||
@ -697,7 +697,7 @@ public class Format {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean underlineURLs() {
|
public static boolean underlineURLs() {
|
||||||
return plugin.getConfig().getBoolean("underlineurls", true);
|
return getInstance().getConfig().getBoolean("underlineurls", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int currentTimeMillis() {
|
public static int currentTimeMillis() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user