From b7704a4ea804560fabfaee33e2e8ef9af0effd81 Mon Sep 17 00:00:00 2001 From: drtshock Date: Wed, 22 Apr 2015 10:58:04 -0500 Subject: [PATCH] Simplify a few things in EssentialsChat. --- .../essentials/chat/EssentialsChatPlayer.java | 8 ++------ .../chat/EssentialsChatPlayerListenerNormal.java | 11 +++-------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java index 2edb03766..2526e8b60 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java @@ -24,14 +24,10 @@ public abstract class EssentialsChatPlayer implements Listener { this.chatStorage = chatStorage; } - public void onPlayerChat(final AsyncPlayerChatEvent event) { - } + public abstract void onPlayerChat(final AsyncPlayerChatEvent event); public boolean isAborted(final AsyncPlayerChatEvent event) { - if (event.isCancelled()) { - return true; - } - return false; + return event.isCancelled(); } public String getChatType(final String message) { diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java index 91bfd4c2b..f493f7106 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java @@ -48,17 +48,12 @@ public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer { permission.append("essentials.chat.").append(chatStore.getType()); if (user.isAuthorized(permission.toString())) { - final StringBuilder format = new StringBuilder(); - format.append(chatStore.getType()).append("Format"); event.setMessage(event.getMessage().substring(1)); - event.setFormat(tl(format.toString(), event.getFormat())); + event.setFormat(tl(chatStore.getType() + "Format", event.getFormat())); return; } - final StringBuilder errorMsg = new StringBuilder(); - errorMsg.append("notAllowedTo").append(chatStore.getType().substring(0, 1).toUpperCase(Locale.ENGLISH)).append(chatStore.getType().substring(1)); - - user.sendMessage(tl(errorMsg.toString())); + user.sendMessage(tl("notAllowedTo" + chatStore.getType().substring(0, 1).toUpperCase(Locale.ENGLISH) + chatStore.getType().substring(1))); event.setCancelled(true); return; } @@ -66,7 +61,7 @@ public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer { final Location loc = user.getLocation(); final World world = loc.getWorld(); - if (charge(event, chatStore) == false) { + if (!charge(event, chatStore)) { return; }