2011-01-09 21:35:06 +01:00
|
|
|
import java.io.*;
|
2011-01-10 20:18:38 +01:00
|
|
|
import java.lang.String;
|
2011-01-10 21:08:07 +01:00
|
|
|
import java.util.ArrayList;
|
2011-01-09 21:35:06 +01:00
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
2011-01-05 17:20:42 +01:00
|
|
|
public class vmc {
|
2011-01-09 21:35:06 +01:00
|
|
|
private static volatile vmc instance;
|
|
|
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
|
|
|
private PropertiesFile properties;
|
|
|
|
String location = "groups.txt";
|
2011-01-05 17:20:42 +01:00
|
|
|
//Check if two players are in the same party
|
|
|
|
public static boolean inSameParty(Player playera, Player playerb){
|
|
|
|
if(vUsers.getProfile(playera).getParty().equals(vUsers.getProfile(playerb).getParty())){
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Get the distance between two players
|
|
|
|
public static double getDistance(Player player1, Player player2)
|
|
|
|
{
|
|
|
|
return Math.sqrt(Math.pow(player1.getX() - player2.getX(), 2) + Math.pow(player1.getY() - player2.getY(), 2)
|
|
|
|
+ Math.pow(player1.getZ() - player2.getZ(), 2));
|
|
|
|
}
|
|
|
|
//Send the "invisibility" toggle to players near the hidden player
|
|
|
|
public static void sendInvisible(Player player){
|
|
|
|
for (Player p : etc.getServer().getPlayerList())
|
|
|
|
{
|
2011-01-09 21:35:06 +01:00
|
|
|
if (getDistance(player, p) <= vConfig.range && p.getUser() != player.getUser())
|
2011-01-05 17:20:42 +01:00
|
|
|
{
|
|
|
|
p.getUser().a.b(new dv(player.getUser().g));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Send "visibility" toggle to invisible players turning them back to normal
|
|
|
|
public static void sendNotInvisible(Player player){
|
|
|
|
for (Player p : etc.getServer().getPlayerList())
|
|
|
|
{
|
2011-01-09 21:35:06 +01:00
|
|
|
if (getDistance(player, p) < vConfig.range && p.getUser() != player.getUser())
|
2011-01-05 17:20:42 +01:00
|
|
|
{
|
|
|
|
p.getUser().a.b(new d(player.getUser()));
|
|
|
|
}
|
|
|
|
}
|
2011-01-09 21:35:06 +01:00
|
|
|
}
|
2011-01-10 21:08:07 +01:00
|
|
|
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++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-09 21:35:06 +01:00
|
|
|
public String getGroupPrefix(Player player){
|
|
|
|
String groups[] = player.getGroups();
|
|
|
|
String groupline[] = null;
|
|
|
|
String prefix = Colors.White;
|
2011-01-10 20:18:38 +01:00
|
|
|
int x = 0;
|
2011-01-10 23:37:24 +01:00
|
|
|
if(groups.length == 0 || groups == null)
|
|
|
|
return prefix;
|
2011-01-10 20:18:38 +01:00
|
|
|
if(vConfig.getInstance().groupcoloredbrackets()){
|
2011-01-09 21:35:06 +01:00
|
|
|
//Read the file
|
|
|
|
properties = new PropertiesFile(location);
|
|
|
|
try {
|
|
|
|
properties.load();
|
|
|
|
} catch (IOException e) {
|
|
|
|
log.log(Level.SEVERE, "Exception while loading " + location, e);
|
|
|
|
}
|
|
|
|
//Grab the line with the same group as the player
|
2011-01-10 20:18:38 +01:00
|
|
|
for(String herp : groups){
|
2011-01-10 21:08:07 +01:00
|
|
|
if(herp != null)
|
2011-01-10 20:18:38 +01:00
|
|
|
x++;
|
|
|
|
}
|
2011-01-10 23:37:24 +01:00
|
|
|
if(x > 0)
|
2011-01-09 21:35:06 +01:00
|
|
|
groupline = properties.getString(groups[0]).split(":");
|
|
|
|
//Check if the prefix is null or not
|
2011-01-10 21:08:07 +01:00
|
|
|
if(!groupline[0].isEmpty() && groupline != null)
|
2011-01-09 21:35:06 +01:00
|
|
|
{
|
|
|
|
//vChat.colorChange(groupline[0].charAt(0));
|
|
|
|
prefix = groupline[0];
|
|
|
|
prefix = vChat.colorChange(prefix.charAt(0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return prefix;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static vmc getInstance() {
|
|
|
|
if (instance == null) {
|
|
|
|
instance = new vmc();
|
|
|
|
}
|
|
|
|
return instance;
|
|
|
|
}
|
2011-01-05 17:20:42 +01:00
|
|
|
}
|