vmc.java 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import java.io.*;
  2. import java.util.ArrayList;
  3. import java.util.logging.Level;
  4. import java.util.logging.Logger;
  5. public class vmc {
  6. private static volatile vmc instance;
  7. protected static final Logger log = Logger.getLogger("Minecraft");
  8. private PropertiesFile properties;
  9. String location = "groups.txt";
  10. //Check if two players are in the same party
  11. public static boolean inSameParty(Player playera, Player playerb){
  12. if(vUsers.getProfile(playera).getParty().equals(vUsers.getProfile(playerb).getParty())){
  13. return true;
  14. } else {
  15. return false;
  16. }
  17. }
  18. //Get the distance between two players
  19. public static double getDistance(Player player1, Player player2)
  20. {
  21. return Math.sqrt(Math.pow(player1.getX() - player2.getX(), 2) + Math.pow(player1.getY() - player2.getY(), 2)
  22. + Math.pow(player1.getZ() - player2.getZ(), 2));
  23. }
  24. //Send the "invisibility" toggle to players near the hidden player
  25. public static void sendInvisible(Player player){
  26. for (Player p : etc.getServer().getPlayerList())
  27. {
  28. if (getDistance(player, p) <= vConfig.range && p.getUser() != player.getUser())
  29. {
  30. p.getUser().a.b(new dv(player.getUser().g));
  31. }
  32. }
  33. }
  34. //Send "visibility" toggle to invisible players turning them back to normal
  35. public static void sendNotInvisible(Player player){
  36. for (Player p : etc.getServer().getPlayerList())
  37. {
  38. if (getDistance(player, p) < vConfig.range && p.getUser() != player.getUser())
  39. {
  40. p.getUser().a.b(new d(player.getUser()));
  41. }
  42. }
  43. }
  44. public String getGroupPrefix(Player player){
  45. String groups[] = player.getGroups();
  46. String groupline[] = null;
  47. String prefix = Colors.White;
  48. if(vConfig.getInstance().groupcoloredbrackets()){
  49. //Read the file
  50. properties = new PropertiesFile(location);
  51. try {
  52. properties.load();
  53. } catch (IOException e) {
  54. log.log(Level.SEVERE, "Exception while loading " + location, e);
  55. }
  56. //Grab the line with the same group as the player
  57. if(!groups[0].isEmpty())
  58. groupline = properties.getString(groups[0]).split(":");
  59. //Check if the prefix is null or not
  60. if(groupline[0] != null)
  61. {
  62. //vChat.colorChange(groupline[0].charAt(0));
  63. prefix = groupline[0];
  64. prefix = vChat.colorChange(prefix.charAt(0));
  65. }
  66. }
  67. return prefix;
  68. }
  69. public static vmc getInstance() {
  70. if (instance == null) {
  71. instance = new vmc();
  72. }
  73. return instance;
  74. }
  75. }