vmc.java 2.8 KB

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