vmc.java 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import java.io.*;
  2. import java.lang.String;
  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. int x = 0;
  49. if(vConfig.getInstance().groupcoloredbrackets()){
  50. //Read the file
  51. properties = new PropertiesFile(location);
  52. try {
  53. properties.load();
  54. } catch (IOException e) {
  55. log.log(Level.SEVERE, "Exception while loading " + location, e);
  56. }
  57. //Grab the line with the same group as the player
  58. for(String herp : groups){
  59. x++;
  60. }
  61. if(x > 0)
  62. groupline = properties.getString(groups[0]).split(":");
  63. //Check if the prefix is null or not
  64. if(!groupline[0].isEmpty())
  65. {
  66. //vChat.colorChange(groupline[0].charAt(0));
  67. prefix = groupline[0];
  68. prefix = vChat.colorChange(prefix.charAt(0));
  69. }
  70. }
  71. return prefix;
  72. }
  73. public static vmc getInstance() {
  74. if (instance == null) {
  75. instance = new vmc();
  76. }
  77. return instance;
  78. }
  79. }