mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-04-04 18:56:23 +02:00
Abstract the chat events a bit.
This commit is contained in:
parent
b512fe2003
commit
c265aad6d7
@ -1,62 +1,11 @@
|
|||||||
package com.gmail.nossr50.events.chat;
|
package com.gmail.nossr50.events.chat;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a chat is sent to the admin chat channel
|
* Called when a chat is sent to the admin chat channel
|
||||||
*/
|
*/
|
||||||
public class McMMOAdminChatEvent extends Event implements Cancellable {
|
public class McMMOAdminChatEvent extends McMMOChatEvent{
|
||||||
private boolean cancelled;
|
|
||||||
private String sender, message;
|
|
||||||
|
|
||||||
public McMMOAdminChatEvent(String sender, String message) {
|
public McMMOAdminChatEvent(String sender, String message) {
|
||||||
this.sender = sender;
|
super(sender, message);
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return String name of the player who sent the chat, or "Console"
|
|
||||||
*/
|
|
||||||
public String getSender() {
|
|
||||||
return sender;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return String message that will be sent
|
|
||||||
*/
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param message String message to be sent in chat
|
|
||||||
*/
|
|
||||||
public void setMessage(String message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Rest of file is required boilerplate for custom events **/
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Following are required for Cancellable **/
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancelled) {
|
|
||||||
this.cancelled = cancelled;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.gmail.nossr50.events.chat;
|
||||||
|
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class McMMOChatEvent extends Event implements Cancellable{
|
||||||
|
private boolean cancelled;
|
||||||
|
private String sender;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public McMMOChatEvent(String sender, String message) {
|
||||||
|
this.sender = sender;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return String name of the player who sent the chat, or "Console"
|
||||||
|
*/
|
||||||
|
public String getSender() {
|
||||||
|
return sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return String message that will be sent
|
||||||
|
*/
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message String message to be sent in chat
|
||||||
|
*/
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Rest of file is required boilerplate for custom events **/
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Following are required for Cancellable **/
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancelled) {
|
||||||
|
this.cancelled = cancelled;
|
||||||
|
}
|
||||||
|
}
|
@ -1,27 +1,14 @@
|
|||||||
package com.gmail.nossr50.events.chat;
|
package com.gmail.nossr50.events.chat;
|
||||||
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a chat is sent to a party channel
|
* Called when a chat is sent to a party channel
|
||||||
*/
|
*/
|
||||||
public class McMMOPartyChatEvent extends Event implements Cancellable {
|
public class McMMOPartyChatEvent extends McMMOChatEvent{
|
||||||
private boolean cancelled;
|
private String party;
|
||||||
private String sender, party, message;
|
|
||||||
|
|
||||||
public McMMOPartyChatEvent(String sender, String party, String message) {
|
public McMMOPartyChatEvent(String sender, String party, String message) {
|
||||||
this.sender = sender;
|
super(sender, message);
|
||||||
this.party = party;
|
this.party = party;
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return String name of the player who sent the chat, or "Console"
|
|
||||||
*/
|
|
||||||
public String getSender() {
|
|
||||||
return sender;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,41 +17,4 @@ public class McMMOPartyChatEvent extends Event implements Cancellable {
|
|||||||
public String getParty() {
|
public String getParty() {
|
||||||
return party;
|
return party;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return String message that will be sent
|
|
||||||
*/
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param message String message to be sent in chat
|
|
||||||
*/
|
|
||||||
public void setMessage(String message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Rest of file is required boilerplate for custom events **/
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Following are required for Cancellable **/
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancelled) {
|
|
||||||
this.cancelled = cancelled;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user