vminecraftListener.java 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. protected static final Logger log = Logger.getLogger("Minecraft");
  10. //=====================================================================
  11. //Function: disable
  12. //Input: None
  13. //Output: None
  14. //Use: Disables vminecraft, but why would you want to do that? ;)
  15. //=====================================================================
  16. public void disable() {
  17. log.log(Level.INFO, "vminecraft disabled");
  18. }
  19. //=====================================================================
  20. //Function: onChat
  21. //Input: Player player: The player calling the command
  22. // String message: The message to color
  23. //Output: boolean: If the user has access to the command
  24. // and it is enabled
  25. //Use: Checks for quote, rage, and colors
  26. //=====================================================================
  27. public boolean onChat(Player player, String message){
  28. //Quote (Greentext)
  29. if (message.startsWith(">"))
  30. vminecraftChat.quote(player, message);
  31. //Rage (FFF)
  32. else if (message.startsWith("FFF"))
  33. vminecraftChat.rage(player, message);
  34. //Send through quakeColors otherwise
  35. else
  36. vminecraftChat.quakeColors(player, message);
  37. return false;
  38. }
  39. //=====================================================================
  40. //Function: onCommand
  41. //Input: Player player: The player calling the command
  42. // String[] split: The arguments
  43. //Output: boolean: If the user has access to the command
  44. // and it is enabled
  45. //Use: Checks for exploits and runs the commands
  46. //=====================================================================
  47. public boolean onCommand(Player player, String[] split) {
  48. //Explot fix on /modify
  49. if(split[0].equals("/modify") && split[2].equals("commands")) {
  50. return false;
  51. }
  52. //Copy the arguments into their own array.
  53. String[] args = new String[split.length - 1];
  54. System.arraycopy(split, 1, args, 0, args.length);
  55. //Return the results of the command
  56. return vminecraftCommands.cl.call(split[0], player, args);
  57. }
  58. //=====================================================================
  59. //Function: onHealthChange
  60. //Input: Player player: The player calling the command
  61. // int oldValue: The old health value;
  62. // int newValue: The new health value
  63. //Output: boolean: If the user has access to the command
  64. // and it is enabled
  65. //Use: Checks for exploits and runs the commands
  66. //=====================================================================
  67. public boolean onHealthChange(Player player,int oldValue,int newValue){
  68. if (player.getHealth() != vminecraftSettings.getInstance().ezModoHealth() && vminecraftSettings.getInstance().isEzModo(player.getName())) {
  69. player.setHealth(vminecraftSettings.getInstance().ezModoHealth());
  70. }
  71. else if (vminecraftSettings.getInstance().globalmessages() && player.getHealth() < 1) {
  72. vminecraftChat.gmsg(Colors.Gray + player.getName() + " is no more");
  73. }
  74. return false;
  75. }
  76. }