diff --git a/vChat.java b/vChat.java index b8e02172b..c001c4e8e 100644 --- a/vChat.java +++ b/vChat.java @@ -294,7 +294,7 @@ public class vChat { output = player.getName(); //Add the color if there is one - if(player.getColor() != null && player.getColor() != "") + if(player.getColor() != null && !"".equals(player.getColor())) output = player.getColor().substring(0,2) + output; //Add the tag if there is one @@ -448,6 +448,10 @@ public class vChat { return false; } public static boolean partyChat(Player player, String message){ + if(vConfig.getInstance().partyChat()){ + //Cut off the ! prefix + if(message.startsWith("!")) + message = message.substring(1, message.length()); if(vUsers.getProfile(player).inParty()){ String partychat = Colors.Green + "(" + getName(player) + Colors.Green + ") "; for (Player p: etc.getServer().getPlayerList()){ @@ -459,7 +463,9 @@ public class vChat { } return true; } + } return false; + } //===================================================================== diff --git a/vCom.java b/vCom.java index 0c3759ba2..add3f4c6e 100644 --- a/vCom.java +++ b/vCom.java @@ -67,7 +67,7 @@ private static HashMap hidden = new HashMap(); //Party cl.register("/party", "party"); cl.register("/pquit", "partyquit"); - cl.register("/p", "partychat"); + cl.register("/p", "partyChatToggle", "Toggles party chat on or off"); //Movement cl.register("/freeze", "freeze"); @@ -269,19 +269,6 @@ private static HashMap hidden = new HashMap(); } } } - public static int partychat(Player player, String[] args){ - if (args.length < 1) { - player.sendMessage(Colors.Rose + "Usage is /p [Message]"); - return EXIT_SUCCESS; - } - if(vUsers.getProfile(player).inParty()){ - String str = etc.combineSplit(0, args, " "); - vChat.partyChat(player, str); - return EXIT_SUCCESS; - } else{ - return EXIT_FAIL; - } - } public static int party(Player player, String[] args){ if(vUsers.getProfile(player).inParty()){ player.sendMessage(Colors.Red + "You are already in a party, use /pquit to leave it"); @@ -1057,7 +1044,29 @@ private static HashMap hidden = new HashMap(); } return EXIT_FAIL; } - + //Party chat toggle + public static int partyChatToggle(Player player, String[] args) + { + //Check if party chat is even enabled befor executing anymore code + if(!vConfig.getInstance().partyChat()) return EXIT_FAIL; + //Check if the player is admin toggled, and if so remove them from that array + if(vConfig.getInstance().isAdminToggled(player.getName())){ + vConfig.getInstance().removeAdminToggled(player.getName()); + } + //Make sure the user has access to the command + if(!player.canUseCommand("/p")) return EXIT_FAIL; + + //If the player is already toggled for admin chat, remove them + if (vConfig.getInstance().isPartyToggled(null)) { + player.sendMessage(Colors.Red + "Party Chat Toggle = off"); + vConfig.getInstance().removeAdminToggled(player.getName()); + //Otherwise include them + } else { + player.sendMessage(Colors.Blue + "Party Chat Toggled on"); + vConfig.getInstance().addAdminToggled(player.getName()); + } + return EXIT_SUCCESS; + } //===================================================================== //Function: adminChatToggle (/a) //Input: Player player: The player using the command @@ -1068,6 +1077,10 @@ private static HashMap hidden = new HashMap(); //===================================================================== public static int adminChatToggle(Player player, String[] args) { + //Check if the player is party toggled, and if so remove them from that array + if(vConfig.getInstance().isPartyToggled(player.getName())){ + vConfig.getInstance().removePartyToggled(player.getName()); + } //Make sure the user has access to the command if(!player.canUseCommand("/a")) return EXIT_FAIL; diff --git a/vConfig.java b/vConfig.java index 548d7ff3a..9eff5907c 100644 --- a/vConfig.java +++ b/vConfig.java @@ -18,6 +18,7 @@ public class vConfig { //The feature settings static boolean toggle = true, adminChat = false, + partyChat = false, greentext = false, FFF = false, quakeColors = false, @@ -52,6 +53,8 @@ public class vConfig { static ArrayList frozenplayers = new ArrayList(); //An array of players currently toggled for admin chat static ArrayList adminChatList = new ArrayList(); + //An array of player currently toggled for party chat + static ArrayList partyChatList = new ArrayList(); //An array of blocks that won't catch on fire static public ArrayList fireblockan; @@ -140,6 +143,8 @@ public class vConfig { writer.write("rules=Rules@#1: No griefing@#2: No griefing\r\n"); writer.write("#The Random Death messages, seperate them by comma. All death messages start with the player name and a space.\r\n"); writer.write("deathMessages=is no more,died horribly,went peacefully\r\n"); + writer.write("#Enable whether or not players can toggle party chat"); + writer.write("partychat=true"); writer.write("hiddendistance=1024"); } catch (Exception e) { log.log(Level.SEVERE, "Exception while creating " + location, e); @@ -164,6 +169,7 @@ public class vConfig { try { adminChat = properties.getBoolean("adminchat",true); + partyChat = properties.getBoolean("partychat",true); playerspawn = properties.getBoolean("playerspawn",true); greentext = properties.getBoolean("QuotesAreGreen",true); FFF = properties.getBoolean("FFF",true); @@ -223,6 +229,7 @@ public class vConfig { //Use: Returns if the feature is enabled //===================================================================== public boolean adminchat() {return adminChat;} + public boolean partyChat() {return partyChat;} public boolean adminChatToggle() {return cmdAdminToggle;} public boolean greentext() {return greentext;} public boolean FFF() {return FFF;} @@ -258,9 +265,12 @@ public class vConfig { public boolean isEzModo(String playerName) {return ezModo.contains(playerName);} public boolean isFrozen(String playerName) {return frozenplayers.contains(playerName);} public boolean isAdminToggled(String playerName) {return adminChatList.contains(playerName);} + public boolean isPartyToggled(String playerName) {return partyChatList.contains(playerName);} public void removeEzModo(String playerName) {ezModo.remove(ezModo.indexOf(playerName));} + public void removePartyToggled(String playerName) {partyChatList.remove(partyChatList.indexOf(playerName));} public void removeAdminToggled(String playerName) {adminChatList.remove(adminChatList.indexOf(playerName));} public void addEzModo(String playerName) {ezModo.add(playerName);} + public void addPartyToggled(String playerName) {partyChatList.add(playerName);} public void addAdminToggled(String playerName) {adminChatList.add(playerName);} public void addFrozen(String playerName) {frozenplayers.add(playerName);} public void removeFrozen (String playerName) {frozenplayers.remove(frozenplayers.indexOf(playerName));} diff --git a/vListener.java b/vListener.java index 9c2cd88bd..13c709b8f 100644 --- a/vListener.java +++ b/vListener.java @@ -35,18 +35,19 @@ public class vListener extends PluginListener { public boolean onChat(Player player, String message){ - //Quote (Greentext) if (message.startsWith("@") || vConfig.getInstance().isAdminToggled(player.getName())) return vChat.adminChat(player, message); - + //PartyChat + if((message.startsWith("!")) || + vConfig.getInstance().isPartyToggled(player.getName())) + return vChat.partyChat(player, message); + //Quote (Greentext) else if (message.startsWith(">")) - return vChat.quote(player, message); - + return vChat.quote(player, message); //Rage (FFF) else if (message.startsWith("FFF")) return vChat.rage(player, message); - //Send through quakeColors otherwise else return vChat.quakeColors(player, message); @@ -163,16 +164,22 @@ public class vListener extends PluginListener { public boolean onDamage(PluginLoader.DamageType type, BaseEntity attacker, BaseEntity defender, int amount) { //Invincibility for EzModo players + //This also checks if the defender is a player if(defender.isPlayer()){ Player dplayer = defender.getPlayer(); if(vConfig.getInstance().isEzModo(dplayer.getName())){ return true; } + //So far we've checked if the defender is a player, next we check if the attacker is one if(attacker != null && attacker.isPlayer()){ + //If the attacker is not null and is a player we assign the attacker to a new player variable Player aplayer = attacker.getPlayer(); + //Then we preceed to check if they are in the same party, the code for this is stored elsewhere if(vUsers.getProfile(dplayer).inParty()){ + //If they are in the same party we tell onDamage to return true stopping the damage code from executing if(vmc.inSameParty(aplayer, dplayer)){ return true; + //if they aren't we tell it to return false, making the damage happen } else{ return false; }