diff --git a/vCom.java b/vCom.java index 1cc521410..2995e188b 100644 --- a/vCom.java +++ b/vCom.java @@ -272,24 +272,22 @@ private static HashMap hidden = new HashMap(); } } public static int party(Player player, String[] args){ - if(vUsers.getProfile(player).inParty() && args.length > 1){ + if(!vUsers.getProfile(player).inParty() && args.length == 0){ + player.sendMessage(Colors.Red + "Correct usage is /party [partyname]"); + return EXIT_SUCCESS; + } + if((vUsers.getProfile(player).inParty()) && (args.length > 0)){ player.sendMessage(Colors.Red + "You are already in a party, use /pquit to leave it"); return EXIT_SUCCESS; } if(vUsers.getProfile(player).inParty()){ - int x = 0; - String partymembers[] = null; - for(Player p : etc.getServer().getPlayerList()){ - if(vmc.inSameParty(player, p)){ - partymembers[x] = p.getName(); - x++; - } - } - player.sendMessage(Colors.Green + "Party Members: " + partymembers); + player.sendMessage(Colors.Green + "Party Members: " + vmc.getInstance().getPartyMembers(player)); + return EXIT_SUCCESS; } if(args[0] != null) { vUsers.getProfile(player).setParty(args[0]); player.sendMessage(Colors.DarkPurple + "Party set to " + args[0]); + vmc.informPartyMembers(player); return EXIT_SUCCESS; } else { player.sendMessage(Colors.Red + "Correct usage is /party [partyname]"); @@ -298,6 +296,7 @@ private static HashMap hidden = new HashMap(); } public static int partyquit(Player player, String[] args){ if(vUsers.getProfile(player).inParty()){ + vmc.informPartyMembersQuit(player); vUsers.getProfile(player).removeParty(); player.sendMessage(Colors.LightGreen + "Party successfully removed"); return EXIT_SUCCESS; diff --git a/vmc.java b/vmc.java index 4eb13aae7..9dc4f95fc 100644 --- a/vmc.java +++ b/vmc.java @@ -1,5 +1,6 @@ import java.io.*; import java.lang.String; +import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; public class vmc { @@ -41,6 +42,37 @@ String location = "groups.txt"; } } } + public String[] getPartyMembers(Player player){ + int x = 0; + String partyarray[] = null; + ArrayList partymembers = new ArrayList(); + for(Player p : etc.getServer().getPlayerList()){ + if(vmc.inSameParty(player, p) && p != null){ + partymembers.add(p.getName()); + x++; + } + } + partymembers.toArray(partyarray); + return partyarray; + } + public static void informPartyMembers(Player player){ + int x = 0; + for(Player p : etc.getServer().getPlayerList()){ + if(vmc.inSameParty(player, p) && !p.getName().equals(player.getName())){ + p.sendMessage(vUsers.getProfile(player).getTag() + player.getName() + Colors.Green + " has joined your party"); + x++; + } + } + } + public static void informPartyMembersQuit(Player player){ + int x = 0; + for(Player p : etc.getServer().getPlayerList()){ + if(vmc.inSameParty(player, p) && !p.getName().equals(player.getName())){ + p.sendMessage(vUsers.getProfile(player).getTag() + player.getName() + Colors.Green + " has left your party"); + x++; + } + } + } public String getGroupPrefix(Player player){ String groups[] = player.getGroups(); String groupline[] = null; @@ -56,12 +88,13 @@ String location = "groups.txt"; } //Grab the line with the same group as the player for(String herp : groups){ + if(herp != null) x++; } - if(x > 0) + if(x != 0) groupline = properties.getString(groups[0]).split(":"); //Check if the prefix is null or not - if(!groupline[0].isEmpty()) + if(!groupline[0].isEmpty() && groupline != null) { //vChat.colorChange(groupline[0].charAt(0)); prefix = groupline[0];