expanding the abstraction again...

This commit is contained in:
nossr50 2019-02-13 09:12:53 -08:00
parent 261d571be1
commit 9383b1c65c
8 changed files with 36 additions and 19 deletions

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.core.chat; package com.gmail.nossr50.core.chat;
import com.gmail.nossr50.core.McmmoCore;
import com.gmail.nossr50.core.config.Config; import com.gmail.nossr50.core.config.Config;
import com.gmail.nossr50.core.events.chat.McMMOAdminChatEvent; import com.gmail.nossr50.core.events.chat.McMMOAdminChatEvent;
@ -15,6 +16,6 @@ public class AdminChatManager extends ChatManager {
@Override @Override
protected void sendMessage() { protected void sendMessage() {
plugin.getServer().broadcast(message, "mcmmo.chat.adminchat"); McmmoCore.getServer().broadcast(message, "mcmmo.chat.adminchat");
} }
} }

View File

@ -43,7 +43,7 @@ public abstract class ChatManager {
McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event; McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event;
//Find the people with permissions //Find the people with permissions
for (Player player : event.getPlugin().getServer().getOnlinePlayers()) { for (Player player : McmmoCore.getServer().getOnlinePlayers()) {
//Check for toggled players //Check for toggled players
if (UserManager.getPlayer(player).isPartyChatSpying()) { if (UserManager.getPlayer(player).isPartyChatSpying()) {
Party adminParty = UserManager.getPlayer(player).getParty(); Party adminParty = UserManager.getPlayer(player).getParty();

View File

@ -1,16 +1,15 @@
package com.gmail.nossr50.core.events.chat; package com.gmail.nossr50.core.events.chat;
import org.bukkit.plugin.Plugin;
/** /**
* 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 McMMOChatEvent { public class McMMOAdminChatEvent extends McMMOChatEvent {
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message) { public McMMOAdminChatEvent(String sender, String displayName, String message) {
super(plugin, sender, displayName, message); super(sender, displayName, message);
} }
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) { public McMMOAdminChatEvent(String sender, String displayName, String message, boolean isAsync) {
super(plugin, sender, displayName, message, isAsync); super(sender, displayName, message, isAsync);
} }
} }

View File

@ -1,9 +1,7 @@
package com.gmail.nossr50.core.events.chat; package com.gmail.nossr50.core.events.chat;
import org.bukkit.event.Cancellable; import com.gmail.nossr50.core.mcmmo.event.Cancellable;
import org.bukkit.event.Event; import com.gmail.nossr50.core.mcmmo.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.Plugin;
public abstract class McMMOChatEvent extends Event implements Cancellable { public abstract class McMMOChatEvent extends Event implements Cancellable {
/** /**
@ -11,36 +9,36 @@ public abstract class McMMOChatEvent extends Event implements Cancellable {
**/ **/
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private boolean cancelled; private boolean cancelled;
private Plugin plugin;
private String sender; private String sender;
private String displayName; private String displayName;
private String message; private String message;
protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message) { protected McMMOChatEvent(String sender, String displayName, String message) {
this.plugin = plugin;
this.sender = sender; this.sender = sender;
this.displayName = displayName; this.displayName = displayName;
this.message = message; this.message = message;
} }
protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) { protected McMMOChatEvent(String sender, String displayName, String message, boolean isAsync) {
super(isAsync); super(isAsync);
this.plugin = plugin;
this.sender = sender; this.sender = sender;
this.displayName = displayName; this.displayName = displayName;
this.message = message; this.message = message;
} }
/*
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
*/
/** /**
* @return The plugin responsible for this event, note this can be null * @return The plugin responsible for this event, note this can be null
*/ */
public Plugin getPlugin() { //TODO: Why do we even need this?
/*public Plugin getPlugin() {
return plugin; return plugin;
} }*/
/** /**
* @return String name of the player who sent the chat, or "Console" * @return String name of the player who sent the chat, or "Console"

View File

@ -14,4 +14,10 @@ public interface Nameable extends Named {
* @return the original name of this entity * @return the original name of this entity
*/ */
String getOriginalName(); String getOriginalName();
/**
* This is the name used for chat messages and other things
* @return the display name of this entity
*/
String getDisplayName();
} }

View File

@ -30,4 +30,10 @@ public interface Player extends Living, Nameable, InventoryHolder, Permissible {
* @return the item in the main hand * @return the item in the main hand
*/ */
ItemStack getItemInMainHand(); ItemStack getItemInMainHand();
/**
* Sends a message to this player
* @param msg the message to send
*/
void sendMessage(String msg);
} }

View File

@ -10,7 +10,7 @@ public interface Cancellable {
* *
* @return true if cancelled * @return true if cancelled
*/ */
Boolean isCancelled(); boolean isCancelled();
/** /**
* Sets an events cancellation to b * Sets an events cancellation to b

View File

@ -13,6 +13,13 @@ public interface Server {
*/ */
void broadcast(String msg); void broadcast(String msg);
/**
* Broadcasts a message only to players with the appropriate permission node
* @param msg the message to broadcast
* @param permission the permission node required to hear the message
*/
void broadcast(String msg, String permission);
/** /**
* Gets the online players for this server * Gets the online players for this server
* @return the online players for this server * @return the online players for this server