Advertisement
agentsix1

Public - VIP+ Chat v0.8.4 - Source - 1.7.9 - 1.11

Dec 22nd, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 66.14 KB | None | 0 0
  1. package me.kronix.staffchat;
  2.  
  3.  
  4. import java.io.BufferedReader;
  5. import java.io.File;
  6. import java.io.IOException;
  7. import java.io.InputStreamReader;
  8. import java.io.Reader;
  9. import java.io.UnsupportedEncodingException;
  10. import java.net.MalformedURLException;
  11. import java.net.URL;
  12. import java.net.URLConnection;
  13. import java.util.Arrays;
  14. import java.util.HashMap;
  15. import java.util.List;
  16. import java.util.concurrent.TimeUnit;
  17. import java.util.logging.Level;
  18.  
  19. import org.bukkit.Bukkit;
  20. import org.bukkit.ChatColor;
  21. import org.bukkit.command.Command;
  22. import org.bukkit.command.CommandSender;
  23. import org.bukkit.configuration.file.FileConfiguration;
  24. import org.bukkit.configuration.file.YamlConfiguration;
  25. import org.bukkit.entity.Player;
  26. import org.bukkit.event.EventHandler;
  27. import org.bukkit.event.Listener;
  28. import org.bukkit.event.player.PlayerCommandPreprocessEvent;
  29. import org.bukkit.event.player.PlayerJoinEvent;
  30. import org.bukkit.plugin.java.JavaPlugin;
  31.  
  32. /* List of commands - Added v0.8.4
  33.  
  34.     /vpc checkver - Check the latest version of plugin and what the current release is
  35.     Permission:
  36.     - vippluschat.admin
  37.     - vippluschat.admin.checkversion
  38.    
  39.     /vpc reload - Reload the Chat.yml and Config.yml files
  40.     Permission:
  41.     - vippluschat.admin
  42.     - vippluschat.admin.reload
  43.    
  44.     /vpc {ignore/unignore} {chat} - Set your self to ignore/unignore the specified chat
  45.     Permission:
  46.     - vippluschat.chat.ignore
  47.    
  48.     /vpc ignored {chat} | optional: {show/#/all} - View the list of ignored users with in the chat specified
  49.     Permission:
  50.     - vippluschat.admin
  51.     - vippluschat.admin.ignored
  52.    
  53.     /vpc toggle {chat} - Enable/Disable the chat specified
  54.     Permission:
  55.     - vippluschat.admin
  56.     - vippluschat.admin.toggle
  57.     - vippluschat.toggle.{permission} - The permission is defined in the chat.yml
  58.    
  59.     /vpc blacklist {+/add/del/rem/delete/remove/-/clear} {username} - Add/remove/clear the User{s} to/from the blacklist
  60.     Permission:
  61.     - vippluschat.admin
  62.     - vippluschat.admin.blacklist
  63.    
  64.     /vpc {fui/forceunignore} {chat} {username} - Force the user to uningore the chat specified
  65.     Permission:
  66.     - vippluschat.admin
  67.     - vippluschat.admin.forceunignore
  68.    
  69.     /vpc blacklisted | Optional: {all/#/show} - View the blacklisted users
  70.     Permission:
  71.     - vippluschat.admin
  72.     - vippluschat.admin.blacklisted
  73.    
  74.     /vpc colors {chat} - The command allows you to see what colors are enabled for this command
  75.     Permission:
  76.     - vippluschat.admin
  77.     - vippluschat.admin.viewcolors
  78.    
  79.     /vpc colors toggle {chat} {color-code} - This will allow you to toggle the state of the color code entered
  80.     Permission:
  81.     - vippluschat.admin
  82.     - vippluschat.admin.togglecolors
  83.    
  84.     /{chat} {message} - The chat command is defied with in the chat.yml config. This command allows you to chat in the chats
  85.     Permission:
  86.     - vippluschat.chat.{permission} - The permission is defined in the chat.yml
  87.     - vippluschat.chat.* - Gives you permission to all the chats
  88.     - vippluschat.allowchat - This is required on top of the permission used for the indivual chats.
  89.  
  90.  */
  91.  
  92.  
  93. public class StaffChat extends JavaPlugin implements Listener {
  94.     //---- This is used to easily grab the current version of the program - Added v0.8
  95. public String version = "v0.8.4";
  96. //---- End Version String
  97.     @Override
  98.     public void onEnable(){
  99.         Bukkit.getServer().getPluginManager().registerEvents(this, this);
  100.         checkOldConfgAndPort();
  101.         loadConfiguration();
  102.         loadChats();
  103.     }
  104.     //---- This is used to create the default config.yml and was added in v0.6
  105.     public void loadConfiguration(){
  106.         getConfig().options().copyDefaults(true);
  107.         saveConfig();
  108.    
  109.     }
  110.     //---- End config.yml
  111.     //---- 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
  112.     public void loadChats(){
  113.         getCustomChats().options().copyDefaults(true);
  114.         saveCustomConfig();
  115.     }
  116.     //---- End Chat.yml
  117.     //---- 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
  118.     @EventHandler
  119.     public void onPlayerJoin(PlayerJoinEvent e) {
  120.         Player p = (Player) e.getPlayer();
  121.         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)");}
  122.     }
  123.     //---- End Do you own me?
  124.     //---- Detect Custom Chat - This was added to allow custom commands with custom chats! - Added v0.8.2
  125.     @EventHandler
  126.     public void detectCustomChat(PlayerCommandPreprocessEvent e) {
  127.         Player p = e.getPlayer();
  128.         if (p.hasPermission("vippluschat.allowchat")) {
  129.             try {
  130.                 String[] cmd = e.getMessage().split(" ");
  131.                 int chatID = detectChatID(cmd[0].replace("/", ""));
  132.                 if (chatID > -1 & p.hasPermission("vippluschat.chat." + getCustomChats().getString(chatID + ".permission"))) {
  133.                         String msg = "";
  134.                         for(int i = 0; i < cmd.length; i++){
  135.                             if (i != 0) {
  136.                                 String fmsg = cmd[i] + " ";
  137.                                 msg = msg + fmsg;
  138.                             }
  139.                         }
  140.                         e.setCancelled(true);
  141.                         sendMessages(msg, p, "vippluschat.chat." + getCustomChats().getString(chatID + ".permission"), chatID + ".layout", chatID);
  142.                 }
  143.             } catch (ArrayIndexOutOfBoundsException catcherror) {
  144.                 int chatID = detectChatID(e.getMessage().replace("/", ""));
  145.                 if (chatID > -1) {
  146.                     if (p.hasPermission("vippluschat.chat." + getCustomChats().getString(chatID + ".permission"))) {
  147.                         e.setCancelled(true);
  148.                     }
  149.                 }
  150.             }
  151.         }
  152.        
  153.     }
  154.     //---- End Detect Custom Chat
  155.     //---- Detect Chat ID - This was added to detect what what chat you are trying to reach - Added v0.8.2
  156.     public int detectChatID(String command) {
  157.         int i = 0;
  158.         do {
  159.             for ( String cmd : getCustomChats().getStringList(i + ".command")) {
  160.                 if (cmd.equalsIgnoreCase(command)) {
  161.                     return i;
  162.                 }
  163.             }
  164.         } while (i++ < getCustomChats().getInt("Chat Count") - 1);
  165.         return -1;
  166.     }
  167.     //---- End Detect Chat ID
  168.     public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
  169.         if(sender instanceof Player) {
  170.             Player p = (Player) sender;
  171.            
  172.             //---- View color status - Added v0.8.2 - /vpc colors {chat}
  173.             if (cmdLabel.equalsIgnoreCase("vpc") && args.length == 2) {
  174.                 if (args[0].equalsIgnoreCase("colors")) {
  175.                     if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.viewcolors")) {
  176.                         int  chatID = detectChatID(args[1]);
  177.                         if (chatID > -1) {
  178.                             pMessage(outputColorCodes(chatID), p);
  179.                         }
  180.                     } else {
  181.                         p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
  182.                     }
  183.                 }
  184.             }
  185.             //---- End view color status
  186.            
  187.             //---- Toggle Colors - Added v0.8.2 - /vpc colors toggle {chat} {color-code}
  188.             if (cmdLabel.equalsIgnoreCase("vpc") && args.length == 4) {
  189.                 if (args[0].equalsIgnoreCase("colors") && args[1].equalsIgnoreCase("toggle")) {
  190.                     if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.togglecolors")) {
  191.                         int  chatID = detectChatID(args[2]);
  192.                         if (chatID > -1) {
  193.                             if (toggleColor(args[3], chatID)) {
  194.                                 pMessage("Chat color has been toggled", p);
  195.                             } else {
  196.                                 pMessage("Chat color has failed to toggle", p);
  197.                             }
  198.                         }  
  199.                     } else {
  200.                         p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
  201.                     }
  202.                    
  203.                 }
  204.                
  205.             }
  206.             //---- End Toggle Colors
  207.            
  208.             //---- Add Custom Chats
  209.            
  210.             //---- End Add Custom Chats
  211.            
  212.             //---- Toggle ignore chats - Added v0.8.2
  213.            
  214.             //---- End Toggle ignore chats
  215.            
  216.             //---- Focus Mode
  217.            
  218.             //---- End Focus Mode
  219.            
  220.             //---- Check Version - Added 7/02/16 v0.8 - /vpc checkver
  221.             if (cmdLabel.equalsIgnoreCase("vpc") && args.length == 1) {
  222.                 if (args[0].equalsIgnoreCase("checkver")) {
  223.                     if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.checkversion")) {
  224.                         if (getConfig().getBoolean("Check Version")) {
  225.                             try {
  226.                                 URL u = new URL("http://pastebin.com/raw/2ik6fXLb");
  227.                                 URLConnection conn = u.openConnection();
  228.                                 BufferedReader in = new BufferedReader(
  229.                                         new InputStreamReader(
  230.                                                 conn.getInputStream()));
  231.                                 StringBuffer buffer = new StringBuffer();
  232.                                 String inputLine;
  233.                                 while ((inputLine = in.readLine()) != null)
  234.                                     buffer.append(inputLine);
  235.                                 in.close();
  236.                                 System.out.println(buffer.toString());
  237.                                 p.sendMessage(ct("&7Your current version is: &9" + version + " &7The last released version is: &9" + buffer.toString()));
  238.                                 return true;
  239.                             } catch (MalformedURLException e) {
  240.                                 e.printStackTrace();
  241.                                 return false;
  242.                             } catch (IOException e) {
  243.                                 e.printStackTrace();
  244.                                 return false;
  245.                             }
  246.                         } else {
  247.                             p.sendMessage(ct("&cYou currently have check version disabled inside of the config."));
  248.                             return true;
  249.                         }
  250.                     } else {
  251.                         p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
  252.                     }
  253.                 }
  254.             }
  255.             //---- End Check Version
  256.            
  257.             //---- Reload - Added PRE v0.8 - /vpc reload
  258.             if(cmdLabel.equalsIgnoreCase("vpc") && args[0].equalsIgnoreCase("reload")) {
  259.                 if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.reload")) {
  260.                     this.reloadConfig();
  261.                     this.reloadChats();
  262.                     loadChats();
  263.                     loadConfiguration();
  264.                     pMessage(getConfig().getString("Messages.reload"), p);
  265.                     return true;
  266.                 } else {
  267.                     p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
  268.                 }
  269.             }
  270.             //---- End Reload
  271.            
  272.             //---- Chat - Added PRE v0.8 - /{chat} {message}
  273.             /*
  274.             if((cmdLabel.equalsIgnoreCase("staff") || cmdLabel.equalsIgnoreCase("st")) && p.hasPermission("vippluschat.chat.staff")) {
  275.                 String msg = "";    
  276.  
  277.                 for(int i = 0; i < args.length; i++){
  278.                     String arg = args[i] + " ";
  279.                     msg = msg + arg;
  280.                 }
  281.                 if (getConfig().getString("Enabled.Staff") == "true") {
  282.                     sendMessages(msg, p, "vippluschat.chat.staff", "Staff");
  283.                 } else {
  284.                     pMessage(getConfig().getString("Messages.chat-disabled").replace("%CHAT_NAME%", "Staff").replace("%PLAYER%", p.getName()), p);
  285.                 }
  286.                 return true;
  287.                
  288.             }
  289.             ---- Removed v0.8.2 - This is the old chat system which is useless now but is here for future notes!*/
  290.             //---- Chat End
  291.            
  292.             //---- Un/Ignore - Added PRE v0.8 - /vpc {ignore/unignore} {chat}
  293.            
  294.             if (cmdLabel.equalsIgnoreCase("vpc") && args.length == 2) {
  295.                 if (args[0].equalsIgnoreCase("ignore") || args[0].equalsIgnoreCase("unignore") ) {
  296.                     if (p.hasPermission("vippluschat.chat.ignore")) {
  297.                         if (detectChatID(args[1]) > -1) {
  298.                             int  chatID = detectChatID(args[1]);
  299.                             if (checkIgnoreChatSpecified(p.getName(), getCustomChats().getString(chatID + ".name"))) {
  300.                             if (getCustomChats().getBoolean(chatID + ".allow-ignore")) {
  301.                             if (args[0].equalsIgnoreCase("ignore")) {
  302.                             boolean b = false;
  303.                             reloadConfig();
  304.                             /* ---- Removed v0.8.2 when new black list system was added
  305.                             for (String a: getConfig().getString("Other.blacklist").split(",")) {
  306.                                 if (a.equalsIgnoreCase(p.getName())) {
  307.                                     pMessage(getConfig().getString("Messages.blacklist"), p);
  308.                                     return false;
  309.                                 }
  310.                             }
  311.                             */
  312.                             for (String a: getCustomChats().getString(chatID + ".ignore-list").split(",")) {
  313.                                 if (a.equalsIgnoreCase(p.getName())) {
  314.                                     b = true;
  315.                             }
  316.                         }
  317.                         if (!b) {
  318.                             if (getCustomChats().getString(chatID + ".ignore-list").equalsIgnoreCase("")) {
  319.                                 getCustomChats().set(chatID + ".ignore-list", p.getName().toLowerCase());
  320.                                 saveCustomConfig();
  321.                                 pMessage(ct(getConfig().getString("Messages.ignore").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")).replace("%STATUS%", "ignored").replace("%PLAYER%", p.getName())), p);
  322.                                 return true;
  323.                             } else {
  324.                                 getCustomChats().set(chatID + ".ignore-list", p.getName().toLowerCase() + "," + getConfig().getString(chatID + ".ignore-list".toLowerCase()));
  325.                                 saveCustomConfig();
  326.                                 pMessage(ct(getConfig().getString("Messages.ignore").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")).replace("%STATUS%", "ignored").replace("%PLAYER%", p.getName())), p);
  327.                                 return true;
  328.                             }
  329.                         } else {
  330.                             pMessage(ct(getConfig().getString("Messages.ignore-already").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")).replace("%STATUS%", "ignored").replace("%PLAYER%", p.getName())), p);
  331.                             return true;
  332.                         }
  333.                         } else {
  334.                             boolean b = false;
  335.                             String c = "";
  336.                             int d = 0;
  337.                             for (String a: getCustomChats().getString(chatID + ".ignore-list").split(",")) {
  338.                                 if (a.equalsIgnoreCase(p.getName())) {
  339.                                     b = true;
  340.                                 } else {
  341.                                     if (d == 0) {
  342.                                         d += 1;
  343.                                         c = a;
  344.                                     } else {
  345.                                         String e = c;
  346.                                         c = e + "," + a;
  347.                                     }
  348.                                 }
  349.                             }
  350.                             if (!b) {
  351.                                 pMessage(ct(getConfig().getString("Messages.ignore-not-found").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")).replace("%STATUS%", "unignored").replace("%PLAYER%", p.getName())), p);
  352.                                 return true;
  353.                             } else {
  354.                                 getCustomChats().set(chatID + ".ignore-list", c);
  355.                                 saveCustomConfig();
  356.                                 if (c.length() == 0) {
  357.                                     getCustomChats().set(chatID + ".ignore-list", "");
  358.                                     saveCustomConfig();
  359.                                 }
  360.                                
  361.                                 pMessage(ct(getConfig().getString("Messages.ignore").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")).replace("%STATUS%", "unignored").replace("%PLAYER%", p.getName())), p);
  362.                                 return true;
  363.                             }
  364.                         }
  365.                            
  366.                         } else {
  367.                             pMessage(getConfig().getString("Messages.ignore-disabled").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")),p);
  368.                         }
  369.                             } else {
  370.                                 pMessage("You are blacklisted from ignoring this chat.", p);   
  371.                             }
  372.                         } else {
  373.                             pMessage(ct(getConfig().getString("Messages.ignore-fail").replace("%CHAT_NAME%", getCustomChats().getString(detectChatID(args[1]) + ".name")).replace("%STATUS%", "unignored").replace("%PLAYER%", p.getName())), p);
  374.                         }
  375.                     } else {
  376.                         p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
  377.                     }
  378.                 }
  379.             }
  380.             //---- Ignore End
  381.            
  382.             //---- Get Ignore List - Added PRE v0.8 - /vpc ignored {chat} : {show/#/all}
  383.             if (cmdLabel.equalsIgnoreCase("vpc") &&  (args.length == 2|| args.length == 3)) {
  384.                 if (args[0].equalsIgnoreCase("ignored")) {
  385.                     if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.ignored")) {
  386.                         if (detectChatID(args[1]) > -1) {
  387.                             int chatID = detectChatID(args[1]);
  388.                             int page = 1;
  389.                             try {
  390.                                 page = Integer.parseInt(args[2]);
  391.                             } catch (NumberFormatException e) {
  392.                                 if (args[2].equalsIgnoreCase("all")) {
  393.                                     String[] ignoredlist = getCustomChats().getString(chatID + ".ignore-list").split(",");
  394.                                     double listLength = ignoredlist.length;
  395.                                     if (getCustomChats().getString(chatID + ".ignore-list").equalsIgnoreCase("")) {listLength = 0;}
  396.                                     pMessage(getConfig().getString("Messages.ignore-list").replace("%LIST%", getCustomChats().getString(chatID + ".ignore-list").replace(",", ", ")).replace("%COUNT%", String.valueOf(listLength).replace(".0", "") + ""), p);
  397.                                     return true;
  398.                                 } else if (args[2].equalsIgnoreCase("show")) {
  399.                                     page = 1;
  400.                                 } else {
  401.                                     return false;
  402.                                 }
  403.                            
  404.                             } catch (ArrayIndexOutOfBoundsException d) {
  405.                                
  406.                             }
  407.                             String[] ignorelist = getCustomChats().getString(chatID + ".ignore-list").split(",");
  408.                             String ignored = "";
  409.                             double listLength = ignorelist.length;
  410.                             double length = getConfig().getDouble("Other.ignored-length");
  411.                             double pages = Math.ceil((double)listLength/(double)length);
  412.                             int i = 1;
  413.                             for (String user : ignorelist) {
  414.                                 if (i < (getConfig().getInt("Other.ignored-length") * page)) {
  415.                                     if (i >= getConfig().getInt("Other.ignored-length") * (page - 1)) {
  416.                                         if (ignored.equalsIgnoreCase("")) {
  417.                                             ignored = user;
  418.                                         } else {
  419.                                             if (!user.equalsIgnoreCase("")) {
  420.                                                 ignored = user + ", " + ignored;
  421.                                             }
  422.                                         }
  423.                                     }
  424.                                 } else { break; }
  425.                                
  426.                                
  427.                                 i++;
  428.                             }
  429.                            
  430.                             if (getCustomChats().getString(chatID + ".ignore-list").equalsIgnoreCase("")) {listLength = 0;}
  431.                             ignored = ignored + " &8| &9Pages: " + page + "/" + String.valueOf(pages).replace(".0", "");
  432.                             pMessage(getConfig().getString("Messages.ignore-list").replace("%LIST%", ignored).replace("%COUNT%", String.valueOf(listLength).replace(".0", "") + "").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")), p);
  433.                             return true;
  434.                             /* ---- Removed when custom chats were added in v0.8.2
  435.                             pMessage(getConfig().getString("Messages.ignore-list").replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")).replace("%LIST%", getCustomChats().getString(chatID + ".ignore-list")), p);
  436.                                 return true;
  437.                                 */
  438.                         } else {
  439.                             pMessage(getConfig().getString("Messages.ignore-fail"), p);
  440.                             return true;
  441.                         }
  442.                     } else {
  443.                         p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
  444.                     }
  445.                 }
  446.             }
  447.            
  448.             //---- Toggle Chat - Added PRE v0.8 - /vpc toggle {chat} : {true/false}
  449.             if (cmdLabel.equalsIgnoreCase("vpc") && args.length == 2 || args.length == 3) {
  450.                 if(args[0].equalsIgnoreCase("toggle") && detectChatID(args[1]) > -1) {
  451.                     int chatID = detectChatID(args[1]);
  452.                     if (args.length == 2) {
  453.                         if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.toggle") || p.hasPermission("vippluschat.toggle." + getCustomChats().getString(chatID + ".permission"))) {
  454.                           if (getCustomChats().getBoolean(chatID + ".enabled")) {
  455.                               getCustomChats().set(chatID + ".enabled", false);
  456.                               saveCustomConfig();
  457.                               reloadChats();
  458.                             pMessage(getConfig().getString("Messages.toggle").replace("%CHAT_NAME%", getCustomChats().getString(detectChatID(args[1]) + ".name")).replace("%STATE%", "false"), p);
  459.                           } else {
  460.                               getCustomChats().set(chatID + ".enabled", true);
  461.                               saveCustomConfig();
  462.                               reloadChats();
  463.                             pMessage(getConfig().getString("Messages.toggle").replace("%CHAT_NAME%", getCustomChats().getString(detectChatID(args[1]) + ".name")).replace("%STATE%", "true"), p);
  464.                           }
  465.                           return true;
  466.                         } else {
  467.                             p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
  468.                             return false;
  469.                         }
  470.                     } else if (args.length == 3 ) {
  471.                         try{
  472.                            
  473.                             if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.toggle") || p.hasPermission("vippluschat.toggle." + getCustomChats().getString(chatID + ".permission"))) {  
  474.                                       boolean st = Boolean.valueOf(args[2]);
  475.                                       getCustomChats().set(chatID + ".enabled", st);
  476.                                       saveCustomConfig();
  477.                                       reloadChats();
  478.                                       pMessage(getConfig().getString("Messages.toggle").replace("%CHAT_NAME%", getCustomChats().getString(detectChatID(args[1]) + ".name")).replace("%STATE%", args[2]), p);
  479.                            
  480.                             } else {
  481.                                 p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
  482.                             }
  483.                             } catch (NullPointerException e){
  484.                                 pMessage(getConfig().getString("Messages.error"), p);
  485.                             }
  486.                             return true;
  487.                     }
  488.                    
  489.                 }
  490.             }
  491.             //---- End Toggle Chat
  492.            
  493.             //---- Blacklist Add/Rem/Del - Added 7/2/16 v0.8 - /vpc blacklist {+/add/del/rem/delete/remove/-/clear} {username}
  494.             if (cmdLabel.equalsIgnoreCase("vpc") && (args.length == 3 || args.length == 2)) {
  495.                 String blacklist = "";
  496.                 if (args[0].equalsIgnoreCase("blacklist")) {
  497.                     if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.blacklist")) {
  498.                         if (args[1].equalsIgnoreCase("clear")) {
  499.                             getConfig().set("Other.blacklist", "");
  500.                             saveConfig();
  501.                             if (getConfig().getBoolean("Other.broadcast")) {
  502.                                 Broadcast(getConfig().getString("Messages.remove-blacklisted").replace("%PLAYER%", "Everyone"));
  503.                                 return true;
  504.                             } else {
  505.                                 pMessage(getConfig().getString("Messages.remove-blacklisted").replace("%PLAYER%", "Everyone"), p);
  506.                                 return true;
  507.                             }
  508.                         }
  509.                         if (args[1].equalsIgnoreCase("add") || args[1].equalsIgnoreCase("+")) {
  510.                             if (!getConfig().getString("Other.blacklist").equalsIgnoreCase("")) {
  511.                                 blacklist = getConfig().getString("Other.blacklist");
  512.                             }
  513.                                 if (getConfig().getString("Other.blacklist").equalsIgnoreCase("")) {
  514.                                     getConfig().set("Other.blacklist", args[2]);
  515.                                     saveConfig();
  516.                                     forceUnIgnore(args[2], -1);
  517.                                 } else {
  518.                                     getConfig().set("Other.blacklist", args[2] + "," + blacklist);
  519.                                     saveConfig();
  520.                                     forceUnIgnore(args[2], -1);
  521.                                 }
  522.                                
  523.                                 //forceUnIgnore(args[2], -1);
  524.                                 if (getConfig().getBoolean("Other.broadcast")) {
  525.                                     Broadcast(getConfig().getString("Messages.blacklisted").replace("%PLAYER%", args[2]));
  526.                                     return true;
  527.                                 } else {
  528.                                     pMessage(getConfig().getString("Messages.blacklisted").replace("%PLAYER%", args[2]), p);
  529.                                     return true;
  530.                                 }
  531.                                    
  532.                         } else if (args[1].equalsIgnoreCase("rem") || args[1].equalsIgnoreCase("del") || args[1].equalsIgnoreCase("delete")|| args[1].equalsIgnoreCase("remove")|| args[1].equalsIgnoreCase("-") ) {
  533.                             if (!getConfig().getString("Other.blacklist").equalsIgnoreCase("")) {
  534.                                 blacklist = getConfig().getString("Other.blacklist");
  535.                             }
  536.                                 getConfig().set("Other.blacklist", blacklist.replace(args[2] + ",", "").replace(args[2], ""));
  537.                             saveConfig();
  538.                             if (getConfig().getBoolean("Other.broadcast")) {
  539.                                 Broadcast(getConfig().getString("Messages.remove-blacklisted").replace("%PLAYER%", args[2]));
  540.                                 return true;
  541.                             } else {
  542.                                 pMessage(getConfig().getString("Messages.remove-blacklisted").replace("%PLAYER%", args[2]), p);
  543.                                 return true;
  544.                             }
  545.                         } else if (args[1].equalsIgnoreCase("clear") & args[2].equalsIgnoreCase("all")) {
  546.                             getConfig().set("Other.blacklist", "");
  547.                             saveConfig();
  548.                             if (getConfig().getBoolean("Other.broadcast")) {
  549.                                 Broadcast(getConfig().getString("Messages.remove-blacklisted").replace("%PLAYER%", "all"));
  550.                                 return true;
  551.                             } else {
  552.                                 pMessage(getConfig().getString("Messages.remove-blacklisted").replace("%PLAYER%", "all"), p);
  553.                                 return true;
  554.                             }
  555.                         }
  556.                     } else {
  557.                         p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
  558.                     }
  559.                 }
  560.             }      
  561.             //---- End Blacklist Add/Rem/Del - /vpc blacklist {+/add/del/rem/delete/remove/-/clear} {username}
  562.            
  563.             //---- Remove Player Ignore - Added 7/2/16 v0.8 - /vpc {fui/forceunignore} {chat} {username}
  564.             if (cmdLabel.equalsIgnoreCase("vpc") && args.length == 3) {
  565.                 if (args[0].equalsIgnoreCase("fui") || (args[0].equalsIgnoreCase("forceunignore"))) {
  566.                     if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.forceunignore")) {
  567.                         if (detectChatID(args[1]) > -1) {
  568.                             int chatID = detectChatID(args[1]);
  569.                                     forceUnIgnore(args[2], chatID);                        
  570.                                 pMessage(getConfig().getString("Messages.force-unignore").replace("%PLAYER%", args[2]).replace("%CHAT_NAME%", getCustomChats().getString(chatID + ".name")), p);
  571.                         }
  572.                     } else {
  573.                         p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
  574.                     }
  575.                 }
  576.             }
  577.             //---- End Remove Player Ignore
  578.            
  579.             //---- Blacklisted - Added 7/2/16 v0.8 - /vpc blacklisted : {all/#/show}
  580.             if (cmdLabel.equalsIgnoreCase("vpc") && (args.length == 2 || args.length == 1)) {
  581.                 if (args[0].equalsIgnoreCase("blacklisted")) {
  582.                     if (p.hasPermission("vippluschat.admin") || p.hasPermission("vippluschat.admin.blacklisted")) {
  583.                         int page = 1;
  584.                         try {
  585.                             page = Integer.parseInt(args[1]);
  586.                         } catch (NumberFormatException e) {
  587.                             if (args[1].equalsIgnoreCase("all")) {
  588.                                 String[] blacklist = getConfig().getString("Other.blacklist").split(",");
  589.                                 double listLength = blacklist.length;
  590.                                 if (getConfig().getString("Other.blacklist").equalsIgnoreCase("")) {listLength = 0;}
  591.                                 pMessage(getConfig().getString("Messages.blacklisted-list").replace("%LIST%", getConfig().getString("Other.blacklist").replace(",", ", ")).replace("%COUNT%", String.valueOf(listLength).replace(".0", "") + ""), p);
  592.                                 return true;
  593.                             } else if (args[1].equalsIgnoreCase("show")) {
  594.                                 page = 1;
  595.                             } else {
  596.                                 return false;
  597.                             }
  598.                                
  599.                         } catch (ArrayIndexOutOfBoundsException d) {
  600.                            
  601.                         }
  602.                         String[] blacklist = getConfig().getString("Other.blacklist").split(",");
  603.                         String blacklisted = "";
  604.                         double listLength = blacklist.length;
  605.                         double length = getConfig().getDouble("Other.blacklisted-length");
  606.                         double pages = Math.ceil((double)listLength/(double)length);
  607.                         int i = 1;
  608.                         for (String user : blacklist) {
  609.                             if (i < (getConfig().getInt("Other.blacklisted-length") * page)) {
  610.                                 if (i >= getConfig().getInt("Other.blacklisted-length") * (page - 1)) {
  611.                                     if (blacklisted.equalsIgnoreCase("")) {
  612.                                         blacklisted = user;
  613.                                     } else {
  614.                                         if (!user.equalsIgnoreCase("")) {
  615.                                             blacklisted = user + ", " + blacklisted;
  616.                                         }
  617.                                     }
  618.                                 }
  619.                             } else { break; }
  620.                            
  621.                            
  622.                             i++;
  623.                         }
  624.                         if (getConfig().getString("Other.blacklist").equalsIgnoreCase("")) {listLength = 0;}
  625.                         blacklisted = blacklisted + " &8| &9Pages: " + page + "/" + String.valueOf(pages).replace(".0", "");
  626.                         pMessage(getConfig().getString("Messages.blacklisted-list").replace("%LIST%", blacklisted).replace("%COUNT%", String.valueOf(listLength).replace(".0", "") + ""), p);
  627.                         return true;
  628.                     } else {
  629.                         p.sendMessage(ct(getConfig().getString("Messages.no-permissions")));
  630.                     }
  631.                 }
  632.             }
  633.             //---- End Blacklisted
  634.            
  635.            
  636.         }
  637.         return false;
  638.     }
  639.    
  640.     //---- Toggle Color Codes - v0.8.2
  641.    
  642.     public boolean toggleColor(String code, int chatID) {
  643.         String[] color_codes = getCustomChats().getString(chatID + ".color-codes").split(" ");
  644.         for (String color : color_codes) {
  645.             if (color.equalsIgnoreCase(code + ":true")) {
  646.                 String theColors = "";
  647.                 for (String newColors : color_codes) {
  648.                     if (newColors.equalsIgnoreCase(code + ":true")) {
  649.                         if (theColors.equalsIgnoreCase("")) {
  650.                             theColors = newColors.replace("true", "false");
  651.                         } else {
  652.                             theColors = theColors + " " + newColors.replace("true", "false");
  653.                         }
  654.                     } else {
  655.                         if (theColors.equalsIgnoreCase("")) {
  656.                             theColors = newColors;
  657.                         } else {
  658.                             theColors = theColors + " " + newColors;
  659.                         }
  660.                     }
  661.                 }
  662.                 getCustomChats().set(chatID + ".color-codes", theColors);
  663.                 saveCustomConfig();
  664.                 reloadChats();
  665.                 return true;
  666.             } else if (color.equalsIgnoreCase(code + ":false")) {
  667.                 String theColors = "";
  668.                 for (String newColors : color_codes) {
  669.                     if (newColors.equalsIgnoreCase(code + ":false")) {
  670.                         if (theColors.equalsIgnoreCase("")) {
  671.                             theColors = newColors.replace("false", "true");
  672.                         } else {
  673.                             theColors = theColors + " " + newColors.replace("false", "true");
  674.                         }
  675.                     } else {
  676.                         if (theColors.equalsIgnoreCase("")) {
  677.                             theColors = newColors;
  678.                         } else {
  679.                             theColors = theColors + " " + newColors;
  680.                         }
  681.                     }
  682.                 }
  683.                 getCustomChats().set(chatID + ".color-codes", theColors);
  684.                 saveCustomConfig();
  685.                 reloadChats();
  686.                 return true;
  687.             }
  688.         }
  689.         return false;          
  690.     }
  691.    
  692.     //---- End Toggle Color Codes
  693.    
  694.     //---- Used to detect old configs and port them over to the new system - v0.8.2
  695.    
  696.     public void checkOldConfgAndPort() {
  697.         try {
  698.            
  699.             String a = getConfig().getString("Check Version");
  700.             String b = getConfig().getString("Tag.mod.allow-ignore");
  701.             if (b.equalsIgnoreCase("null")) {
  702.                 return;
  703.             }
  704.             File file = new File(getDataFolder(), "config.yml");
  705.             File file2 = new File(getDataFolder(), "oldConfig.yml");
  706.             file.renameTo(file2);
  707.             saveDefaultConfig();
  708.             reloadConfig();
  709.             reloadOld();
  710.             getConfig().set("Check Version", getOldConfig().getBoolean("Check Version"));
  711.             saveConfig();
  712.             getConfig().set("Other.blacklist",getOldConfig().getString("Other.ignore-blacklist").replaceAll("none", ""));
  713.             saveConfig();
  714.             getConfig().set("Messages.no-permission", getOldConfig().getString("Messages.no-permission"));
  715.             saveConfig();
  716.             getConfig().set("Messages.chat-disabled", getOldConfig().getString("Messages.chat-disabled"));
  717.             saveConfig();
  718.             getConfig().set("Messages.reload", getOldConfig().getString("Messages.reload"));
  719.             saveConfig();
  720.             getConfig().set("Messages.toggle" ,getOldConfig().getString("Messages.toggle"));
  721.             saveConfig();
  722.             getConfig().set("Messages.error", getOldConfig().getString("Messages.error"));
  723.             saveConfig();
  724.             getConfig().set("Messages.ignore", getOldConfig().getString("Messages.ignore"));
  725.             saveConfig();
  726.             getConfig().set("Messages.ignore-fail", getOldConfig().getString("Messages.ignore-fail"));
  727.             saveConfig();
  728.             getConfig().set("Messages.ignore-already", getOldConfig().getString("Messages.ignore-already"));
  729.             saveConfig();
  730.             getConfig().set("Messages.ignore-not-found", getOldConfig().getString("Messages.ignore-not-found"));
  731.             saveConfig();
  732.             getConfig().set("Messages.ignore-disabled", getOldConfig().getString("Messages.ignore-disabled"));
  733.             saveConfig();
  734.             getConfig().set("Messages.force-unignore", getOldConfig().getString("Messages.force-unignore").replace("%CHAT%", "%CHAT_NAME%"));
  735.             saveConfig();
  736.             getConfig().set("Messages.remove-blacklisted",getOldConfig().getString("Messages.remove-blacklisted"));
  737.             saveConfig();
  738.             getCustomChats().set("0.allow-ignore", getOldConfig().getBoolean("Tag.mod.allow-ignore"));
  739.             saveCustomConfig();
  740.             getCustomChats().set("0.layout" , getOldConfig().getString("Tag.mod.layout"));
  741.             saveCustomConfig();
  742.             getCustomChats().set("0.enabled" , getOldConfig().getBoolean("Enabled.Mod"));
  743.             saveCustomConfig();
  744.             getCustomChats().set("0.ignore-list" , getOldConfig().getString("Other.ignore.mod").replaceAll("none", ""));
  745.             saveCustomConfig();
  746.             getCustomChats().set("1.allow-ignore" , getOldConfig().getBoolean("Tag.admin.allow-ignore"));
  747.             saveCustomConfig();
  748.             getCustomChats().set("1.layout" , getOldConfig().getString("Tag.admin.layout"));
  749.             saveCustomConfig();
  750.             getCustomChats().set("1.enabled" , getOldConfig().getBoolean("Enabled.Admin"));
  751.             saveCustomConfig();
  752.             getCustomChats().set("1.ignore-list" , getOldConfig().getString("Other.ignore.admin").replaceAll("none", ""));
  753.             saveCustomConfig();
  754.             getCustomChats().set("2.allow-ignore" , getOldConfig().getBoolean("Tag.owner.allow-ignore"));
  755.             saveCustomConfig();
  756.             getCustomChats().set("2.layout" , getOldConfig().getString("Tag.owner.layout"));
  757.             saveCustomConfig();
  758.             getCustomChats().set("2.enabled" , getOldConfig().getBoolean("Enabled.Owner"));
  759.             saveCustomConfig();
  760.             getCustomChats().set("2.ignore-list" , getOldConfig().getString("Other.ignore.owner").replaceAll("none", ""));
  761.             saveCustomConfig();
  762.             getCustomChats().set("3.allow-ignore" , getOldConfig().getBoolean("Tag.staff.allow-ignore"));
  763.             saveCustomConfig();
  764.             getCustomChats().set("3.layout" , getOldConfig().getString("Tag.staff.layout"));
  765.             saveCustomConfig();
  766.             getCustomChats().set("3.enabled" , getOldConfig().getBoolean("Enabled.Staff"));
  767.             saveCustomConfig();
  768.             getCustomChats().set("3.ignore-list" , getOldConfig().getString("Other.ignore.staff").replaceAll("none", ""));
  769.             saveCustomConfig();
  770.             getCustomChats().set("4.allow-ignore" , getOldConfig().getBoolean("Tag.dev.allow-ignore"));
  771.             saveCustomConfig();
  772.             getCustomChats().set("4.layout" , getOldConfig().getString("Tag.dev.layout"));
  773.             saveCustomConfig();
  774.             getCustomChats().set("4.enabled" , getOldConfig().getBoolean("Enabled.Dev"));
  775.             saveCustomConfig();
  776.             getCustomChats().set("4.ignore-list" , getOldConfig().getString("Other.ignore.dev").replaceAll("none", ""));
  777.             saveCustomConfig();
  778.             getCustomChats().set("5.allow-ignore" , getOldConfig().getBoolean("Tag.vip.allow-ignore"));
  779.             saveCustomConfig();
  780.             getCustomChats().set("5.layout" , getOldConfig().getString("Tag.vip.layout"));
  781.             saveCustomConfig();
  782.             getCustomChats().set("5.enabled" , getOldConfig().getBoolean("Enabled.VIP"));
  783.             saveCustomConfig();
  784.             getCustomChats().set("5.ignore-list" , getOldConfig().getString("Other.ignore.vip").replaceAll("none", ""));
  785.             saveCustomConfig();
  786.             getCustomChats().set("6.allow-ignore" , getOldConfig().getBoolean("Tag.donator.allow-ignore"));
  787.             saveCustomConfig();
  788.             getCustomChats().set("6.layout" , getOldConfig().getString("Tag.donator.layout"));
  789.             saveCustomConfig();
  790.             getCustomChats().set("6.enabled" , getOldConfig().getBoolean("Enabled.Donator"));
  791.             saveCustomConfig();
  792.             getCustomChats().set("6.ignore-list" , getOldConfig().getString("Other.ignore.donator").replaceAll("none", ""));
  793.             saveCustomConfig();
  794.             getCustomChats().set("7.allow-ignore" , getOldConfig().getBoolean("Tag.special.allow-ignore"));
  795.             saveCustomConfig();
  796.             getCustomChats().set("7.layout" , getOldConfig().getString("Tag.special.layout"));
  797.             saveCustomConfig();
  798.             getCustomChats().set("7.enabled" , getOldConfig().getBoolean("Enabled.Special"));
  799.             saveCustomConfig();
  800.             getCustomChats().set("7.ignore-list" , getOldConfig().getString("Other.ignore.special").replaceAll("none", ""));
  801.             saveCustomConfig();
  802.             getCustomChats().set("8.allow-ignore" , getOldConfig().getBoolean("Tag.elite.allow-ignore"));
  803.             saveCustomConfig();
  804.             getCustomChats().set("8.layout" , getOldConfig().getString("Tag.elite.layout"));
  805.             saveCustomConfig();
  806.             getCustomChats().set("8.enabled" , getOldConfig().getBoolean("Enabled.Elite"));
  807.             saveCustomConfig();
  808.             getCustomChats().set("8.ignore-list" , getOldConfig().getString("Other.ignore.elite").replaceAll("none", ""));
  809.             saveCustomConfig();
  810.             File file3 = new File(getDataFolder(), "oldConfig.yml");
  811.             File file4 = new File(getDataFolder(), "oldConfig.yml.bak");
  812.             file3.renameTo(file4);
  813.         } catch (NullPointerException failed) {
  814.            
  815.         }
  816.     }
  817.    
  818.     //---- End Detect Old Config
  819.    
  820.     //---- Check and port configs to new config system! - v0.8.2
  821.    
  822.     public void portConfig() {
  823.     }
  824.    
  825.     //---- End Check and port configs to new config system!
  826.    
  827.     //---- Check black list to see if the player is on the blacklist - v0.8.2
  828.    
  829.     public boolean checkBlacklist(String player) {
  830.         List<String> blacklisted = Arrays.asList(getConfig().getString("Other.blacklist").split(","));
  831.         for (String p : blacklisted) {
  832.             if (p.toLowerCase().equalsIgnoreCase(player.toLowerCase())) {
  833.                 return true;
  834.             }
  835.         }
  836.         return false;
  837.     }
  838.    
  839.     //---- End blacklist check player
  840.        
  841.     //---- Check blacklist options to see if they can view chat - v0.8.2
  842.    
  843.     public boolean checkView(String player) {
  844.         if (checkBlacklist(player) & getConfig().getBoolean("Other.Blacklist-Settings.can-view-chats.enabled")) {
  845.             return true;
  846.         } else if (checkBlacklist(player) & !getConfig().getBoolean("Other.Blacklist-Settings.can-view-chats.enabled")){
  847.             return false;
  848.         }
  849.         return false;
  850.     }
  851.    
  852.     //---- End blacklist check options view chat
  853.            
  854.     //---- Check blacklist options to see if they can view chat is specified - v0.8.2
  855.    
  856.     public boolean checkViewChatSpecified(String player, String chat) {
  857.         if (checkBlacklist(player)) {
  858.             if (!getConfig().getBoolean("Other.Blacklist-Settings.can-view-chats.enabled")) {
  859.                 return true;
  860.             }
  861.             if (checkView(player)) {
  862.                 for (String c : getConfig().getStringList("Other.Blacklist-Settings.can-view-chats.specified-chats")) {
  863.                     if (c.toLowerCase().equalsIgnoreCase(chat.toLowerCase())) { return true; }
  864.                 }
  865.                 return false;
  866.             }
  867.         }
  868.        
  869.         return true;
  870.     }
  871.            
  872.     //---- End blacklist check options view chat if chat is specified
  873.        
  874.     //---- Check blacklist options to see if they can talk chat - v0.8.2
  875.  
  876.     public boolean checkTalk(String player) {
  877.         if (checkBlacklist(player) & getConfig().getBoolean("Other.Blacklist-Settings.can-talk-in-chats.enabled")) {
  878.             return true;
  879.         } else if (checkBlacklist(player) & !getConfig().getBoolean("Other.Blacklist-Settings.can-talk-in-chats.enabled")){
  880.             return false;
  881.         }
  882.         return false;
  883.     }
  884.    
  885.     //---- End blacklist check options talk chat
  886.  
  887.     //---- Check blacklist options to see if they can talk chat is specified - v0.8.2
  888.    
  889.     public boolean checkTalkChatSpecified(String player, String chat) {
  890.         if (checkBlacklist(player)) {
  891.             if (!getConfig().getBoolean("Other.Blacklist-Settings.can-talk-in-chats.enabled")) {
  892.                 return true;
  893.             }
  894.             if (checkTalk(player)) {
  895.                 for (String c : getConfig().getStringList("Other.Blacklist-Settings.can-talk-in-chats.specified-chats")) {
  896.                     if (c.toLowerCase().equalsIgnoreCase(chat.toLowerCase())) { return true; }
  897.                 }
  898.                 return false;
  899.             }
  900.         }
  901.        
  902.         return true;
  903.     }
  904.            
  905.     //---- End blacklist check options talk chat if chat is specified
  906.    
  907.     //---- Check ignore options to see if they can ignore chat - v0.8.2
  908.    
  909.     public boolean checkIgnore(String player) {
  910.         if (checkBlacklist(player.toLowerCase()) & getConfig().getBoolean("Other.Blacklist-Settings.can-ignore-chats.enabled")) {
  911.             return true;
  912.         } else if (checkBlacklist(player.toLowerCase()) & !getConfig().getBoolean("Other.Blacklist-Settings.can-ignore-chats.enabled")){
  913.             return false;
  914.         }
  915.         return false;
  916.     }
  917.    
  918.     //---- End ignore check options ignore chat
  919.        
  920.     //---- Check ignore options to see if they can ignore chat is specified - v0.8.2
  921.  
  922.     public boolean checkIgnoreChatSpecified(String player, String chat) {
  923.         if (checkBlacklist(player.toLowerCase())) {
  924.             if (!getConfig().getBoolean("Other.Blacklist-Settings.can-ignore-chats.enabled")) {
  925.                 return true;
  926.             }
  927.             if (checkIgnore(player.toLowerCase())) {
  928.                 for (String c : getConfig().getStringList("Other.Blacklist-Settings.can-ignore-chats.specified-chats")) {
  929.                     if (c.toLowerCase().equalsIgnoreCase(chat.toLowerCase())) { return true; }
  930.                 }
  931.                 return false;
  932.             }
  933.         }
  934.        
  935.         return true;
  936.     }
  937.    
  938.     //---- End ignore check options ignore chat if chat is specified
  939.    
  940.     //---- This is called when force unignoring chats. This was modified to accept custom chats in v0.8.2 - Created in v0.8
  941.     private void forceUnIgnore(String player, int id) {
  942.         if (id == -1) {
  943.             int i = 0;
  944.             if (player.equalsIgnoreCase("*")) {
  945.                 do {
  946.                     getCustomChats().set(i + ".ignore-list", "");
  947.                     saveCustomConfig();
  948.                 } while (i++ < getCustomChats().getInt("Chat Count") - 1);
  949.                
  950.             } else {
  951.                 do {
  952.                     getCustomChats().set(i + ".ignore-list", getCustomChats().getString(i + ".ignore-list").toLowerCase().replace(player.toLowerCase() + ",", "").replace(player.toLowerCase(), ""));
  953.                     saveCustomConfig();
  954.                 } while (i++ < getCustomChats().getInt("Chat Count") - 1);
  955.             }
  956.             return;
  957.         }
  958.         if (player.equalsIgnoreCase("*")) {
  959.             getCustomChats().set(id + ".ignore-list", "");
  960.             saveCustomConfig();
  961.         } else {
  962.             if (getCustomChats().getString(id + ".ignore-list").equalsIgnoreCase("")){
  963.                
  964.             } else {
  965.                 getCustomChats().set(id + ".ignore-list", getCustomChats().getString(id + ".ignore-list").toLowerCase().replace(player.toLowerCase() + ",", "").replace(player.toLowerCase(), ""));
  966.                 saveCustomConfig();
  967.                 if (getCustomChats().getString(id + ".ignore-list").equalsIgnoreCase("null")) {
  968.                     getCustomChats().set(id + ".ignore-list", "");
  969.                     saveCustomConfig();
  970.                 }
  971.             }
  972.         }
  973.        
  974.         /* - Removed v0.8.2 - Removed with when custom chats were added
  975.         switch (chat.toLowerCase()) {
  976.         case "mod":
  977.             getConfig().set("Other.ignore.mod", getConfig().getString("Other.ignore.mod").replace(a.getName() + ",", "").replace(a.getName(), ""));
  978.             saveConfig();
  979.             break;
  980.         case "all":
  981.             getConfig().set("Other.ignore.elite", getConfig().getString("Other.ignore.elite").replace(a.getName() + ",", "").replace(a.getName(), ""));
  982.             saveConfig();
  983.             getConfig().set("Other.ignore.special", getConfig().getString("Other.ignore.special").replace(a.getName() + ",", "").replace(a.getName(), ""));
  984.             saveConfig();
  985.             getConfig().set("Other.ignore.donator", getConfig().getString("Other.ignore.donator").replace(a.getName() + ",", "").replace(a.getName(), ""));
  986.             saveConfig();
  987.             getConfig().set("Other.ignore.vip", getConfig().getString("Other.ignore.vip").replace(a.getName() + ",", "").replace(a.getName(), ""));
  988.             saveConfig();
  989.             getConfig().set("Other.ignore.dev", getConfig().getString("Other.ignore.dev").replace(a.getName() + ",", "").replace(a.getName(), ""));
  990.             saveConfig();
  991.             getConfig().set("Other.ignore.staff", getConfig().getString("Other.ignore.staff").replace(a.getName() + ",", "").replace(a.getName(), ""));
  992.             saveConfig();
  993.             getConfig().set("Other.ignore.owner", getConfig().getString("Other.ignore.owner").replace(a.getName() + ",", "").replace(a.getName(), ""));
  994.             saveConfig();
  995.             getConfig().set("Other.ignore.admin", getConfig().getString("Other.ignore.admin").replace(a.getName() + ",", "").replace(a.getName(), ""));
  996.             saveConfig();
  997.             getConfig().set("Other.ignore.mod", getConfig().getString("Other.ignore.mod").replace(a.getName() + ",", "").replace(a.getName(), ""));
  998.             saveConfig();
  999.             break;
  1000.            
  1001.         }*/
  1002.     }
  1003.     //---- End forceunignore
  1004.     //---- Used to color not message chats - Added v0.7
  1005.     public static String ct(String text) {
  1006.         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 + "");
  1007.     }
  1008.     //---- End of color
  1009.     //---- Used to broadcast message - Added v0.7
  1010.     public static void Broadcast(String msg) {
  1011.         String tag = ct("&8[&9VPC&8] &2");
  1012.         Bukkit.getServer().broadcastMessage(tag + ct(msg));
  1013.     }
  1014.     //---- End of broad cast
  1015.     //---- Used to detect what colors are enabled for what chats. This was modified in v0.8.2 to accept custom chats
  1016.     public Boolean checkColorCodes(String code, int id) {
  1017.         System.out.println(code + " - End of list");
  1018.         for (String precolors: Arrays.asList(getCustomChats().getString(id + ".color-codes").split(" "))) {
  1019.             List<String> temp = Arrays.asList(precolors.split(":"));
  1020.             String colors = temp.get(0);
  1021.             Boolean colorsState = Boolean.parseBoolean(temp.get(1));
  1022.             if (colors.equalsIgnoreCase(code) && colorsState) {
  1023.                 return true;
  1024.             }
  1025.         }
  1026.         return false;
  1027.     }
  1028.     //---- End of color checking
  1029.     //---- Ingore Check
  1030.     public Boolean checkIgnore(String user, int id) {
  1031.         boolean b = false;
  1032.        
  1033.         for (String a: getCustomChats().getString(id + ".ignore-list").toLowerCase().split(",")) {
  1034.             if (a.equalsIgnoreCase(user)) {
  1035.                 b = true;
  1036.             }
  1037.         }
  1038.         if (b) {
  1039.             return true;
  1040.         }
  1041.         return false;
  1042.     }
  1043.     //---- Ignore Check End
  1044.    
  1045.     //---- Output Color Codes - Added v0.8.2
  1046.     public String outputColorCodes(int chatID) {
  1047.         String text = getCustomChats().getString(chatID + ".name") + " Current Color Code Status\n";
  1048.         int i = 0;
  1049.         for (String precolors: Arrays.asList(getCustomChats().getString(chatID + ".color-codes").split(" "))) {
  1050.             List<String> temp = Arrays.asList(precolors.split(":"));
  1051.             String colors = temp.get(0);
  1052.             Boolean colorsState = Boolean.parseBoolean(temp.get(1));
  1053.             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");}
  1054.             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");}
  1055.             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");}
  1056.             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");}
  1057.             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");}
  1058.             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");}
  1059.             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");}
  1060.             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");}
  1061.             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");}
  1062.             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");}
  1063.             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");}
  1064.             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");}
  1065.             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");}
  1066.             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");}
  1067.             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");}
  1068.             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");}
  1069.             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");}
  1070.             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");}
  1071.             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");}
  1072.             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");}
  1073.             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");}
  1074.             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");}
  1075.             i++;
  1076.         }
  1077.         return ct(text);
  1078.     }
  1079.     //---- End Output Color Codes
  1080.        
  1081.     //---- Used to send messages - Modified in v0.8.2 to accept custom chats
  1082.     public String chatCleaner(String text , int id) {
  1083.         if (text.contains("&0") && checkColorCodes("black", id) == true) { text = text.replace("&0", ChatColor.BLACK + ""); } else { text = text.replace("&0", "");}
  1084.         if (text.contains("&1") && checkColorCodes("dark_blue", id) == true) { text = text.replace("&1", ChatColor.DARK_BLUE + ""); } else { text = text.replace("&1", "");}
  1085.         if (text.contains("&2") && checkColorCodes("dark_green", id) == true) { text = text.replace("&2", ChatColor.DARK_GREEN + ""); } else { text = text.replace("&2", "");}
  1086.         if (text.contains("&3") && checkColorCodes("dark_aqua", id) == true) { text = text.replace("&3", ChatColor.DARK_AQUA + ""); } else { text = text.replace("&3", "");}
  1087.         if (text.contains("&4") && checkColorCodes("dark_red", id) == true) { text = text.replace("&4", ChatColor.DARK_RED + ""); } else { text = text.replace("&4", "");}
  1088.         if (text.contains("&5") && checkColorCodes("dark_purple", id) == true) { text = text.replace("&5", ChatColor.DARK_PURPLE + ""); } else { text = text.replace("&5", "");}
  1089.         if (text.contains("&6") && checkColorCodes("gold", id) == true) { text = text.replace("&6", ChatColor.GOLD + ""); } else { text = text.replace("&6", "");}
  1090.         if (text.contains("&7") && checkColorCodes("gray", id) == true) { text = text.replace("&7", ChatColor.GRAY + ""); } else { text = text.replace("&7", "");}
  1091.         if (text.contains("&8") && checkColorCodes("dark_gray", id) == true) { text = text.replace("&8", ChatColor.DARK_GRAY + ""); } else { text = text.replace("&8", "");}
  1092.         if (text.contains("&9") && checkColorCodes("blue", id) == true) { text = text.replace("&9", ChatColor.BLUE + ""); } else { text = text.replace("&9", "");}
  1093.         if (text.contains("&a") && checkColorCodes("green", id) == true) { text = text.replace("&a", ChatColor.GREEN + ""); } else { text = text.replace("&a", "");}
  1094.         if (text.contains("&b") && checkColorCodes("aqua", id) == true) { text = text.replace("&b", ChatColor.AQUA + ""); } else { text = text.replace("&b", "");}
  1095.         if (text.contains("&c") && checkColorCodes("red", id) == true) { text = text.replace("&c", ChatColor.RED + ""); } else { text = text.replace("&c", "");}
  1096.         if (text.contains("&d") && checkColorCodes("light_purple", id) == true) { text = text.replace("&d", ChatColor.LIGHT_PURPLE + ""); } else { text = text.replace("&d", "");}
  1097.         if (text.contains("&e") && checkColorCodes("yellow", id) == true) { text = text.replace("&e", ChatColor.YELLOW + ""); } else { text = text.replace("&e", "");}
  1098.         if (text.contains("&f") && checkColorCodes("white", id) == true) { text = text.replace("&f", ChatColor.WHITE + ""); } else { text = text.replace("&f", "");}
  1099.         if (text.contains("&k") && checkColorCodes("obfuscated", id) == true) { text = text.replace("&k", ChatColor.MAGIC + ""); } else { text = text.replace("&k", "");}
  1100.         if (text.contains("&l") && checkColorCodes("bold", id) == true) { text = text.replace("&l", ChatColor.BOLD + ""); } else { text = text.replace("&l", "");}
  1101.         if (text.contains("&m") && checkColorCodes("strikethrough", id) == true) { text = text.replace("&m", ChatColor.STRIKETHROUGH + ""); } else { text = text.replace("&m", "");}
  1102.         if (text.contains("&n") && checkColorCodes("underline", id) == true) { text = text.replace("&n", ChatColor.UNDERLINE + ""); } else { text = text.replace("&n", "");}
  1103.         if (text.contains("&o") && checkColorCodes("italic", id) == true) { text = text.replace("&o", ChatColor.ITALIC + ""); } else { text = text.replace("&o", "");}
  1104.         if (text.contains("&r") && checkColorCodes("reset", id) == true) { text = text.replace("&r", ChatColor.RESET + ""); } else { text = text.replace("&r", "");}
  1105.        
  1106.         return text;
  1107.     }
  1108.     public void pMessage(String msg, Player p) {
  1109.         p.sendMessage(ct("&8[&9VPC&8] &2" + msg));
  1110.     }
  1111.     public String pSend(String msg, Player p1, Player p2, String layout, int id) {
  1112.         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());
  1113.         /* - Removed v0.8.2 - Removed wheen we added the custom chats - 10/3/16
  1114.         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()); }
  1115.         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()); }
  1116.         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()); }
  1117.         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()); }
  1118.         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()); }
  1119.         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()); }
  1120.         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()); }
  1121.         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()); }
  1122.         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()); }
  1123.         */
  1124.         System.out.println(tag);
  1125.         p1.sendMessage(tag);
  1126.         return "";
  1127.     }
  1128.    
  1129.     @SuppressWarnings("deprecation")
  1130.     public void sendMessages(String msg, Player player, String permissin, String layout, int id) {
  1131.         if(player.hasPermission(permissin) && !checkIgnore(player.getName(), id)) {
  1132.             if (checkTalkChatSpecified(player.getName(), getCustomChats().getString(id + ".name").toLowerCase())) {
  1133.                 if (getCustomChats().getBoolean(id  + ".enabled")) {
  1134.                     for(Player p : Bukkit.getOnlinePlayers()) {
  1135.                         if(p.hasPermission(permissin) && !checkIgnore(p.getName(), id) && checkViewChatSpecified(p.getName().toLowerCase(), getCustomChats().getString(id + ".name").toLowerCase())) {
  1136.                             pSend(msg, p, player, layout, id); 
  1137.                         }
  1138.                     }
  1139.                 } else {
  1140.                     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);            
  1141.                 }
  1142.             } else {
  1143.                 pMessage("You are currently blacklisted from this chat and may not chat in this chat.", player);
  1144.             }
  1145.         } else {
  1146.             pMessage("You are currently ignoring this chat.", player);
  1147.         }
  1148.     }
  1149.    
  1150.     //---- End of sending messages
  1151.    
  1152.  // Added the ability to have a custom chats config! - v0.8.2 - 10/3/2016
  1153.     private FileConfiguration customChatsConfig = null; //customConfig
  1154.     private File customChats = null; //customConfigFile
  1155.    
  1156.    
  1157.     public void reloadChats() {
  1158.         if (customChats == null) {
  1159.             customChats = new File(getDataFolder(), "chat.yml");
  1160.         }
  1161.         customChatsConfig = YamlConfiguration.loadConfiguration(customChats);
  1162.         // Look for defaults in the jar
  1163.         Reader defConfigStream;
  1164.         try {
  1165.             defConfigStream = new InputStreamReader(this.getResource("chat.yml"), "UTF8");
  1166.        
  1167.         if (defConfigStream != null) {
  1168.             YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
  1169.             customChatsConfig.setDefaults(defConfig);
  1170.         }
  1171.         } catch (UnsupportedEncodingException e) {
  1172.             // TODO Auto-generated catch block
  1173.             e.printStackTrace();
  1174.         }
  1175.     }
  1176.    
  1177.     public FileConfiguration getCustomChats() {
  1178.         if (customChatsConfig == null) {
  1179.             reloadChats();
  1180.         }
  1181.         return customChatsConfig;
  1182.     }
  1183.    
  1184.     public void saveCustomConfig() {
  1185.         if (customChatsConfig == null || customChatsConfig == null) {
  1186.             return;
  1187.         }
  1188.         try {
  1189.             getCustomChats().save(customChats);
  1190.         } catch (IOException ex) {
  1191.             getLogger().log(Level.SEVERE, "Could not save config to " + customChats, ex);
  1192.         }
  1193.     }
  1194.    
  1195.     public void saveDefaultConfig() {
  1196.         if (customChats == null) {
  1197.             customChats = new File(getDataFolder(), "chat.yml");
  1198.         }
  1199.         if (!customChats.exists()) {            
  1200.              this.saveResource("chat.yml", false);
  1201.          }
  1202.     }
  1203.    
  1204.     //--- End of chats.yml writing tools
  1205.    
  1206.     private FileConfiguration oldConfig = null; //customConfig
  1207.     private File oldConfigFile = null; //customConfigFile
  1208.    
  1209.    
  1210.     public void reloadOld() {
  1211.         if (oldConfigFile == null) {
  1212.             oldConfigFile = new File(getDataFolder(), "oldConfig.yml");
  1213.         }
  1214.         oldConfig = YamlConfiguration.loadConfiguration(oldConfigFile);
  1215.         // Look for defaults in the jar
  1216.         Reader defConfigStream;
  1217.         try {
  1218.             defConfigStream = new InputStreamReader(this.getResource("oldConfig.yml"), "UTF8");
  1219.        
  1220.         if (defConfigStream != null) {
  1221.             YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
  1222.             oldConfig.setDefaults(defConfig);
  1223.         }
  1224.         } catch (UnsupportedEncodingException e) {
  1225.             // TODO Auto-generated catch block
  1226.             e.printStackTrace();
  1227.         }
  1228.     }
  1229.    
  1230.     public FileConfiguration getOldConfig() {
  1231.         if (oldConfig == null) {
  1232.             reloadOld();
  1233.         }
  1234.         return oldConfig;
  1235.     }
  1236.    
  1237.     public void saveOldConfig() {
  1238.         if (oldConfig == null || oldConfig == null) {
  1239.             return;
  1240.         }
  1241.         try {
  1242.             getOldConfig().save(oldConfigFile);
  1243.         } catch (IOException ex) {
  1244.             getLogger().log(Level.SEVERE, "Could not save config to " + oldConfigFile, ex);
  1245.         }
  1246.     }
  1247.    
  1248. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement