Changes to the party system

This commit is contained in:
nossr50 2011-01-10 12:08:07 -08:00
parent 03f73a0353
commit 25e9d7afcf
2 changed files with 44 additions and 12 deletions

View File

@ -272,24 +272,22 @@ private static HashMap<String, Player> hidden = new HashMap<String, Player>();
}
}
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<String, Player> hidden = new HashMap<String, Player>();
}
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;

View File

@ -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<String> partymembers = new ArrayList<String>();
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];