From 28aeb355734e8a79edb7703126d811827aa45a90 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 7 May 2017 01:09:39 +0200 Subject: [PATCH] Fixed channels a lot Made Console be able to send messages --- src/main/java/buttondevteam/chat/ChatProcessing.java | 9 +++------ .../buttondevteam/chat/commands/ChatonlyCommand.java | 10 +++++----- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/buttondevteam/chat/ChatProcessing.java b/src/main/java/buttondevteam/chat/ChatProcessing.java index f641229..84282a2 100644 --- a/src/main/java/buttondevteam/chat/ChatProcessing.java +++ b/src/main/java/buttondevteam/chat/ChatProcessing.java @@ -124,12 +124,9 @@ public class ChatProcessing { try { if (channel.filteranderrormsg != null) { Objective obj = PluginMain.SB.getObjective(channel.ID); - int score; - obj.getScore(player.getUniqueId().toString()).setScore(score = e.getMCScore(player)); + int score = -1; for (Player p : Bukkit.getOnlinePlayers()) { - if (player == p) - continue; - obj.getScore(p.getUniqueId().toString()).setScore(e.getMCScore(p)); + obj.getScore(p.getUniqueId().toString()).setScore(score = e.getMCScore(p)); } 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)); @@ -138,7 +135,7 @@ public class ChatProcessing { String.format("tellraw @a %s", jsonstr)); } catch (Exception ex) { TBMCCoreAPI.SendException("An error occured while sending a chat message!", ex); - player.sendMessage("§cAn error occured while sending the message."); + sender.sendMessage("§cAn error occured while sending the message."); return true; } PluginMain.Instance.getServer().getConsoleSender().sendMessage(String.format("%s <%s> %s", channelidentifier, diff --git a/src/main/java/buttondevteam/chat/commands/ChatonlyCommand.java b/src/main/java/buttondevteam/chat/commands/ChatonlyCommand.java index a79e878..e85c7d3 100644 --- a/src/main/java/buttondevteam/chat/commands/ChatonlyCommand.java +++ b/src/main/java/buttondevteam/chat/commands/ChatonlyCommand.java @@ -1,14 +1,15 @@ package buttondevteam.chat.commands; import org.bukkit.GameMode; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import buttondevteam.chat.ChatPlayer; -import buttondevteam.lib.chat.TBMCCommandBase; +import buttondevteam.lib.chat.CommandClass; +import buttondevteam.lib.chat.PlayerCommandBase; import buttondevteam.lib.player.TBMCPlayer; -public final class ChatonlyCommand extends TBMCCommandBase { //TODO: Add annotation +@CommandClass(modOnly = false) +public final class ChatonlyCommand extends PlayerCommandBase { @Override public String[] GetHelpText(String alias) { @@ -20,8 +21,7 @@ public final class ChatonlyCommand extends TBMCCommandBase { //TODO: Add annotat } @Override - public boolean OnCommand(CommandSender sender, String alias, String[] args) { - Player player = (Player) sender; + public boolean OnCommand(Player player, String alias, String[] args) { ChatPlayer p = TBMCPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class); p.ChatOnly = true; player.setGameMode(GameMode.SPECTATOR);