Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.kronix.staffchat;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.io.Reader;
- import java.io.UnsupportedEncodingException;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLConnection;
- import java.util.Arrays;
- import java.util.HashMap;
- import java.util.List;
- import java.util.concurrent.TimeUnit;
- import java.util.logging.Level;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerCommandPreprocessEvent;
- import org.bukkit.event.player.PlayerJoinEvent;
- import org.bukkit.plugin.java.JavaPlugin;
- /* List of commands - Added v0.8.2
- /vpc checkver - Check the latest version of plugin and what the current release is
- Permission:
- - vippluschat.admin
- - vippluschat.admin.checkversion
- /vpc reload - Reload the Chat.yml and Config.yml files
- Permission:
- - vippluschat.admin
- - vippluschat.admin.reload
- /vpc {ignore/unignore} {chat} - Set your self to ignore/unignore the specified chat
- Permission:
- - vippluschat.chat.ignore
- /vpc ignored {chat} | optional: {show/#/all} - View the list of ignored users with in the chat specified
- Permission:
- - vippluschat.admin
- - vippluschat.admin.ignored
- /vpc toggle {chat} - Enable/Disable the chat specified
- Permission:
- - vippluschat.admin
- - vippluschat.admin.toggle
- - vippluschat.toggle.{permission} - The permission is defined in the chat.yml
- /vpc blacklist {+/add/del/rem/delete/remove/-/clear} {username} - Add/remove/clear the User{s} to/from the blacklist
- Permission:
- - vippluschat.admin
- - vippluschat.admin.blacklist
- /vpc {fui/forceunignore} {chat} {username} - Force the user to uningore the chat specified
- Permission:
- - vippluschat.admin
- - vippluschat.admin.forceunignore
- /vpc blacklisted | Optional: {all/#/show} - View the blacklisted users
- Permission:
- - vippluschat.admin
- - vippluschat.admin.blacklisted
- /vpc colors {chat} - The command allows you to see what colors are enabled for this command
- Permission:
- - vippluschat.admin
- - vippluschat.admin.viewcolors
- /vpc colors toggle {chat} {color-code} - This will allow you to toggle the state of the color code entered
- Permission:
- - vippluschat.admin
- - vippluschat.admin.togglecolors
- /{chat} {message} - The chat command is defied with in the chat.yml config. This command allows you to chat in the chats
- Permission:
- - vippluschat.chat.{permission} - The permission is defined in the chat.yml
- - vippluschat.chat.* - Gives you permission to all the chats
- - vippluschat.allowchat - This is required on top of the permission used for the indivual chats.
- */
- public class StaffChat extends JavaPlugin implements Listener {
- //---- This is used to easily grab the current version of the program - Added v0.8
- public String version = "v0.8.2";
- //---- End Version String
- @Override
- public void onEnable(){
- Bukkit.getServer().getPluginManager().registerEvents(this, this);
- checkOldConfgAndPort();
- loadConfiguration();
- loadChats();
- }
- //---- This is used to create the default config.yml and was added in v0.6
- public void loadConfiguration(){
- getConfig().options().copyDefaults(true);
- saveConfig();
- }
- //---- End config.yml
- //---- This is used to create the default chat.yml and was added in v0.8.2 to allow for custom chats and to clean up the original config.yml
- public void loadChats(){
- getCustomChats().options().copyDefaults(true);
- saveCustomConfig();
- }
- //---- End Chat.yml
- //---- This is just a little code that I added so when I join the server I can view if you are using my plugin and if so what version - Added v0.8
- @EventHandler
- public void onPlayerJoin(PlayerJoinEvent e) {
- Player p = (Player) e.getPlayer();
- if (p.getUniqueId().toString().equalsIgnoreCase("87acd853-989b-496f-8eb0-9744f160bf15") && p.getName().equals("agentsix1")) { p.sendMessage(ct("&7Oh hey there. It appears this server is using your plugin!. PUBLIC SOURCE - The current version is &9" + version)); System.out.println("The plugin dev for VIP+ Chat has just joined your server! - agentsix1 (uuid: 87acd853-989b-496f-8eb0-9744f160bf15)");}
- }
- //---- End Do you own me?
- //---- Detect Custom Chat - This was added to allow custom commands with custom chats! - Added v0.8.2
- @EventHandler
- public void detectCustomChat(PlayerCommandPreprocessEvent e) {
- Player p = e.getPlayer();
- if (p.hasPermission("vippluschat.allowchat")) {
- try {
- String[] cmd = e.getMessage().split(" ");
- int chatID = detectChatID(cmd[0].replace("/", ""));
- if (chatID > -1 & p.hasPermission("vippluschat.chat." + getCustomChats().getString(chatID + ".permission"))) {
- String msg = "";
- for(int i = 0; i < cmd.length; i++){
- if (i != 0) {
- String fmsg = cmd[i] + " ";
- msg = msg + fmsg;
- }
- }
- e.setCancelled(true);
- sendMessages(msg, p, "vippluschat.chat." + getCustomChats().getString(chatID + ".permission"), chatID + ".layout", chatID);
- }
- } catch (ArrayIndexOutOfBoundsException catcherror) {
- int chatID = detectChatID(e.getMessage().replace("/", ""));
- if (chatID > -1) {
- if (p.hasPermission("vippluschat.chat." + getCustomChats().getString(chatID + ".permission"))) {
- e.setCancelled(true);
- }
- }
- }
- }
- }
- //---- End Detect Custom Chat
- //---- Detect Chat ID - This was added to detect what what chat you are trying to reach - Added v0.8.2
- public int detectChatID(String command) {
- int i = 0;
- do {
- for ( String cmd : getCustomChats().getStringList(i + ".command")) {
- if (cmd.equalsIgnoreCase(command)) {
- return i;
- }
- }
- } while (i++ < getCustomChats().getInt("Chat Count") - 1);
- return -1;
- }
- //---- End Detect Chat ID
- public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
- if(sender instanceof Player) {
- Player p = (Player) sender;
- //---- View color status - Added v0.8.2 - /vpc colors {chat}
- if (cmdLabel.equalsIgnoreCase("vpc") && args.length == 2) {
- if (args[0].equalsIgnoreCase("colors")) {
- if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.viewcolors")) {
- int chatID = detectChatID(args[1]);
- if (chatID > -1) {
- pMessage(outputColorCodes(chatID), p);
- }
- } else {
- p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
- }
- }
- }
- //---- End view color status
- //---- Toggle Colors - Added v0.8.2 - /vpc colors toggle {chat} {color-code}
- if (cmdLabel.equalsIgnoreCase("vpc") && args.length == 4) {
- if (args[0].equalsIgnoreCase("colors") && args[1].equalsIgnoreCase("toggle")) {
- if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.togglecolors")) {
- int chatID = detectChatID(args[2]);
- if (chatID > -1) {
- if (toggleColor(args[3], chatID)) {
- pMessage("Chat color has been toggled", p);
- } else {
- pMessage("Chat color has failed to toggle", p);
- }
- }
- } else {
- p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
- }
- }
- }
- //---- End Toggle Colors
- //---- Add Custom Chats
- //---- End Add Custom Chats
- //---- Toggle ignore chats - Added v0.8.2
- //---- End Toggle ignore chats
- //---- Focus Mode
- //---- End Focus Mode
- //---- Check Version - Added 7/02/16 v0.8 - /vpc checkver
- if (cmdLabel.equalsIgnoreCase("vpc") && args.length == 1) {
- if (args[0].equalsIgnoreCase("checkver")) {
- if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.checkversion")) {
- if (getConfig().getBoolean("Check Version")) {
- try {
- URL u = new URL("http://pastebin.com/raw/2ik6fXLb");
- URLConnection conn = u.openConnection();
- BufferedReader in = new BufferedReader(
- new InputStreamReader(
- conn.getInputStream()));
- StringBuffer buffer = new StringBuffer();
- String inputLine;
- while ((inputLine = in.readLine()) != null)
- buffer.append(inputLine);
- in.close();
- System.out.println(buffer.toString());
- p.sendMessage(ct("&7Your current version is: &9" + version + " &7The last released version is: &9" + buffer.toString()));
- return true;
- } catch (MalformedURLException e) {
- e.printStackTrace();
- return false;
- } catch (IOException e) {
- e.printStackTrace();
- return false;
- }
- } else {
- p.sendMessage(ct("&cYou currently have check version disabled inside of the config."));
- return true;
- }
- } else {
- p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
- }
- }
- }
- //---- End Check Version
- //---- Reload - Added PRE v0.8 - /vpc reload
- if(cmdLabel.equalsIgnoreCase("vpc") && args[0].equalsIgnoreCase("reload")) {
- if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.reload")) {
- this.reloadConfig();
- this.reloadChats();
- loadChats();
- loadConfiguration();
- pMessage(getConfig().getString("Messages.reload"), p);
- return true;
- } else {
- p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
- }
- }
- //---- End Reload
- //---- Chat - Added PRE v0.8 - /{chat} {message}
- /*
- if((cmdLabel.equalsIgnoreCase("staff") || cmdLabel.equalsIgnoreCase("st")) && p.hasPermission("vippluschat.chat.staff")) {
- String msg = "";
- for(int i = 0; i < args.length; i++){
- String arg = args[i] + " ";
- msg = msg + arg;
- }
- if (getConfig().getString("Enabled.Staff") == "true") {
- sendMessages(msg, p, "vippluschat.chat.staff", "Staff");
- } else {
- pMessage(getConfig().getString("Messages.chat-disabled").replace("%CHAT_NAME%", "Staff").replace("%PLAYER%", p.getName()), p);
- }
- return true;
- }
- ---- Removed v0.8.2 - This is the old chat system which is useless now but is here for future notes!*/
- //---- Chat End
- //---- Un/Ignore - Added PRE v0.8 - /vpc {ignore/unignore} {chat}
- if (cmdLabel.equalsIgnoreCase("vpc") && args.length == 2) {
- if (args[0].equalsIgnoreCase("ignore") || args[0].equalsIgnoreCase("unignore") ) {
- if (p.hasPermission("vippluschat.chat.ignore")) {
- if (detectChatID(args[1]) > -1) {
- int chatID = detectChatID(args[1]);
- if (checkIgnoreChatSpecified(p.getName(), getCustomChats().getString(chatID + ".name"))) {
- if (getCustomChats().getBoolean(chatID + ".allow-ignore")) {
- if (args[0].equalsIgnoreCase("ignore")) {
- boolean b = false;
- reloadConfig();
- /* ---- Removed v0.8.2 when new black list system was added
- for (String a: getConfig().getString("Other.blacklist").split(",")) {
- if (a.equalsIgnoreCase(p.getName())) {
- pMessage(getConfig().getString("Messages.blacklist"), p);
- return false;
- }
- }
- */
- for (String a: getCustomChats().getString(chatID + ".ignore-list").split(",")) {
- if (a.equalsIgnoreCase(p.getName())) {
- b = true;
- }
- }
- if (!b) {
- if (getCustomChats().getString(chatID + ".ignore-list").equalsIgnoreCase("")) {
- getCustomChats().set(chatID + ".ignore-list", p.getName().toLowerCase());
- saveCustomConfig();
- pMessage(ct(getConfig().getString("Messages.ignore").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")).replace("%STATUS%", "ignored").replace("%PLAYER%", p.getName())), p);
- return true;
- } else {
- getCustomChats().set(chatID + ".ignore-list", p.getName().toLowerCase() + "," + getConfig().getString(chatID + ".ignore-list".toLowerCase()));
- saveCustomConfig();
- pMessage(ct(getConfig().getString("Messages.ignore").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")).replace("%STATUS%", "ignored").replace("%PLAYER%", p.getName())), p);
- return true;
- }
- } else {
- pMessage(ct(getConfig().getString("Messages.ignore-already").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")).replace("%STATUS%", "ignored").replace("%PLAYER%", p.getName())), p);
- return true;
- }
- } else {
- boolean b = false;
- String c = "";
- int d = 0;
- for (String a: getCustomChats().getString(chatID + ".ignore-list").split(",")) {
- if (a.equalsIgnoreCase(p.getName())) {
- b = true;
- } else {
- if (d == 0) {
- d += 1;
- c = a;
- } else {
- String e = c;
- c = e + "," + a;
- }
- }
- }
- if (!b) {
- pMessage(ct(getConfig().getString("Messages.ignore-not-found").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")).replace("%STATUS%", "unignored").replace("%PLAYER%", p.getName())), p);
- return true;
- } else {
- getCustomChats().set(chatID + ".ignore-list", c);
- saveCustomConfig();
- if (c.length() == 0) {
- getCustomChats().set(chatID + ".ignore-list", "");
- saveCustomConfig();
- }
- pMessage(ct(getConfig().getString("Messages.ignore").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")).replace("%STATUS%", "unignored").replace("%PLAYER%", p.getName())), p);
- return true;
- }
- }
- } else {
- pMessage(getConfig().getString("Messages.ignore-disabled").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")),p);
- }
- } else {
- pMessage("You are blacklisted from ignoring this chat.", p);
- }
- } else {
- pMessage(ct(getConfig().getString("Messages.ignore-fail").replace("%CHAT_NAME%", getCustomChats().getString(detectChatID(args[1]) + ".name")).replace("%STATUS%", "unignored").replace("%PLAYER%", p.getName())), p);
- }
- } else {
- p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
- }
- }
- }
- //---- Ignore End
- //---- Get Ignore List - Added PRE v0.8 - /vpc ignored {chat} : {show/#/all}
- if (cmdLabel.equalsIgnoreCase("vpc") && (args.length == 2|| args.length == 3)) {
- if (args[0].equalsIgnoreCase("ignored")) {
- if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.ignored")) {
- if (detectChatID(args[1]) > -1) {
- int chatID = detectChatID(args[1]);
- int page = 1;
- try {
- page = Integer.parseInt(args[2]);
- } catch (NumberFormatException e) {
- if (args[2].equalsIgnoreCase("all")) {
- String[] ignoredlist = getCustomChats().getString(chatID + ".ignore-list").split(",");
- double listLength = ignoredlist.length;
- if (getCustomChats().getString(chatID + ".ignore-list").equalsIgnoreCase("")) {listLength = 0;}
- pMessage(getConfig().getString("Messages.ignore-list").replace("%LIST%", getCustomChats().getString(chatID + ".ignore-list").replace(",", ", ")).replace("%COUNT%", String.valueOf(listLength).replace(".0", "") + ""), p);
- return true;
- } else if (args[2].equalsIgnoreCase("show")) {
- page = 1;
- } else {
- return false;
- }
- } catch (ArrayIndexOutOfBoundsException d) {
- }
- String[] ignorelist = getCustomChats().getString(chatID + ".ignore-list").split(",");
- String ignored = "";
- double listLength = ignorelist.length;
- double length = getConfig().getDouble("Other.ignored-length");
- double pages = Math.ceil((double)listLength/(double)length);
- int i = 1;
- for (String user : ignorelist) {
- if (i < (getConfig().getInt("Other.ignored-length") * page)) {
- if (i >= getConfig().getInt("Other.ignored-length") * (page - 1)) {
- if (ignored.equalsIgnoreCase("")) {
- ignored = user;
- } else {
- if (!user.equalsIgnoreCase("")) {
- ignored = user + ", " + ignored;
- }
- }
- }
- } else { break; }
- i++;
- }
- if (getCustomChats().getString(chatID + ".ignore-list").equalsIgnoreCase("")) {listLength = 0;}
- ignored = ignored + " &8| &9Pages: " + page + "/" + String.valueOf(pages).replace(".0", "");
- pMessage(getConfig().getString("Messages.ignore-list").replace("%LIST%", ignored).replace("%COUNT%", String.valueOf(listLength).replace(".0", "") + "").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")), p);
- return true;
- /* ---- Removed when custom chats were added in v0.8.2
- pMessage(getConfig().getString("Messages.ignore-list").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")).replace("%LIST%", getCustomChats().getString(chatID + ".ignore-list")), p);
- return true;
- */
- } else {
- pMessage(getConfig().getString("Messages.ignore-fail"), p);
- return true;
- }
- } else {
- p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
- }
- }
- }
- //---- Toggle Chat - Added PRE v0.8 - /vpc toggle {chat} : {true/false}
- if (cmdLabel.equalsIgnoreCase("vpc") && args.length == 2 || args.length == 3) {
- if(args[0].equalsIgnoreCase("toggle") && detectChatID(args[1]) > -1) {
- int chatID = detectChatID(args[1]);
- if (args.length == 2) {
- if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.toggle") || p.hasPermission("vippluschat.toggle." + getCustomChats().getString(chatID + ".permission"))) {
- if (getCustomChats().getBoolean(chatID + ".enabled")) {
- getCustomChats().set(chatID + ".enabled", false);
- saveCustomConfig();
- reloadChats();
- pMessage(getConfig().getString("Messages.toggle").replace("%CHAT_NAME%", getCustomChats().getString(detectChatID(args[1]) + ".name")).replace("%STATE%", "false"), p);
- } else {
- getCustomChats().set(chatID + ".enabled", true);
- saveCustomConfig();
- reloadChats();
- pMessage(getConfig().getString("Messages.toggle").replace("%CHAT_NAME%", getCustomChats().getString(detectChatID(args[1]) + ".name")).replace("%STATE%", "true"), p);
- }
- return true;
- } else {
- p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
- return false;
- }
- } else if (args.length == 3 ) {
- try{
- if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.toggle") || p.hasPermission("vippluschat.toggle." + getCustomChats().getString(chatID + ".permission"))) {
- boolean st = Boolean.valueOf(args[2]);
- getCustomChats().set(chatID + ".enabled", st);
- saveCustomConfig();
- reloadChats();
- pMessage(getConfig().getString("Messages.toggle").replace("%CHAT_NAME%", getCustomChats().getString(detectChatID(args[1]) + ".name")).replace("%STATE%", args[2]), p);
- } else {
- p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
- }
- } catch (NullPointerException e){
- pMessage(getConfig().getString("Messages.error"), p);
- }
- return true;
- }
- }
- }
- //---- End Toggle Chat
- //---- Blacklist Add/Rem/Del - Added 7/2/16 v0.8 - /vpc blacklist {+/add/del/rem/delete/remove/-/clear} {username}
- if (cmdLabel.equalsIgnoreCase("vpc") && (args.length == 3 || args.length == 2)) {
- String blacklist = "";
- if (args[0].equalsIgnoreCase("blacklist")) {
- if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.blacklist")) {
- if (args[1].equalsIgnoreCase("clear")) {
- getConfig().set("Other.blacklist", "");
- saveConfig();
- if (getConfig().getBoolean("Other.broadcast")) {
- Broadcast(getConfig().getString("Messages.remove-blacklisted").replace("%PLAYER%", "Everyone"));
- return true;
- } else {
- pMessage(getConfig().getString("Messages.remove-blacklisted").replace("%PLAYER%", "Everyone"), p);
- return true;
- }
- }
- if (args[1].equalsIgnoreCase("add") || args[1].equalsIgnoreCase("+")) {
- if (!getConfig().getString("Other.blacklist").equalsIgnoreCase("")) {
- blacklist = getConfig().getString("Other.blacklist");
- }
- if (getConfig().getString("Other.blacklist").equalsIgnoreCase("")) {
- getConfig().set("Other.blacklist", args[2]);
- saveConfig();
- forceUnIgnore(args[2], -1);
- } else {
- getConfig().set("Other.blacklist", args[2] + "," + blacklist);
- saveConfig();
- forceUnIgnore(args[2], -1);
- }
- //forceUnIgnore(args[2], -1);
- if (getConfig().getBoolean("Other.broadcast")) {
- Broadcast(getConfig().getString("Messages.blacklisted").replace("%PLAYER%", args[2]));
- return true;
- } else {
- pMessage(getConfig().getString("Messages.blacklisted").replace("%PLAYER%", args[2]), p);
- return true;
- }
- } else if (args[1].equalsIgnoreCase("rem") || args[1].equalsIgnoreCase("del") || args[1].equalsIgnoreCase("delete")|| args[1].equalsIgnoreCase("remove")|| args[1].equalsIgnoreCase("-") ) {
- if (!getConfig().getString("Other.blacklist").equalsIgnoreCase("")) {
- blacklist = getConfig().getString("Other.blacklist");
- }
- getConfig().set("Other.blacklist", blacklist.replace(args[2] + ",", "").replace(args[2], ""));
- saveConfig();
- if (getConfig().getBoolean("Other.broadcast")) {
- Broadcast(getConfig().getString("Messages.remove-blacklisted").replace("%PLAYER%", args[2]));
- return true;
- } else {
- pMessage(getConfig().getString("Messages.remove-blacklisted").replace("%PLAYER%", args[2]), p);
- return true;
- }
- } else if (args[1].equalsIgnoreCase("clear") & args[2].equalsIgnoreCase("all")) {
- getConfig().set("Other.blacklist", "");
- saveConfig();
- if (getConfig().getBoolean("Other.broadcast")) {
- Broadcast(getConfig().getString("Messages.remove-blacklisted").replace("%PLAYER%", "all"));
- return true;
- } else {
- pMessage(getConfig().getString("Messages.remove-blacklisted").replace("%PLAYER%", "all"), p);
- return true;
- }
- }
- } else {
- p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
- }
- }
- }
- //---- End Blacklist Add/Rem/Del - /vpc blacklist {+/add/del/rem/delete/remove/-/clear} {username}
- //---- Remove Player Ignore - Added 7/2/16 v0.8 - /vpc {fui/forceunignore} {chat} {username}
- if (cmdLabel.equalsIgnoreCase("vpc") && args.length == 3) {
- if (args[0].equalsIgnoreCase("fui") || (args[0].equalsIgnoreCase("forceunignore"))) {
- if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.forceunignore")) {
- if (detectChatID(args[1]) > -1) {
- int chatID = detectChatID(args[1]);
- forceUnIgnore(args[2], chatID);
- pMessage(getConfig().getString("Messages.force-unignore").replace("%PLAYER%", args[2]).replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")), p);
- }
- } else {
- p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
- }
- }
- }
- //---- End Remove Player Ignore
- //---- Blacklisted - Added 7/2/16 v0.8 - /vpc blacklisted : {all/#/show}
- if (cmdLabel.equalsIgnoreCase("vpc") && (args.length == 2 || args.length == 1)) {
- if (args[0].equalsIgnoreCase("blacklisted")) {
- if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.blacklisted")) {
- int page = 1;
- try {
- page = Integer.parseInt(args[1]);
- } catch (NumberFormatException e) {
- if (args[1].equalsIgnoreCase("all")) {
- String[] blacklist = getConfig().getString("Other.blacklist").split(",");
- double listLength = blacklist.length;
- if (getConfig().getString("Other.blacklist").equalsIgnoreCase("")) {listLength = 0;}
- pMessage(getConfig().getString("Messages.blacklisted-list").replace("%LIST%", getConfig().getString("Other.blacklist").replace(",", ", ")).replace("%COUNT%", String.valueOf(listLength).replace(".0", "") + ""), p);
- return true;
- } else if (args[1].equalsIgnoreCase("show")) {
- page = 1;
- } else {
- return false;
- }
- } catch (ArrayIndexOutOfBoundsException d) {
- }
- String[] blacklist = getConfig().getString("Other.blacklist").split(",");
- String blacklisted = "";
- double listLength = blacklist.length;
- double length = getConfig().getDouble("Other.blacklisted-length");
- double pages = Math.ceil((double)listLength/(double)length);
- int i = 1;
- for (String user : blacklist) {
- if (i < (getConfig().getInt("Other.blacklisted-length") * page)) {
- if (i >= getConfig().getInt("Other.blacklisted-length") * (page - 1)) {
- if (blacklisted.equalsIgnoreCase("")) {
- blacklisted = user;
- } else {
- if (!user.equalsIgnoreCase("")) {
- blacklisted = user + ", " + blacklisted;
- }
- }
- }
- } else { break; }
- i++;
- }
- if (getConfig().getString("Other.blacklist").equalsIgnoreCase("")) {listLength = 0;}
- blacklisted = blacklisted + " &8| &9Pages: " + page + "/" + String.valueOf(pages).replace(".0", "");
- pMessage(getConfig().getString("Messages.blacklisted-list").replace("%LIST%", blacklisted).replace("%COUNT%", String.valueOf(listLength).replace(".0", "") + ""), p);
- return true;
- } else {
- p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
- }
- }
- }
- //---- End Blacklisted
- }
- return false;
- }
- //---- Toggle Color Codes - v0.8.2
- public boolean toggleColor(String code, int chatID) {
- String[] color_codes = getCustomChats().getString(chatID + ".color-codes").split(" ");
- for (String color : color_codes) {
- if (color.equalsIgnoreCase(code + ":true")) {
- String theColors = "";
- for (String newColors : color_codes) {
- if (newColors.equalsIgnoreCase(code + ":true")) {
- if (theColors.equalsIgnoreCase("")) {
- theColors = newColors.replace("true", "false");
- } else {
- theColors = theColors + " " + newColors.replace("true", "false");
- }
- } else {
- if (theColors.equalsIgnoreCase("")) {
- theColors = newColors;
- } else {
- theColors = theColors + " " + newColors;
- }
- }
- }
- getCustomChats().set(chatID + ".color-codes", theColors);
- saveCustomConfig();
- reloadChats();
- return true;
- } else if (color.equalsIgnoreCase(code + ":false")) {
- String theColors = "";
- for (String newColors : color_codes) {
- if (newColors.equalsIgnoreCase(code + ":false")) {
- if (theColors.equalsIgnoreCase("")) {
- theColors = newColors.replace("false", "true");
- } else {
- theColors = theColors + " " + newColors.replace("false", "true");
- }
- } else {
- if (theColors.equalsIgnoreCase("")) {
- theColors = newColors;
- } else {
- theColors = theColors + " " + newColors;
- }
- }
- }
- getCustomChats().set(chatID + ".color-codes", theColors);
- saveCustomConfig();
- reloadChats();
- return true;
- }
- }
- return false;
- }
- //---- End Toggle Color Codes
- //---- Used to detect old configs and port them over to the new system - v0.8.2
- public void checkOldConfgAndPort() {
- try {
- String a = getConfig().getString("Check Version");
- String b = getConfig().getString("Tag.mod.allow-ignore");
- if (b.equalsIgnoreCase("null")) {
- return;
- }
- File file = new File(getDataFolder(), "config.yml");
- File file2 = new File(getDataFolder(), "oldConfig.yml");
- file.renameTo(file2);
- saveDefaultConfig();
- reloadConfig();
- reloadOld();
- getConfig().set("Check Version", getOldConfig().getBoolean("Check Version"));
- saveConfig();
- getConfig().set("Other.blacklist",getOldConfig().getString("Other.ignore-blacklist").replaceAll("none", ""));
- saveConfig();
- getConfig().set("Messages.no-permission", getOldConfig().getString("Messages.no-permission"));
- saveConfig();
- getConfig().set("Messages.chat-disabled", getOldConfig().getString("Messages.chat-disabled"));
- saveConfig();
- getConfig().set("Messages.reload", getOldConfig().getString("Messages.reload"));
- saveConfig();
- getConfig().set("Messages.toggle" ,getOldConfig().getString("Messages.toggle"));
- saveConfig();
- getConfig().set("Messages.error", getOldConfig().getString("Messages.error"));
- saveConfig();
- getConfig().set("Messages.ignore", getOldConfig().getString("Messages.ignore"));
- saveConfig();
- getConfig().set("Messages.ignore-fail", getOldConfig().getString("Messages.ignore-fail"));
- saveConfig();
- getConfig().set("Messages.ignore-already", getOldConfig().getString("Messages.ignore-already"));
- saveConfig();
- getConfig().set("Messages.ignore-not-found", getOldConfig().getString("Messages.ignore-not-found"));
- saveConfig();
- getConfig().set("Messages.ignore-disabled", getOldConfig().getString("Messages.ignore-disabled"));
- saveConfig();
- getConfig().set("Messages.force-unignore", getOldConfig().getString("Messages.force-unignore").replace("%CHAT%", "%CHAT_NAME%"));
- saveConfig();
- getConfig().set("Messages.remove-blacklisted",getOldConfig().getString("Messages.remove-blacklisted"));
- saveConfig();
- getCustomChats().set("0.allow-ignore", getOldConfig().getBoolean("Tag.mod.allow-ignore"));
- saveCustomConfig();
- getCustomChats().set("0.layout" , getOldConfig().getString("Tag.mod.layout"));
- saveCustomConfig();
- getCustomChats().set("0.enabled" , getOldConfig().getBoolean("Enabled.Mod"));
- saveCustomConfig();
- getCustomChats().set("0.ignore-list" , getOldConfig().getString("Other.ignore.mod").replaceAll("none", ""));
- saveCustomConfig();
- getCustomChats().set("1.allow-ignore" , getOldConfig().getBoolean("Tag.admin.allow-ignore"));
- saveCustomConfig();
- getCustomChats().set("1.layout" , getOldConfig().getString("Tag.admin.layout"));
- saveCustomConfig();
- getCustomChats().set("1.enabled" , getOldConfig().getBoolean("Enabled.Admin"));
- saveCustomConfig();
- getCustomChats().set("1.ignore-list" , getOldConfig().getString("Other.ignore.admin").replaceAll("none", ""));
- saveCustomConfig();
- getCustomChats().set("2.allow-ignore" , getOldConfig().getBoolean("Tag.owner.allow-ignore"));
- saveCustomConfig();
- getCustomChats().set("2.layout" , getOldConfig().getString("Tag.owner.layout"));
- saveCustomConfig();
- getCustomChats().set("2.enabled" , getOldConfig().getBoolean("Enabled.Owner"));
- saveCustomConfig();
- getCustomChats().set("2.ignore-list" , getOldConfig().getString("Other.ignore.owner").replaceAll("none", ""));
- saveCustomConfig();
- getCustomChats().set("3.allow-ignore" , getOldConfig().getBoolean("Tag.staff.allow-ignore"));
- saveCustomConfig();
- getCustomChats().set("3.layout" , getOldConfig().getString("Tag.staff.layout"));
- saveCustomConfig();
- getCustomChats().set("3.enabled" , getOldConfig().getBoolean("Enabled.Staff"));
- saveCustomConfig();
- getCustomChats().set("3.ignore-list" , getOldConfig().getString("Other.ignore.staff").replaceAll("none", ""));
- saveCustomConfig();
- getCustomChats().set("4.allow-ignore" , getOldConfig().getBoolean("Tag.dev.allow-ignore"));
- saveCustomConfig();
- getCustomChats().set("4.layout" , getOldConfig().getString("Tag.dev.layout"));
- saveCustomConfig();
- getCustomChats().set("4.enabled" , getOldConfig().getBoolean("Enabled.Dev"));
- saveCustomConfig();
- getCustomChats().set("4.ignore-list" , getOldConfig().getString("Other.ignore.dev").replaceAll("none", ""));
- saveCustomConfig();
- getCustomChats().set("5.allow-ignore" , getOldConfig().getBoolean("Tag.vip.allow-ignore"));
- saveCustomConfig();
- getCustomChats().set("5.layout" , getOldConfig().getString("Tag.vip.layout"));
- saveCustomConfig();
- getCustomChats().set("5.enabled" , getOldConfig().getBoolean("Enabled.VIP"));
- saveCustomConfig();
- getCustomChats().set("5.ignore-list" , getOldConfig().getString("Other.ignore.vip").replaceAll("none", ""));
- saveCustomConfig();
- getCustomChats().set("6.allow-ignore" , getOldConfig().getBoolean("Tag.donator.allow-ignore"));
- saveCustomConfig();
- getCustomChats().set("6.layout" , getOldConfig().getString("Tag.donator.layout"));
- saveCustomConfig();
- getCustomChats().set("6.enabled" , getOldConfig().getBoolean("Enabled.Donator"));
- saveCustomConfig();
- getCustomChats().set("6.ignore-list" , getOldConfig().getString("Other.ignore.donator").replaceAll("none", ""));
- saveCustomConfig();
- getCustomChats().set("7.allow-ignore" , getOldConfig().getBoolean("Tag.special.allow-ignore"));
- saveCustomConfig();
- getCustomChats().set("7.layout" , getOldConfig().getString("Tag.special.layout"));
- saveCustomConfig();
- getCustomChats().set("7.enabled" , getOldConfig().getBoolean("Enabled.Special"));
- saveCustomConfig();
- getCustomChats().set("7.ignore-list" , getOldConfig().getString("Other.ignore.special").replaceAll("none", ""));
- saveCustomConfig();
- getCustomChats().set("8.allow-ignore" , getOldConfig().getBoolean("Tag.elite.allow-ignore"));
- saveCustomConfig();
- getCustomChats().set("8.layout" , getOldConfig().getString("Tag.elite.layout"));
- saveCustomConfig();
- getCustomChats().set("8.enabled" , getOldConfig().getBoolean("Enabled.Elite"));
- saveCustomConfig();
- getCustomChats().set("8.ignore-list" , getOldConfig().getString("Other.ignore.elite").replaceAll("none", ""));
- saveCustomConfig();
- File file3 = new File(getDataFolder(), "oldConfig.yml");
- File file4 = new File(getDataFolder(), "oldConfig.yml.bak");
- file3.renameTo(file4);
- } catch (NullPointerException failed) {
- }
- }
- //---- End Detect Old Config
- //---- Check and port configs to new config system! - v0.8.2
- public void portConfig() {
- }
- //---- End Check and port configs to new config system!
- //---- Check black list to see if the player is on the blacklist - v0.8.2
- public boolean checkBlacklist(String player) {
- List<String> blacklisted = Arrays.asList(getConfig().getString("Other.blacklist").split(","));
- for (String p : blacklisted) {
- if (p.toLowerCase().equalsIgnoreCase(player.toLowerCase())) {
- return true;
- }
- }
- return false;
- }
- //---- End blacklist check player
- //---- Check blacklist options to see if they can view chat - v0.8.2
- public boolean checkView(String player) {
- if (checkBlacklist(player) & getConfig().getBoolean("Other.Blacklist-Settings.can-view-chats.enabled")) {
- return true;
- } else if (checkBlacklist(player) & !getConfig().getBoolean("Other.Blacklist-Settings.can-view-chats.enabled")){
- return false;
- }
- return false;
- }
- //---- End blacklist check options view chat
- //---- Check blacklist options to see if they can view chat is specified - v0.8.2
- public boolean checkViewChatSpecified(String player, String chat) {
- if (checkBlacklist(player)) {
- if (!getConfig().getBoolean("Other.Blacklist-Settings.can-view-chats.enabled")) {
- return true;
- }
- if (checkView(player)) {
- for (String c : getConfig().getStringList("Other.Blacklist-Settings.can-view-chats.specified-chats")) {
- if (c.toLowerCase().equalsIgnoreCase(chat.toLowerCase())) { return true; }
- }
- return false;
- }
- }
- return true;
- }
- //---- End blacklist check options view chat if chat is specified
- //---- Check blacklist options to see if they can talk chat - v0.8.2
- public boolean checkTalk(String player) {
- if (checkBlacklist(player) & getConfig().getBoolean("Other.Blacklist-Settings.can-talk-in-chats.enabled")) {
- return true;
- } else if (checkBlacklist(player) & !getConfig().getBoolean("Other.Blacklist-Settings.can-talk-in-chats.enabled")){
- return false;
- }
- return false;
- }
- //---- End blacklist check options talk chat
- //---- Check blacklist options to see if they can talk chat is specified - v0.8.2
- public boolean checkTalkChatSpecified(String player, String chat) {
- if (checkBlacklist(player)) {
- if (!getConfig().getBoolean("Other.Blacklist-Settings.can-talk-in-chats.enabled")) {
- return true;
- }
- if (checkTalk(player)) {
- for (String c : getConfig().getStringList("Other.Blacklist-Settings.can-talk-in-chats.specified-chats")) {
- if (c.toLowerCase().equalsIgnoreCase(chat.toLowerCase())) { return true; }
- }
- return false;
- }
- }
- return true;
- }
- //---- End blacklist check options talk chat if chat is specified
- //---- Check ignore options to see if they can ignore chat - v0.8.2
- public boolean checkIgnore(String player) {
- if (checkBlacklist(player.toLowerCase()) & getConfig().getBoolean("Other.Blacklist-Settings.can-ignore-chats.enabled")) {
- return true;
- } else if (checkBlacklist(player.toLowerCase()) & !getConfig().getBoolean("Other.Blacklist-Settings.can-ignore-chats.enabled")){
- return false;
- }
- return false;
- }
- //---- End ignore check options ignore chat
- //---- Check ignore options to see if they can ignore chat is specified - v0.8.2
- public boolean checkIgnoreChatSpecified(String player, String chat) {
- if (checkBlacklist(player.toLowerCase())) {
- if (!getConfig().getBoolean("Other.Blacklist-Settings.can-ignore-chats.enabled")) {
- return true;
- }
- if (checkIgnore(player.toLowerCase())) {
- for (String c : getConfig().getStringList("Other.Blacklist-Settings.can-ignore-chats.specified-chats")) {
- if (c.toLowerCase().equalsIgnoreCase(chat.toLowerCase())) { return true; }
- }
- return false;
- }
- }
- return true;
- }
- //---- End ignore check options ignore chat if chat is specified
- //---- This is called when force unignoring chats. This was modified to accept custom chats in v0.8.2 - Created in v0.8
- private void forceUnIgnore(String player, int id) {
- if (id == -1) {
- int i = 0;
- if (player.equalsIgnoreCase("*")) {
- do {
- getCustomChats().set(i + ".ignore-list", "");
- saveCustomConfig();
- } while (i++ < getCustomChats().getInt("Chat Count") - 1);
- } else {
- do {
- getCustomChats().set(i + ".ignore-list", getCustomChats().getString(i + ".ignore-list").toLowerCase().replace(player.toLowerCase() + ",", "").replace(player.toLowerCase(), ""));
- saveCustomConfig();
- } while (i++ < getCustomChats().getInt("Chat Count") - 1);
- }
- return;
- }
- if (player.equalsIgnoreCase("*")) {
- getCustomChats().set(id + ".ignore-list", "");
- saveCustomConfig();
- } else {
- if (getCustomChats().getString(id + ".ignore-list").equalsIgnoreCase("")){
- } else {
- getCustomChats().set(id + ".ignore-list", getCustomChats().getString(id + ".ignore-list").toLowerCase().replace(player.toLowerCase() + ",", "").replace(player.toLowerCase(), ""));
- saveCustomConfig();
- if (getCustomChats().getString(id + ".ignore-list").equalsIgnoreCase("null")) {
- getCustomChats().set(id + ".ignore-list", "");
- saveCustomConfig();
- }
- }
- }
- /* - Removed v0.8.2 - Removed with when custom chats were added
- switch (chat.toLowerCase()) {
- case "mod":
- getConfig().set("Other.ignore.mod", getConfig().getString("Other.ignore.mod").replace(a.getName() + ",", "").replace(a.getName(), ""));
- saveConfig();
- break;
- case "all":
- getConfig().set("Other.ignore.elite", getConfig().getString("Other.ignore.elite").replace(a.getName() + ",", "").replace(a.getName(), ""));
- saveConfig();
- getConfig().set("Other.ignore.special", getConfig().getString("Other.ignore.special").replace(a.getName() + ",", "").replace(a.getName(), ""));
- saveConfig();
- getConfig().set("Other.ignore.donator", getConfig().getString("Other.ignore.donator").replace(a.getName() + ",", "").replace(a.getName(), ""));
- saveConfig();
- getConfig().set("Other.ignore.vip", getConfig().getString("Other.ignore.vip").replace(a.getName() + ",", "").replace(a.getName(), ""));
- saveConfig();
- getConfig().set("Other.ignore.dev", getConfig().getString("Other.ignore.dev").replace(a.getName() + ",", "").replace(a.getName(), ""));
- saveConfig();
- getConfig().set("Other.ignore.staff", getConfig().getString("Other.ignore.staff").replace(a.getName() + ",", "").replace(a.getName(), ""));
- saveConfig();
- getConfig().set("Other.ignore.owner", getConfig().getString("Other.ignore.owner").replace(a.getName() + ",", "").replace(a.getName(), ""));
- saveConfig();
- getConfig().set("Other.ignore.admin", getConfig().getString("Other.ignore.admin").replace(a.getName() + ",", "").replace(a.getName(), ""));
- saveConfig();
- getConfig().set("Other.ignore.mod", getConfig().getString("Other.ignore.mod").replace(a.getName() + ",", "").replace(a.getName(), ""));
- saveConfig();
- break;
- }*/
- }
- //---- End forceunignore
- //---- Used to color not message chats - Added v0.7
- public static String ct(String text) {
- return text.replace("&0", ChatColor.BLACK + "").replace("&1", ChatColor.DARK_BLUE + "").replace("&2", ChatColor.DARK_GREEN + "").replace("&3", ChatColor.DARK_AQUA + "").replace("&4", ChatColor.DARK_RED + "").replace("&5", ChatColor.DARK_PURPLE + "").replace("&6", ChatColor.GOLD + "").replace("&7", ChatColor.GRAY + "").replace("&8", ChatColor.DARK_GRAY + "").replace("&9", ChatColor.BLUE + "").replace("&a", ChatColor.GREEN + "").replace("&b", ChatColor.AQUA + "").replace("&c", ChatColor.RED + "").replace("&d", ChatColor.LIGHT_PURPLE + "").replace("&e", ChatColor.YELLOW + "").replace("&f", ChatColor.WHITE + "").replace("&l", ChatColor.BOLD + "").replace("&m", ChatColor.STRIKETHROUGH + "").replace("&n", ChatColor.UNDERLINE + "").replace("&o", ChatColor.ITALIC + "").replace("&r", ChatColor.RESET + "").replace("&k", ChatColor.MAGIC + "");
- }
- //---- End of color
- //---- Used to broadcast message - Added v0.7
- public static void Broadcast(String msg) {
- String tag = ct("&8[&9VPC&8] &2");
- Bukkit.getServer().broadcastMessage(tag + ct(msg));
- }
- //---- End of broad cast
- //---- Used to detect what colors are enabled for what chats. This was modified in v0.8.2 to accept custom chats
- public Boolean checkColorCodes(String code, int id) {
- System.out.println(code + " - End of list");
- for (String precolors: Arrays.asList(getCustomChats().getString(id + ".color-codes").split(" "))) {
- List<String> temp = Arrays.asList(precolors.split(":"));
- String colors = temp.get(0);
- Boolean colorsState = Boolean.parseBoolean(temp.get(1));
- if (colors.equalsIgnoreCase(code) && colorsState) {
- return true;
- }
- }
- return false;
- }
- //---- End of color checking
- //---- Ingore Check
- public Boolean checkIgnore(String user, int id) {
- boolean b = false;
- for (String a: getCustomChats().getString(id + ".ignore-list").toLowerCase().split(",")) {
- if (a.equalsIgnoreCase(user)) {
- b = true;
- }
- }
- if (b) {
- return true;
- }
- return false;
- }
- //---- Ignore Check End
- //---- Output Color Codes - Added v0.8.2
- public String outputColorCodes(int chatID) {
- String text = getCustomChats().getString(chatID + ".name") + " Current Color Code Status\n";
- int i = 0;
- for (String precolors: Arrays.asList(getCustomChats().getString(chatID + ".color-codes").split(" "))) {
- List<String> temp = Arrays.asList(precolors.split(":"));
- String colors = temp.get(0);
- Boolean colorsState = Boolean.parseBoolean(temp.get(1));
- if (colors.equalsIgnoreCase("black") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&91. &0Black").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("black") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&91. &0Black").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("dark_blue") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&92. &1Dark Blue").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("dark_blue") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&92. &1Dark Blue").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("dark_green") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&93. &2Dark Green").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("dark_green") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&93. &2Dark Green").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("dark_aqua") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&94. &3Dark Aqua").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("dark_aqua") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&94. &3Dark Aqua").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("dark_red") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&95. &4Dark Red").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("dark_red") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&95. &4Dark Red").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("dark_purple") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&96. &5Dark Purple").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("dark_purple") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&96. &5Dark Purple").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("gold") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&97. &6Gold").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("gold") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&97. &6Gold").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("gray") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&98. &7Gray").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("gray") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&98. &7Gray").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("dark_gray") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&99. &8Dark Gray").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("dark_gray") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&99. &8Dark Gray").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("blue") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&910. &9Blue").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("blue") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&910. &9Blue").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("green") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&911. &aGreen").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("green") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&911. &aGreen").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("aqua") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&912. &bAqua").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("aqua") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&912. &bAqua").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("red") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&913. &cRed").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("red") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&913. &cRed").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("light_purple") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&914. &dLight Purple").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("light_purple") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&914. &dLight Purple").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("yellow") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&915. &eYellow").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("yellow") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&915. &eYellow").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("white") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&916. &fWhite").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("white") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&916. &fWhite").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("obfuscated") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&917. &fObfuscated").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("obfuscated") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&917. &fObfuscated").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("bold") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&918. &f&lBold").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("bold") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&918. &f&lBold").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("strikethrough") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&919. &f&mStrikethrough").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("strikethrough") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&919. &f&mStrikethrough").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("underline") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&920. &f&nUnderline").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("underline") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&920. &f&nUnderline").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("italic") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&921. &f&oItalic").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("italic") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&921. &f&oItalic").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- if (colors.equalsIgnoreCase("reset") & colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&922. &f&rReset").replace("%STATE%", "&aEnabled").replace("%NL%", "\n");} else if (colors.equalsIgnoreCase("reset") & !colorsState) { text = text + getConfig().getString("Messages.colors").replace("%COLOR%", "&922. &f&rReset").replace("%STATE%", "&cDisabled").replace("%NL%", "\n");}
- i++;
- }
- return ct(text);
- }
- //---- End Output Color Codes
- //---- Used to send messages - Modified in v0.8.2 to accept custom chats
- public String chatCleaner(String text , int id) {
- if (text.contains("&0") && checkColorCodes("black", id) == true) { text = text.replace("&0", ChatColor.BLACK + ""); } else { text = text.replace("&0", "");}
- if (text.contains("&1") && checkColorCodes("dark_blue", id) == true) { text = text.replace("&1", ChatColor.DARK_BLUE + ""); } else { text = text.replace("&1", "");}
- if (text.contains("&2") && checkColorCodes("dark_green", id) == true) { text = text.replace("&2", ChatColor.DARK_GREEN + ""); } else { text = text.replace("&2", "");}
- if (text.contains("&3") && checkColorCodes("dark_aqua", id) == true) { text = text.replace("&3", ChatColor.DARK_AQUA + ""); } else { text = text.replace("&3", "");}
- if (text.contains("&4") && checkColorCodes("dark_red", id) == true) { text = text.replace("&4", ChatColor.DARK_RED + ""); } else { text = text.replace("&4", "");}
- if (text.contains("&5") && checkColorCodes("dark_purple", id) == true) { text = text.replace("&5", ChatColor.DARK_PURPLE + ""); } else { text = text.replace("&5", "");}
- if (text.contains("&6") && checkColorCodes("gold", id) == true) { text = text.replace("&6", ChatColor.GOLD + ""); } else { text = text.replace("&6", "");}
- if (text.contains("&7") && checkColorCodes("gray", id) == true) { text = text.replace("&7", ChatColor.GRAY + ""); } else { text = text.replace("&7", "");}
- if (text.contains("&8") && checkColorCodes("dark_gray", id) == true) { text = text.replace("&8", ChatColor.DARK_GRAY + ""); } else { text = text.replace("&8", "");}
- if (text.contains("&9") && checkColorCodes("blue", id) == true) { text = text.replace("&9", ChatColor.BLUE + ""); } else { text = text.replace("&9", "");}
- if (text.contains("&a") && checkColorCodes("green", id) == true) { text = text.replace("&a", ChatColor.GREEN + ""); } else { text = text.replace("&a", "");}
- if (text.contains("&b") && checkColorCodes("aqua", id) == true) { text = text.replace("&b", ChatColor.AQUA + ""); } else { text = text.replace("&b", "");}
- if (text.contains("&c") && checkColorCodes("red", id) == true) { text = text.replace("&c", ChatColor.RED + ""); } else { text = text.replace("&c", "");}
- if (text.contains("&d") && checkColorCodes("light_purple", id) == true) { text = text.replace("&d", ChatColor.LIGHT_PURPLE + ""); } else { text = text.replace("&d", "");}
- if (text.contains("&e") && checkColorCodes("yellow", id) == true) { text = text.replace("&e", ChatColor.YELLOW + ""); } else { text = text.replace("&e", "");}
- if (text.contains("&f") && checkColorCodes("white", id) == true) { text = text.replace("&f", ChatColor.WHITE + ""); } else { text = text.replace("&f", "");}
- if (text.contains("&k") && checkColorCodes("obfuscated", id) == true) { text = text.replace("&k", ChatColor.MAGIC + ""); } else { text = text.replace("&k", "");}
- if (text.contains("&l") && checkColorCodes("bold", id) == true) { text = text.replace("&l", ChatColor.BOLD + ""); } else { text = text.replace("&l", "");}
- if (text.contains("&m") && checkColorCodes("strikethrough", id) == true) { text = text.replace("&m", ChatColor.STRIKETHROUGH + ""); } else { text = text.replace("&m", "");}
- if (text.contains("&n") && checkColorCodes("underline", id) == true) { text = text.replace("&n", ChatColor.UNDERLINE + ""); } else { text = text.replace("&n", "");}
- if (text.contains("&o") && checkColorCodes("italic", id) == true) { text = text.replace("&o", ChatColor.ITALIC + ""); } else { text = text.replace("&o", "");}
- if (text.contains("&r") && checkColorCodes("reset", id) == true) { text = text.replace("&r", ChatColor.RESET + ""); } else { text = text.replace("&r", "");}
- return text;
- }
- public void pMessage(String msg, Player p) {
- p.sendMessage(ct("&8[&9VPC&8] &2" + msg));
- }
- public String pSend(String msg, Player p1, Player p2, String layout, int id) {
- String tag = ct(getCustomChats().getString(layout)).replace("%PLAYER%", p2.getName()).replace("%DISPLAY_NAME%", p2.getDisplayName()).replace("%MESSAGE%", chatCleaner(msg, id)).replace("%WORLD%", p1.getWorld().getName()).replace("%GAMEMODE%", p1.getGameMode().toString());
- /* - Removed v0.8.2 - Removed wheen we added the custom chats - 10/3/16
- if(rank == "Mod") { tag = ct(getConfig().getString("Tag.mod.layout")).replace("%PLAYER%", p2.getName()).replace("%MESSAGE%", chatCleaner(msg, "mod")).replace("%WORLD%", p1.getWorld().getName()).replace("%GAMEMODE%", p1.getGameMode().toString()); }
- if(rank == "Admin") { tag = ct(getConfig().getString("Tag.admin.layout")).replace("%PLAYER%", p2.getName()).replace("%MESSAGE%", chatCleaner(msg, "admin")).replace("%WORLD%", p1.getWorld().getName()).replace("%GAMEMODE%", p1.getGameMode().toString()); }
- if(rank == "Staff") { tag = ct(getConfig().getString("Tag.staff.layout")).replace("%PLAYER%", p2.getName()).replace("%MESSAGE%", chatCleaner(msg, "staff")).replace("%WORLD%", p1.getWorld().getName()).replace("%GAMEMODE%", p1.getGameMode().toString()); }
- if(rank == "Owner") { tag = ct(getConfig().getString("Tag.owner.layout")).replace("%PLAYER%", p2.getName()).replace("%MESSAGE%", chatCleaner(msg, "owner")).replace("%WORLD%", p1.getWorld().getName()).replace("%GAMEMODE%", p1.getGameMode().toString()); }
- if(rank == "Dev") { tag = ct(getConfig().getString("Tag.dev.layout")).replace("%PLAYER%", p2.getName()).replace("%MESSAGE%", chatCleaner(msg, "dev")).replace("%WORLD%", p1.getWorld().getName()).replace("%GAMEMODE%", p1.getGameMode().toString()); }
- if(rank == "VIP") { tag = ct(getConfig().getString("Tag.vip.layout")).replace("%PLAYER%", p2.getName()).replace("%MESSAGE%", chatCleaner(msg, "vip")).replace("%WORLD%", p1.getWorld().getName()).replace("%GAMEMODE%", p1.getGameMode().toString()); }
- if(rank == "Donator") { tag = ct(getConfig().getString("Tag.donator.layout")).replace("%PLAYER%", p2.getName()).replace("%MESSAGE%", chatCleaner(msg, "donator")).replace("%WORLD%", p1.getWorld().getName()).replace("%GAMEMODE%", p1.getGameMode().toString()); }
- if(rank == "Special") { tag = ct(getConfig().getString("Tag.special.layout")).replace("%PLAYER%", p2.getName()).replace("%MESSAGE%", chatCleaner(msg, "special")).replace("%WORLD%", p1.getWorld().getName()).replace("%GAMEMODE%", p1.getGameMode().toString()); }
- if(rank == "Elite") { tag = ct(getConfig().getString("Tag.elite.layout")).replace("%PLAYER%", p2.getName()).replace("%MESSAGE%", chatCleaner(msg, "elite")).replace("%WORLD%", p1.getWorld().getName()).replace("%GAMEMODE%", p1.getGameMode().toString()); }
- */
- System.out.println(tag);
- p1.sendMessage(tag);
- return "";
- }
- @SuppressWarnings("deprecation")
- public void sendMessages(String msg, Player player, String permissin, String layout, int id) {
- if(player.hasPermission(permissin) && !checkIgnore(player.getName(), id)) {
- if (checkTalkChatSpecified(player.getName(), getCustomChats().getString(id + ".name").toLowerCase())) {
- if (getCustomChats().getBoolean(id + ".enabled")) {
- for(Player p : Bukkit.getOnlinePlayers()) {
- if(p.hasPermission(permissin) && !checkIgnore(p.getName(), id) && checkViewChatSpecified(p.getName().toLowerCase(), getCustomChats().getString(id + ".name").toLowerCase())) {
- pSend(msg, p, player, layout, id);
- }
- }
- } else {
- pMessage(getConfig().getString("Messages.chat-disabled").replace("%CHAT_NAME%", getCustomChats().getString(id + ".name")).replace("%PLAYER%", player.getName()).replace("%DISPLAY_PLAYER%", player.getDisplayName().replace("%STATE%", "Disabled")).replace("%STATUS%", "").replace("%LIST%", "").replace("%STATUS%", ""), player);
- }
- } else {
- pMessage("You are currently blacklisted from this chat and may not chat in this chat.", player);
- }
- } else {
- pMessage("You are currently ignoring this chat.", player);
- }
- }
- //---- End of sending messages
- // Added the ability to have a custom chats config! - v0.8.2 - 10/3/2016
- private FileConfiguration customChatsConfig = null; //customConfig
- private File customChats = null; //customConfigFile
- public void reloadChats() {
- if (customChats == null) {
- customChats = new File(getDataFolder(), "chat.yml");
- }
- customChatsConfig = YamlConfiguration.loadConfiguration(customChats);
- InputStream defConfigStream = getResource("chat.yml");
- if (defConfigStream != null) {
- YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
- customChatsConfig.setDefaults(defConfig);
- }
- }
- public FileConfiguration getCustomChats() {
- if (customChatsConfig == null) {
- reloadChats();
- }
- return customChatsConfig;
- }
- public void saveCustomConfig() {
- if (customChatsConfig == null || customChatsConfig == null) {
- return;
- }
- try {
- getCustomChats().save(customChats);
- } catch (IOException ex) {
- getLogger().log(Level.SEVERE, "Could not save config to " + customChats, ex);
- }
- }
- public void saveDefaultConfig() {
- if (customChats == null) {
- customChats = new File(getDataFolder(), "chat.yml");
- }
- if (!customChats.exists()) {
- this.saveResource("chat.yml", false);
- }
- }
- //--- End of chats.yml writing tools
- private FileConfiguration oldConfig = null; //customConfig
- private File oldConfigFile = null; //customConfigFile
- public void reloadOld() {
- if (oldConfigFile == null) {
- oldConfigFile = new File(getDataFolder(), "oldConfig.yml");
- }
- oldConfig = YamlConfiguration.loadConfiguration(oldConfigFile);
- InputStream defConfigStream = getResource("oldConfig.yml");
- if (defConfigStream != null) {
- YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
- oldConfig.setDefaults(defConfig);
- }
- }
- public FileConfiguration getOldConfig() {
- if (oldConfig == null) {
- reloadOld();
- }
- return oldConfig;
- }
- public void saveOldConfig() {
- if (oldConfig == null || oldConfig == null) {
- return;
- }
- try {
- getOldConfig().save(oldConfigFile);
- } catch (IOException ex) {
- getLogger().log(Level.SEVERE, "Could not save config to " + oldConfigFile, ex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement