diff --git a/vMinecraftChat.java b/vMinecraftChat.java index fa7e9e32b..9b7a6fd42 100644 --- a/vMinecraftChat.java +++ b/vMinecraftChat.java @@ -448,6 +448,20 @@ public class vMinecraftChat { } return false; } + public static boolean partyChat(Player player, String message){ + if(vMinecraftUsers.getProfile(player).inParty()){ + String partychat = Colors.Green + "(" + getName(player) + Colors.Green + ") "; + for (Player p: etc.getServer().getPlayerList()){ + if (p != null){ + if (vMinecraftUsers.getProfile(p).inParty() && (vMinecraftUsers.getProfile(p).getParty().equals(vMinecraftUsers.getProfile(player).getParty()))){ + sendMessage(player, p, partychat + message); + } + } + } + return true; + } + return false; + } //===================================================================== //Function: quote diff --git a/vMinecraftCommands.java b/vMinecraftCommands.java index ef8cae536..95b8dd821 100644 --- a/vMinecraftCommands.java +++ b/vMinecraftCommands.java @@ -53,6 +53,11 @@ public class vMinecraftCommands{ cl.register("/who", "who"); cl.register("/promote", "promote", "Promote a player one rank"); cl.register("/demote", "demote", "Demote a player one rank"); + + //Party + cl.register("/party", "party"); + cl.register("/pquit", "partyquit"); + cl.register("/p", "partychat"); //Movement cl.register("/freeze", "freeze"); @@ -179,6 +184,39 @@ public class vMinecraftCommands{ .globalmessages()); return EXIT_SUCCESS; } + public static int partychat(Player player, String[] args){ + if(vMinecraftUsers.getProfile(player).inParty()){ + String message = args.toString(); + vMinecraftChat.partyChat(player, message); + return EXIT_SUCCESS; + } else{ + return EXIT_FAIL; + } + } + public static int party(Player player, String[] args){ + if(vMinecraftUsers.getProfile(player).inParty()){ + player.sendMessage(Colors.Red + "You are already in a party, use /pquit to leave it"); + return EXIT_SUCCESS; + } + if(args[0] != null) { + vMinecraftUsers.getProfile(player).setParty(args[0]); + player.sendMessage(Colors.DarkPurple + "Party set to " + args[0]); + return EXIT_SUCCESS; + } else { + player.sendMessage(Colors.Red + "Correct usage is /party [partyname]"); + return EXIT_SUCCESS; + } + } + public static int partyquit(Player player, String[] args){ + if(vMinecraftUsers.getProfile(player).inParty()){ + vMinecraftUsers.getProfile(player).removeParty(); + player.sendMessage(Colors.LightGreen + "Party successfully removed"); + return EXIT_SUCCESS; + } else { + player.sendMessage(Colors.Red + "You are not in a party"); + return EXIT_SUCCESS; + } + } public static int tpback(Player player, String[] args){ if(player.canUseCommand("/tpback")){ String tpxyz = vMinecraftUsers.getProfile(player).getTpxyz(); diff --git a/vMinecraftListener.java b/vMinecraftListener.java index e122b7b60..17c3f903f 100644 --- a/vMinecraftListener.java +++ b/vMinecraftListener.java @@ -162,10 +162,20 @@ public class vMinecraftListener extends PluginListener { //Invincibility for EzModo players if(defender.isPlayer()){ Player dplayer = defender.getPlayer(); - if(vMinecraftSettings.getInstance().isEzModo(dplayer.getName())){ - return true; - } + if(vMinecraftSettings.getInstance().isEzModo(dplayer.getName())){ + return true; + } + if(attacker.isPlayer()){ + Player aplayer = attacker.getPlayer(); + if(vMinecraftUsers.getProfile(dplayer).inParty()){ + if(vMinecraftParty.inSameParty(aplayer, dplayer)){ + return true; + } else{ + return false; + } + } + } } return false; } -} \ No newline at end of file +} diff --git a/vMinecraftParty.java b/vMinecraftParty.java new file mode 100644 index 000000000..cd0ab3367 --- /dev/null +++ b/vMinecraftParty.java @@ -0,0 +1,12 @@ +import java.util.ArrayList; +public class vMinecraftParty { + + //Check if two players are in the same party + public static boolean inSameParty(Player playera, Player playerb){ + if(vMinecraftUsers.getProfile(playera).getParty().equals(vMinecraftUsers.getProfile(playerb).getParty())){ + return true; + } else { + return false; + } + } +} diff --git a/vMinecraftSettings.java b/vMinecraftSettings.java index 7c8ed09a3..32a1e2391 100644 --- a/vMinecraftSettings.java +++ b/vMinecraftSettings.java @@ -52,7 +52,8 @@ public class vMinecraftSettings { //An array of players currently toggled for admin chat static ArrayList adminChatList = new ArrayList(); //An array of blocks that won't catch on fire - static public ArrayList fireblockan; + static public ArrayList fireblockan; + private PropertiesFile properties; String file = "vminecraft.properties"; diff --git a/vMinecraftUsers.java b/vMinecraftUsers.java index 96f6f6ac0..be96ec1df 100644 --- a/vMinecraftUsers.java +++ b/vMinecraftUsers.java @@ -153,6 +153,7 @@ class PlayerList nickName, tag, suffix, + party, tpxyz; private boolean dead; @@ -183,6 +184,8 @@ class PlayerList nickName = new String(); suffix = new String(); tpxyz = new String(); + party = new String(); + party = null; defaultColor = 'f'; ignoreList = new ArrayList(); aliasList = new commandList(); @@ -505,6 +508,27 @@ class PlayerList nickName = newNick; save(); } + //Store the player's party + public void setParty(String newParty) + { + party = newParty; + save(); + } + //Retrieve the player's party + public String getParty() {return party;} + //Remove party + public void removeParty() { + party = null; + save(); + } + //Retrieve whether or not the player is in a party + public boolean inParty() { + if(party != null){ + return true; + } else { + return false; + } + } //===================================================================== //Function: getNick