vminecraftListener.java 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. //Explot fix on /modify
  50. if(split[0].equals("/modify") && split[2].equals("commands")) {
  51. return false;
  52. }
  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. return vminecraftCommands.cl.call(split[0], player, args);
  58. }
  59. //=====================================================================
  60. //Function: onHealthChange
  61. //Input: Player player: The player calling the command
  62. // int oldValue: The old health value;
  63. // int newValue: The new health value
  64. //Output: boolean: If the user has access to the command
  65. // and it is enabled
  66. //Use: Checks for exploits and runs the commands
  67. //=====================================================================
  68. public boolean onHealthChange(Player player,int oldValue,int newValue){
  69. if (player.getHealth() != vminecraftSettings.getInstance().ezModoHealth() && vminecraftSettings.getInstance().isEzModo(player.getName())) {
  70. player.setHealth(vminecraftSettings.getInstance().ezModoHealth());
  71. }
  72. else if (vminecraftSettings.getInstance().globalmessages() && player.getHealth() < 1) {
  73. vminecraftChat.gmsg(Colors.Gray + player.getName() + " " + vminecraftSettings.randomDeathMsg());
  74. }
  75. return false;
  76. }
  77. /** Not working yet, I posted the issue to hMod on github though
  78. public boolean onDamage(DamageType type, BaseEntity attacker, BaseEntity defender, int amount) {
  79. return false;
  80. }
  81. **/
  82. }