McMMOChatEvent.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package com.gmail.nossr50.events.chat;
  2. import org.bukkit.event.Cancellable;
  3. import org.bukkit.event.Event;
  4. import org.bukkit.event.HandlerList;
  5. import org.bukkit.plugin.Plugin;
  6. public abstract class McMMOChatEvent extends Event implements Cancellable {
  7. private boolean cancelled;
  8. private Plugin plugin;
  9. private String sender;
  10. private String displayName;
  11. private String message;
  12. protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message) {
  13. this.plugin = plugin;
  14. this.sender = sender;
  15. this.displayName = displayName;
  16. this.message = message;
  17. }
  18. /**
  19. * @return The plugin responsible for this event, note this can be null
  20. */
  21. public Plugin getPlugin() {
  22. return plugin;
  23. }
  24. /**
  25. * @return String name of the player who sent the chat, or "Console"
  26. */
  27. public String getSender() {
  28. return sender;
  29. }
  30. /**
  31. * @return String display name of the player who sent the chat, or "Console"
  32. */
  33. public String getDisplayName() {
  34. return displayName;
  35. }
  36. /**
  37. * @return String message that will be sent
  38. */
  39. public String getMessage() {
  40. return message;
  41. }
  42. /**
  43. * @param displayName String display name of the player who sent the chat
  44. */
  45. public void setDisplayName(String displayName) {
  46. this.displayName = displayName;
  47. }
  48. /**
  49. * @param message String message to be sent in chat
  50. */
  51. public void setMessage(String message) {
  52. this.message = message;
  53. }
  54. /** Rest of file is required boilerplate for custom events **/
  55. private static final HandlerList handlers = new HandlerList();
  56. @Override
  57. public HandlerList getHandlers() {
  58. return handlers;
  59. }
  60. public static HandlerList getHandlerList() {
  61. return handlers;
  62. }
  63. /** Following are required for Cancellable **/
  64. @Override
  65. public boolean isCancelled() {
  66. return cancelled;
  67. }
  68. @Override
  69. public void setCancelled(boolean cancelled) {
  70. this.cancelled = cancelled;
  71. }
  72. }