vminecraftListener.java 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. return vminecraftChat.adminChat(player, message);
  31. else if (message.startsWith(">"))
  32. return vminecraftChat.quote(player, message);
  33. //Rage (FFF)
  34. else if (message.startsWith("FFF"))
  35. return vminecraftChat.rage(player, message);
  36. //Send through quakeColors otherwise
  37. else
  38. return vminecraftChat.quakeColors(player, message);
  39. }
  40. //=====================================================================
  41. //Function: onCommand
  42. //Input: Player player: The player calling the command
  43. // String[] split: The arguments
  44. //Output: boolean: If the user has access to the command
  45. // and it is enabled
  46. //Use: Checks for exploits and runs the commands
  47. //=====================================================================
  48. public boolean onCommand(Player player, String[] split) {
  49. //Copy the arguments into their own array.
  50. String[] args = new String[split.length - 1];
  51. System.arraycopy(split, 1, args, 0, args.length);
  52. //Return the results of the command
  53. int exitCode = vminecraftCommands.cl.call(split[0], player, args);
  54. if(exitCode == 0)
  55. return false;
  56. else if(exitCode == 1)
  57. return true;
  58. else
  59. return false;
  60. }
  61. //=====================================================================
  62. //Function: onHealthChange
  63. //Input: Player player: The player calling the command
  64. // int oldValue: The old health value;
  65. // int newValue: The new health value
  66. //Output: boolean: If the user has access to the command
  67. // and it is enabled
  68. //Use: Checks for exploits and runs the commands
  69. //=====================================================================
  70. public boolean onHealthChange(Player player,int oldValue,int newValue){
  71. if (player.getHealth() != vminecraftSettings.getInstance().ezModoHealth() && vminecraftSettings.getInstance().isEzModo(player.getName())) {
  72. player.setHealth(vminecraftSettings.getInstance().ezModoHealth());
  73. }
  74. else if (vminecraftSettings.getInstance().globalmessages() && player.getHealth() < 1) {
  75. vminecraftChat.gmsg(Colors.Gray + player.getName() + " " + vminecraftSettings.randomDeathMsg());
  76. }
  77. return false;
  78. }
  79. /** Not working yet, I posted the issue to hMod on github though
  80. public boolean onDamage(DamageType type, BaseEntity attacker, BaseEntity defender, int amount) {
  81. return false;
  82. }
  83. **/
  84. }