From 2bf3a6c1cdd44a8e112cf08cc1a283a09505bdb6 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 30 Nov 2010 16:02:24 -0800 Subject: [PATCH] Added admin chat toggle, also added shortcut for clearinvetory to be /ci --- vminecraftChat.java | 29 ++++++-- vminecraftCommands.java | 148 ++++++---------------------------------- vminecraftListener.java | 2 + vminecraftSettings.java | 9 +++ 4 files changed, 57 insertions(+), 131 deletions(-) diff --git a/vminecraftChat.java b/vminecraftChat.java index f49eb2db8..026892dc2 100644 --- a/vminecraftChat.java +++ b/vminecraftChat.java @@ -79,7 +79,7 @@ public class vminecraftChat { //and their following color codes for(int x = 0; x " + message); + return true; + } + return false; + } //===================================================================== //Function: quote @@ -381,8 +400,8 @@ public class vminecraftChat { //Loop through looking for a color code for(int x = 0; x< msg.length(); x++) { - //If the char is a ^ or § - if(msg.charAt(x) == '^' || msg.charAt(x) == '§') + //If the char is a ^ or � + if(msg.charAt(x) == '^' || msg.charAt(x) == '�') { if(x != msg.length() - 1) { @@ -445,8 +464,8 @@ public class vminecraftChat { //Loop through looking for a color code for(int x = 0; x< message.length(); x++) { - //If the char is a ^ or § - if(message.charAt(x) == '^' || message.charAt(x) == '§') + //If the char is a ^ or � + if(message.charAt(x) == '^' || message.charAt(x) == '�') { if(x != message.length() - 1) { diff --git a/vminecraftCommands.java b/vminecraftCommands.java index 8fc3a7e62..9020fe39d 100644 --- a/vminecraftCommands.java +++ b/vminecraftCommands.java @@ -38,16 +38,33 @@ public class vminecraftCommands{ cl.register("/slay", "slay", "Kill target player"); cl.register("/ezmodo", "invuln", "Toggle invulnerability"); cl.register("/ezlist", "ezlist", "List invulnerable players"); - cl.register("/heal", "heal", "heal yourself or other players"); cl.register("/suicide", "suicide", "kill yourself... you loser"); - + cl.register("/a", "adminChatToggle", "toggle admin chat for every message"); cl.register("/modify", "modifySplit"); - cl.registerAlias("/playerlist", "/who"); cl.registerAlias("/wrists", "/suicide"); + cl.registerAlias("/ci", "/clearinventory"); } - +public static int adminChatToggle(Player player, String[] args) +{ + if(vminecraftSettings.getInstance().adminChatToggle()) + { + if (vminecraftSettings.getInstance().cmdAdminToggle) { + //If the player is already toggled for admin chat, remove them + if (vminecraftSettings.getInstance().isAdminToggled(player.getName())) { + player.sendMessage(Colors.Red + "Admin Chat Toggle = off"); + vminecraftSettings.getInstance().removeAdminToggled(player.getName()); + //Otherwise include them + } else { + player.sendMessage(Colors.Blue + "Admin Chat Toggled on"); + vminecraftSettings.getInstance().addAdminToggled(player.getName()); + } + return EXIT_SUCCESS; + } + } + return EXIT_FAIL; +} //===================================================================== //Function: heal (/heal) //Input: Player player: The player using the command @@ -516,130 +533,9 @@ public class vminecraftCommands{ public static int timeReverse(long tarTime) { long curTime = etc.getServer().getRelativeTime(); - if(cur) + //if(cur) return EXIT_SUCCESS; } - - - - //Disable using /modify to add commands (need to make a boolean settings for this) - - //ezlist -//ezmodo - - - /* - //Promote - if (vminecraftSettings.getInstance().cmdPromote() && split[0].equalsIgnoreCase("/promote")) { -if(split.length != 2) -{ - player.sendMessage(Colors.Rose + "Usage is /promote [Player]"); - -} - -Player playerTarget = null; - if(split.length==2){ -for( Player p : etc.getServer().getPlayerList()) -{ - if (p.getName().equalsIgnoreCase(split[1])) - { - playerTarget = p; - } -} - -if( playerTarget!=null) -{ - String playerTargetGroup[] = playerTarget.getGroups(); - String playerGroup[] = player.getGroups(); - player.sendMessage("Debug data:"); - player.sendMessage("PlayerTarget: "+playerTargetGroup[0]); - player.sendMessage("Player: "+playerGroup[0]); - if(playerTargetGroup[0].equals("admins")) - { - player.sendMessage(Colors.Rose + "You can not promote " + split[1] + " any higher."); - } - if(playerTargetGroup[0].equals("mods") && (playerGroup[0].equals("owner"))) - { - playerTarget.setGroups(ranks.Admins); - etc.getInstance().getDataSource().modifyPlayer(playerTarget); - String message = Colors.Yellow + split[1] + " was promoted to" + Colors.Rose + " Admin"; - other.gmsg(message); - } - else if (playerTargetGroup[0].equals("trusted") && (playerGroup[0].equals("admins") || playerGroup[0].equals("owner"))) - { - playerTarget.setGroups(ranks.Mods); - playerTargetGroup[0]="Mods"; - etc.getInstance().getDataSource().modifyPlayer(playerTarget); - String message = Colors.Yellow + split[1] + " was promoted to" + Colors.DarkPurple + " Mod"; - other.gmsg(message); - } - else if (playerTargetGroup[0].equals("default") && (playerGroup[0].equals("mods") || playerGroup[0].equals("admins") || player.isInGroup("owner"))) - { - playerTarget.setGroups(ranks.Trusted); - etc.getInstance().getDataSource().modifyPlayer(playerTarget); - String message = Colors.Yellow + split[1] + " was promoted to" + Colors.LightGreen + " Trusted"; - other.gmsg(message); - } - return true; -} -else{ - player.sendMessage(Colors.Rose + "Player not found"); -} -log.log(Level.INFO, "Command used by " + player + " " + split[0] +" "+split[1]+" "); -} - } - //Demote - if (vminecraftSettings.getInstance().cmdPromote() && split[0].equalsIgnoreCase("/promote")) -{ -if(split.length != 2) -{ - player.sendMessage(Colors.Rose + "Usage is /demote [Player]"); -} - -Player playerTarget = null; - -for( Player p : etc.getServer().getPlayerList()) -{ - if (p.getName().equalsIgnoreCase(split[1])) - { - playerTarget = p; - } -} - -if( playerTarget!=null) -{ - if(playerTarget.isInGroup("admins") && (player.isInGroup("superadmins"))) - { - playerTarget.setGroups(ranks.Mods); - etc.getInstance().getDataSource().modifyPlayer(playerTarget); - String message = Colors.Yellow + split[1] + " was demoted to" + Colors.DarkPurple + " Mod"; - other.gmsg(message); - } - if(playerTarget.isInGroup("mods") && (player.isInGroup("admins") || player.isInGroup("superadmins"))) - { - playerTarget.setGroups(ranks.Trusted); - etc.getInstance().getDataSource().modifyPlayer(playerTarget); - String message = Colors.Yellow + split[1] + " was demoted to" + Colors.LightGreen + " Trusted"; - other.gmsg(message); - } - else if (playerTarget.isInGroup("trusted") && (player.isInGroup("mods") || player.isInGroup("superadmins") || player.isInGroup("admins"))) - { - playerTarget.setGroups(ranks.Def); - etc.getInstance().getDataSource().modifyPlayer(playerTarget); - String message = Colors.Yellow + split[1] + " was demoted to" + Colors.White + " Default"; - other.gmsg(message); - } - else if (playerTarget.isInGroup("default") && (player.isInGroup("mods") || player.isInGroup("admins") || player.isInGroup("superadmins"))) - { - player.sendMessage(Colors.Rose + "You can not demote " + split[1] + " any lower."); - } -} -else{ - player.sendMessage(Colors.Rose + "Player not found"); -} -log.log(Level.INFO, "Command used by " + player + " " + split[0] +" "+split[1]+" "); - return true; -}*/ } //===================================================================== diff --git a/vminecraftListener.java b/vminecraftListener.java index 319ebc8e9..0bf545c1d 100644 --- a/vminecraftListener.java +++ b/vminecraftListener.java @@ -31,6 +31,8 @@ public class vminecraftListener extends PluginListener { //Quote (Greentext) if (message.startsWith("@")) return vminecraftChat.adminChat(player, message); + if (vminecraftSettings.getInstance().isAdminToggled(player.getName())) + return vminecraftChat.adminChatToggle(player, message); else if (message.startsWith(">")) return vminecraftChat.quote(player, message); diff --git a/vminecraftSettings.java b/vminecraftSettings.java index 04c145ee5..177bca7ea 100644 --- a/vminecraftSettings.java +++ b/vminecraftSettings.java @@ -34,9 +34,12 @@ public class vminecraftSettings { stopTnt = false, cmdHeal = false, cmdSuicide = false, + cmdAdminToggle = false, cmdEzModo = false; //An array of players currently in ezmodo static ArrayList ezModo = new ArrayList(); + //An array of players currently toggled for admin chat + static ArrayList adminChatList = new ArrayList(); //The max health for ezModo static int ezHealth = 30; @@ -76,6 +79,7 @@ public class vminecraftSettings { writer.write("cmdTp=true\r\n"); writer.write("cmdRules=true\r\n"); writer.write("cmdSuicide=true\r\n"); + writer.write("cmdAdminToggle=true\r\n"); writer.write("globalmessages=true\r\n"); writer.write("FFF=true\r\n"); writer.write("adminchat=true\r\n"); @@ -126,6 +130,7 @@ public class vminecraftSettings { cmdTphere = properties.getBoolean("cmdTphere",true); cmdSuicide = properties.getBoolean("cmdSuicide", true); cmdHeal = properties.getBoolean("cmdHeal",true); + cmdAdminToggle = properties.getBoolean("cmdAdminToggle", true); globalmessages = properties.getBoolean("globalmessages",true); cmdSay = properties.getBoolean("cmdSay",true); cmdEzModo = properties.getBoolean("cmdEzModo",true); @@ -158,6 +163,7 @@ public class vminecraftSettings { //Use: Returns if the feature is enabled //===================================================================== public boolean adminchat() {return adminChat;} + public boolean adminChatToggle() {return cmdAdminToggle;} public boolean greentext() {return greentext;} public boolean FFF() {return FFF;} public boolean quakeColors() {return quakeColors;} @@ -180,8 +186,11 @@ public class vminecraftSettings { //EzModo methods public boolean cmdEzModo() {return cmdEzModo;} public boolean isEzModo(String playerName) {return ezModo.contains(playerName);} + public boolean isAdminToggled(String playerName) {return adminChatList.contains(playerName);} public void removeEzModo(String playerName) {ezModo.remove(ezModo.indexOf(playerName));} + public void removeAdminToggled(String playerName) {adminChatList.remove(adminChatList.indexOf(playerName));} public void addEzModo(String playerName) {ezModo.add(playerName);} + public void addAdminToggled(String playerName) {adminChatList.add(playerName);} public int ezModoHealth() {return ezHealth;} public String ezModoList() {return ezModo.toString();}