2
0

vMinecraftListener.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import java.util.logging.Level;
  2. import java.util.logging.Logger;
  3. //=====================================================================
  4. //Class: vMinecraftListener
  5. //Use: The listener to catch incoming chat and commands
  6. //Author: nossr50, TrapAlice, cerevisiae
  7. //=====================================================================
  8. public class vMinecraftListener extends PluginListener {
  9. public int bAttacker;
  10. public int bDefender;
  11. public int bAmount;
  12. protected static final Logger log = Logger.getLogger("Minecraft");
  13. //=====================================================================
  14. //Function: disable
  15. //Input: None
  16. //Output: None
  17. //Use: Disables vMinecraft, but why would you want to do that? ;)
  18. //=====================================================================
  19. public void disable() {
  20. log.log(Level.INFO, "vMinecraft disabled");
  21. }
  22. //=====================================================================
  23. //Function: onChat
  24. //Input: Player player: The player calling the command
  25. // String message: The message to color
  26. //Output: boolean: If the user has access to the command
  27. // and it is enabled
  28. //Use: Checks for quote, rage, and colors
  29. //=====================================================================
  30. public boolean onChat(Player player, String message){
  31. //Quote (Greentext)
  32. if (message.startsWith("@") ||
  33. vMinecraftSettings.getInstance().isAdminToggled(player.getName()))
  34. return vMinecraftChat.adminChat(player, message);
  35. else if (message.startsWith(">"))
  36. return vMinecraftChat.quote(player, message);
  37. //Rage (FFF)
  38. else if (message.startsWith("FFF"))
  39. return vMinecraftChat.rage(player, message);
  40. //Send through quakeColors otherwise
  41. else
  42. return vMinecraftChat.quakeColors(player, message);
  43. }
  44. //=====================================================================
  45. //Function: onCommand
  46. //Input: Player player: The player calling the command
  47. // String[] split: The arguments
  48. //Output: boolean: If the user has access to the command
  49. // and it is enabled
  50. //Use: Checks for exploits and runs the commands
  51. //=====================================================================
  52. public boolean onCommand(Player player, String[] split) {
  53. //Copy the arguments into their own array.
  54. String[] args = new String[split.length - 1];
  55. System.arraycopy(split, 1, args, 0, args.length);
  56. //Return the results of the command
  57. int exitCode = vMinecraftCommands.cl.call(split[0], player, args);
  58. if(exitCode == 0)
  59. return false;
  60. else if(exitCode == 1)
  61. return true;
  62. else
  63. return false;
  64. }
  65. //=====================================================================
  66. //Function: onHealthChange
  67. //Input: Player player: The player calling the command
  68. // int oldValue: The old health value;
  69. // int newValue: The new health value
  70. //Output: boolean: If the user has access to the command
  71. // and it is enabled
  72. //Use: Checks for exploits and runs the commands
  73. //=====================================================================
  74. public boolean onHealthChange(Player player,int oldValue,int newValue){
  75. if (vMinecraftSettings.getInstance().isEzModo(player.getName())) {
  76. return oldValue > newValue;
  77. }
  78. if (vMinecraftSettings.getInstance().globalmessages() && newValue < 1) {
  79. vMinecraftChat.gmsg(player, Colors.Gray + player.getName() + " " + vMinecraftSettings.randomDeathMsg());
  80. }
  81. return false;
  82. }
  83. public void onLogin(Player player){
  84. vMinecraftUsers.addUser(player);
  85. }
  86. public boolean onDamage(PluginLoader.DamageType type, BaseEntity attacker, BaseEntity defender, int amount) {
  87. bAttacker = attacker.getId();
  88. bDefender = defender.getId();
  89. bAmount = amount;
  90. log.log(Level.INFO, "Attacker ID: " + bAttacker + ", Defender ID: " + bDefender + ", Amount: " + bAmount);
  91. return false;
  92. }
  93. }