From ae1804758ade0085727de47e87165b1dc3815e3a Mon Sep 17 00:00:00 2001 From: KHobbits Date: Wed, 26 Mar 2014 20:06:01 +0000 Subject: [PATCH] Helpop should use broadcast method Add local echo's to helpop and mute commands. --- .../essentials/commands/Commandhelpop.java | 25 ++++++++----------- .../essentials/commands/Commandmute.java | 5 +++- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java index 945f7c688..b83b5b695 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java @@ -5,9 +5,8 @@ import com.earth2me.essentials.Console; import static com.earth2me.essentials.I18n.tl; import com.earth2me.essentials.User; import com.earth2me.essentials.utils.FormatUtil; +import java.util.logging.Level; import org.bukkit.Server; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; public class Commandhelpop extends EssentialsCommand @@ -21,7 +20,11 @@ public class Commandhelpop extends EssentialsCommand public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { user.setDisplayNick(); - sendMessage(server, user.getSource(), user.getDisplayName(), args); + final String message = sendMessage(server, user.getSource(), user.getDisplayName(), args); + if (!user.isAuthorized("essentials.helpop.receive")) + { + user.sendMessage(message); + } } @Override @@ -30,23 +33,15 @@ public class Commandhelpop extends EssentialsCommand sendMessage(server, sender, Console.NAME, args); } - private void sendMessage(final Server server, final CommandSource sender, final String from, final String[] args) throws Exception + private String sendMessage(final Server server, final CommandSource sender, final String from, final String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } final String message = tl("helpOp", from, FormatUtil.stripFormat(getFinalArg(args, 0))); - CommandSender cs = Console.getCommandSender(server); - cs.sendMessage(message); - for (Player onlinePlayer : server.getOnlinePlayers()) - { - final User player = ess.getUser(onlinePlayer); - if (!player.isAuthorized("essentials.helpop.receive")) - { - continue; - } - player.sendMessage(message); - } + server.getLogger().log(Level.INFO, message); + ess.broadcastMessage("essentials.helpop.receive", message); + return message; } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java index e27c97ead..a2ee68556 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java @@ -5,6 +5,7 @@ import static com.earth2me.essentials.I18n.tl; import com.earth2me.essentials.OfflinePlayer; import com.earth2me.essentials.User; import com.earth2me.essentials.utils.DateUtil; +import java.util.logging.Level; import org.bukkit.Server; @@ -81,7 +82,9 @@ public class Commandmute extends EssentialsCommand sender.sendMessage(tl("mutedPlayer", user.getDisplayName())); user.sendMessage(tl("playerMuted")); } - ess.broadcastMessage("essentials.mute.notify", tl("muteNotify", sender.getSender().getName(), user.getName(), muteTime)); + final String message = tl("muteNotify", sender.getSender().getName(), user.getName(), muteTime); + server.getLogger().log(Level.INFO, message); + ess.broadcastMessage("essentials.mute.notify", message); } else {