From d0a990e0f1fcda9dc26ce62c5fa228010280b359 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 23 Aug 2017 02:29:11 +0200 Subject: [PATCH] Fixed channel scores for Discord->MC --- .../buttondevteam/chat/ChatProcessing.java | 19 +++++++++++++------ .../chat/commands/UnlolCommand.java | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/buttondevteam/chat/ChatProcessing.java b/src/main/java/buttondevteam/chat/ChatProcessing.java index 199e533..7a5f232 100644 --- a/src/main/java/buttondevteam/chat/ChatProcessing.java +++ b/src/main/java/buttondevteam/chat/ChatProcessing.java @@ -134,17 +134,24 @@ public class ChatProcessing { Objective obj = PluginMain.SB.getObjective(channel.ID); int score = -1; for (Player p : Bukkit.getOnlinePlayers()) { - if (PluginMain.essentials.getUser(p).isIgnoredPlayer(PluginMain.essentials.getUser(player))) - continue; - final int mcScore = VanillaUtils.getMCScoreIfChatOn(p, e); + final int mcScore; + if (player != null + && PluginMain.essentials.getUser(p).isIgnoredPlayer(PluginMain.essentials.getUser(player))) + mcScore = -1; // Don't send the message to them + else + mcScore = VanillaUtils.getMCScoreIfChatOn(p, e); obj.getScore(p.getName()) .setScore(p.getUniqueId().equals(player == null ? null : player.getUniqueId()) // p.UniqueID==player?.UniqueID ? score = mcScore : mcScore); } - if (player == null) + if (score == -1) // Even if the player object isn't null, it may not be in OnlinePlayers score = e.getMCScore(sender); - PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console, String.format( - "tellraw @a[score_%s=%d,score_%s_min=%d] %s", channel.ID, score, channel.ID, score, jsonstr)); + if (score < 0) // Never send messages to score below 0 + sender.sendMessage("§cYou don't have permission to send this message or something went wrong"); + else + PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console, + String.format("tellraw @a[score_%s=%d,score_%s_min=%d] %s", channel.ID, score, channel.ID, + score, jsonstr)); } else PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console, String.format("tellraw @a %s", jsonstr)); diff --git a/src/main/java/buttondevteam/chat/commands/UnlolCommand.java b/src/main/java/buttondevteam/chat/commands/UnlolCommand.java index c4eaa69..e21221a 100644 --- a/src/main/java/buttondevteam/chat/commands/UnlolCommand.java +++ b/src/main/java/buttondevteam/chat/commands/UnlolCommand.java @@ -24,7 +24,7 @@ public final class UnlolCommand extends TBMCCommandBase { public String[] GetHelpText(String alias) { return new String[] { "§6---- Unlol/unlaugh ----", "This command is based on a joke between NorbiPeti and Ghostise", - "It will make anyone saying one of the recognized laugh strings blind for a few seconds", + "It will make the last person saying one of the recognized laugh strings blind for a few seconds", "Note that you can only unlaugh laughs that weren't unlaughed before" }; }