From 13ec4e43ade04e975cf4610086ef2fe54c2bd776 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 16 Jul 2016 23:55:36 +0200 Subject: [PATCH] Renamed to ChatPlayer --- .../thebuttonmcchat/ChatPlayer.java | 18 +++++------ .../thebuttonmcchat/ChatProcessing.java | 8 ++--- .../thebuttonmcchat/PlayerJoinTimerTask.java | 2 +- .../thebuttonmcchat/PlayerListener.java | 16 +++++----- .../thebuttonmcchat/PluginMain.java | 30 +++++++++---------- .../thebuttonmcchat/TBMCChatAPI.java | 9 ++---- .../commands/ChatonlyCommand.java | 9 ++++-- .../commands/CommandCaller.java | 7 ++++- .../commands/MWikiCommand.java | 5 ++++ .../thebuttonmcchat/commands/OOCCommand.java | 11 +++++-- .../commands/TBMCCommandBase.java | 5 ++-- .../commands/UnlolCommand.java | 17 ++++++----- .../commands/YeehawCommand.java | 4 +++ .../appendtext/AppendTextCommandBase.java | 4 +++ .../commands/ucmds/AcceptCommand.java | 4 +-- .../commands/ucmds/CCommand.java | 4 +-- .../commands/ucmds/IgnoreCommand.java | 6 ++-- .../commands/ucmds/NameCommand.java | 4 +-- .../commands/ucmds/UCommand.java | 4 +++ .../commands/ucmds/UCommandBase.java | 5 ++++ .../commands/ucmds/admin/AdminCommand.java | 5 ++++ .../ucmds/admin/AdminCommandBase.java | 7 ++++- .../commands/ucmds/admin/ConfirmCommand.java | 4 +-- .../ucmds/admin/PlayerInfoCommand.java | 20 +++++-------- .../commands/ucmds/admin/SetFlairCommand.java | 10 +++---- 25 files changed, 129 insertions(+), 89 deletions(-) diff --git a/src/buttondevteam/thebuttonmcchat/ChatPlayer.java b/src/buttondevteam/thebuttonmcchat/ChatPlayer.java index dc47bb7..7ee46b1 100644 --- a/src/buttondevteam/thebuttonmcchat/ChatPlayer.java +++ b/src/buttondevteam/thebuttonmcchat/ChatPlayer.java @@ -11,7 +11,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; -public class TBMCPlayer { +public class ChatPlayer { public String PlayerName; public String UserName; public List UserNames; @@ -37,11 +37,11 @@ public class TBMCPlayer { public UUID UUID; - public static HashMap AllPlayers = new HashMap<>(); + public static HashMap AllPlayers = new HashMap<>(); - public static TBMCPlayer AddPlayerIfNeeded(UUID uuid) { + public static ChatPlayer AddPlayerIfNeeded(UUID uuid) { if (!AllPlayers.containsKey(uuid)) { - TBMCPlayer player = new TBMCPlayer(); + ChatPlayer player = new ChatPlayer(); player.UUID = uuid; player.FlairTime = FlairTimeNone; player.FlairState = FlairStates.NoComment; @@ -59,7 +59,7 @@ public class TBMCPlayer { ConfigurationSection cs = yc.getConfigurationSection("players"); for (String key : cs.getKeys(false)) { ConfigurationSection cs2 = cs.getConfigurationSection(key); - TBMCPlayer mp = AddPlayerIfNeeded(java.util.UUID + ChatPlayer mp = AddPlayerIfNeeded(java.util.UUID .fromString(cs2.getString("uuid"))); mp.UserName = cs2.getString("username"); String tmp = cs2.getString("flairtime"); @@ -84,7 +84,7 @@ public class TBMCPlayer { public static void Save(YamlConfiguration yc) { ConfigurationSection cs = yc.createSection("players"); - for (TBMCPlayer mp : TBMCPlayer.AllPlayers.values()) { + for (ChatPlayer mp : ChatPlayer.AllPlayers.values()) { ConfigurationSection cs2 = cs.createSection(mp.UUID.toString()); cs2.set("playername", mp.PlayerName); cs2.set("username", mp.UserName); @@ -98,7 +98,7 @@ public class TBMCPlayer { } } - public static TBMCPlayer GetFromName(String name) { + public static ChatPlayer GetFromName(String name) { Player p = Bukkit.getPlayer(name); if (p != null) return AllPlayers.get(p.getUniqueId()); @@ -162,7 +162,7 @@ public class TBMCPlayer { return FlairTime; } - public static TBMCPlayer GetFromPlayer(Player p) { - return TBMCPlayer.AllPlayers.get(p.getUniqueId()); + public static ChatPlayer GetFromPlayer(Player p) { + return ChatPlayer.AllPlayers.get(p.getUniqueId()); } } diff --git a/src/buttondevteam/thebuttonmcchat/ChatProcessing.java b/src/buttondevteam/thebuttonmcchat/ChatProcessing.java index 0b71432..59900d2 100644 --- a/src/buttondevteam/thebuttonmcchat/ChatProcessing.java +++ b/src/buttondevteam/thebuttonmcchat/ChatProcessing.java @@ -30,9 +30,9 @@ public class ChatProcessing { if (player != null && PlayerListener.essentials.getUser(player).isMuted()) return true; - TBMCPlayer mp = null; + ChatPlayer mp = null; if (player != null) { - mp = TBMCPlayer.AllPlayers.get(player.getUniqueId()); + mp = ChatPlayer.AllPlayers.get(player.getUniqueId()); if (message.equalsIgnoreCase("F")) { if (!mp.PressedF && PlayerListener.ActiveF) { PlayerListener.FCount++; @@ -109,7 +109,7 @@ public class ChatProcessing { System.out.println("Error: Can't find player " + match + " but it was reported as online."); return false; } - TBMCPlayer mpp = TBMCPlayer.AddPlayerIfNeeded(p.getUniqueId()); + ChatPlayer mpp = ChatPlayer.AddPlayerIfNeeded(p.getUniqueId()); if (PlayerListener.NotificationSound == null) p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO: // Airhorn @@ -143,7 +143,7 @@ public class ChatProcessing { "Error: Can't find player " + match + " but it was reported as online."); return false; } - TBMCPlayer mpp = TBMCPlayer.AddPlayerIfNeeded(p.getUniqueId()); + ChatPlayer mpp = ChatPlayer.AddPlayerIfNeeded(p.getUniqueId()); if (PlayerListener.NotificationSound == null) p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO: // Airhorn diff --git a/src/buttondevteam/thebuttonmcchat/PlayerJoinTimerTask.java b/src/buttondevteam/thebuttonmcchat/PlayerJoinTimerTask.java index 2b950b3..4de9157 100644 --- a/src/buttondevteam/thebuttonmcchat/PlayerJoinTimerTask.java +++ b/src/buttondevteam/thebuttonmcchat/PlayerJoinTimerTask.java @@ -7,6 +7,6 @@ public abstract class PlayerJoinTimerTask extends TimerTask { @Override public abstract void run(); - public TBMCPlayer mp; + public ChatPlayer mp; } diff --git a/src/buttondevteam/thebuttonmcchat/PlayerListener.java b/src/buttondevteam/thebuttonmcchat/PlayerListener.java index 335a21f..4e586ed 100644 --- a/src/buttondevteam/thebuttonmcchat/PlayerListener.java +++ b/src/buttondevteam/thebuttonmcchat/PlayerListener.java @@ -66,7 +66,7 @@ public class PlayerListener implements Listener { if (essentials == null) essentials = ((Essentials) Bukkit.getPluginManager().getPlugin("Essentials")); final Player p = event.getPlayer(); - TBMCPlayer mp = TBMCPlayer.AddPlayerIfNeeded(p.getUniqueId()); + ChatPlayer mp = ChatPlayer.AddPlayerIfNeeded(p.getUniqueId()); if (!mp.FlairState.equals(FlairStates.NoComment)) { PluginMain.ConfirmUserMessage(mp); Timer timer = new Timer(); @@ -80,7 +80,7 @@ public class PlayerListener implements Listener { timer.schedule(tt, 1000); } else { if (mp.GetFlairTime() == 0x00) - mp.SetFlair(TBMCPlayer.FlairTimeNone); + mp.SetFlair(ChatPlayer.FlairTimeNone); Timer timer = new Timer(); PlayerJoinTimerTask tt = new PlayerJoinTimerTask() { @Override @@ -227,7 +227,7 @@ public class PlayerListener implements Listener { if (event.getMessage().length() < 2) return; int index = event.getMessage().indexOf(" "); - TBMCPlayer mp = TBMCPlayer.AllPlayers.get(event.getPlayer().getUniqueId()); + ChatPlayer mp = ChatPlayer.AllPlayers.get(event.getPlayer().getUniqueId()); String cmd = ""; if (index == -1) { cmd = event.getMessage().substring(1); @@ -468,7 +468,7 @@ public class PlayerListener implements Listener { static boolean ActiveF = false; static int FCount = 0; - static TBMCPlayer FPlayer = null; + static ChatPlayer FPlayer = null; private Timer Ftimer; public static int AlphaDeaths; @@ -486,10 +486,10 @@ public class PlayerListener implements Listener { Ftimer.cancel(); ActiveF = true; FCount = 0; - FPlayer = TBMCPlayer.AllPlayers.get(e.getEntity().getUniqueId()); + FPlayer = ChatPlayer.AllPlayers.get(e.getEntity().getUniqueId()); FPlayer.FDeaths++; for (Player p : PluginMain.GetPlayers()) { - TBMCPlayer mp = TBMCPlayer.AllPlayers.get(p.getUniqueId()); + ChatPlayer mp = ChatPlayer.AllPlayers.get(p.getUniqueId()); mp.PressedF = false; p.sendMessage("§bPress F to pay respects.§r"); } @@ -579,7 +579,7 @@ public class PlayerListener implements Listener { }); } - TBMCPlayer mp = TBMCPlayer.GetFromPlayer(e.getPlayer()); + ChatPlayer mp = ChatPlayer.GetFromPlayer(e.getPlayer()); if (mp.ChatOnly) e.setCancelled(true); } @@ -603,7 +603,7 @@ public class PlayerListener implements Listener { * "§cYou are not allowed to teleport to/from No Mans Land."); } */ - if (TBMCPlayer.GetFromPlayer(e.getPlayer()).ChatOnly) { + if (ChatPlayer.GetFromPlayer(e.getPlayer()).ChatOnly) { e.setCancelled(true); e.getPlayer().sendMessage("§cYou are not allowed to teleport while in chat-only mode."); } diff --git a/src/buttondevteam/thebuttonmcchat/PluginMain.java b/src/buttondevteam/thebuttonmcchat/PluginMain.java index f8ea1d0..cd113a5 100644 --- a/src/buttondevteam/thebuttonmcchat/PluginMain.java +++ b/src/buttondevteam/thebuttonmcchat/PluginMain.java @@ -156,7 +156,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. else ign = ign.substring(start, end); ign = ign.trim(); - TBMCPlayer mp = TBMCPlayer.GetFromName(ign); + ChatPlayer mp = ChatPlayer.GetFromName(ign); if (mp == null) continue; if (!JoinedBefore(mp, 2015, 6, 5)) @@ -185,7 +185,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. } } - public void DownloadFlair(TBMCPlayer mp) + public void DownloadFlair(ChatPlayer mp) throws MalformedURLException, IOException { String[] flairdata = DownloadString( "http://karmadecay.com/thebutton-data.php?users=" + mp.UserName) @@ -218,7 +218,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. return body; } - private void SetFlair(TBMCPlayer p, String text, String flairclass, + private void SetFlair(ChatPlayer p, String text, String flairclass, String username) { p.UserName = username; p.FlairState = FlairStates.Recognised; @@ -233,26 +233,26 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. { try { if (CheckForJoinDate(p)) { - p.SetFlair(TBMCPlayer.FlairTimeNonPresser); + p.SetFlair(ChatPlayer.FlairTimeNonPresser); } else { - p.SetFlair(TBMCPlayer.FlairTimeCantPress); + p.SetFlair(ChatPlayer.FlairTimeCantPress); } } catch (Exception e) { p.FlairState = FlairStates.Commented; // Flair unknown - p.SetFlair(TBMCPlayer.FlairTimeNone); + p.SetFlair(ChatPlayer.FlairTimeNone); e.printStackTrace(); } } else { try { if (CheckForJoinDate(p)) { p.FlairState = FlairStates.Commented; // Flair unknown - p.SetFlair(TBMCPlayer.FlairTimeNone); + p.SetFlair(ChatPlayer.FlairTimeNone); } else { - p.SetFlair(TBMCPlayer.FlairTimeCantPress); + p.SetFlair(ChatPlayer.FlairTimeCantPress); } } catch (Exception e) { p.FlairState = FlairStates.Commented; // Flair unknown - p.SetFlair(TBMCPlayer.FlairTimeNone); + p.SetFlair(ChatPlayer.FlairTimeNone); e.printStackTrace(); } } @@ -263,12 +263,12 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. p.SetFlair(Short.parseShort(text)); } - public static boolean CheckForJoinDate(TBMCPlayer mp) + public static boolean CheckForJoinDate(ChatPlayer mp) throws Exception { return JoinedBefore(mp, 2015, 4, 1); } - public static boolean JoinedBefore(TBMCPlayer mp, int year, + public static boolean JoinedBefore(ChatPlayer mp, int year, int month, int day) throws Exception { URL url = new URL("https://www.reddit.com/u/" + mp.UserName); URLConnection con = url.openConnection(); @@ -288,7 +288,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. .setDate(year, month, day).build().getTime()); } - public static void ConfirmUserMessage(TBMCPlayer mp) { + public static void ConfirmUserMessage(ChatPlayer mp) { Player p = Bukkit.getPlayer(mp.UUID); if (mp.FlairState.equals(FlairStates.Commented) && p != null) if (mp.UserNames.size() > 1) @@ -307,7 +307,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. public static void LoadFiles(boolean reload) { if (reload) { System.out.println("TBMC chat plugin cleanup for reloading..."); - TBMCPlayer.AllPlayers.clear(); + ChatPlayer.AllPlayers.clear(); AnnounceMessages.clear(); } System.out.println("Loading files for TBMC chat plugin..."); @@ -316,7 +316,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. if (file.exists()) { YamlConfiguration yc = new YamlConfiguration(); yc.load(file); - TBMCPlayer.Load(yc); + ChatPlayer.Load(yc); PlayerListener.NotificationSound = yc .getString("notificationsound"); PlayerListener.NotificationPitch = yc @@ -340,7 +340,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. try { File file = new File("thebuttonmc.yml"); YamlConfiguration yc = new YamlConfiguration(); - TBMCPlayer.Save(yc); + ChatPlayer.Save(yc); yc.set("notificationsound", PlayerListener.NotificationSound); yc.set("notificationpitch", PlayerListener.NotificationPitch); yc.set("announcetime", AnnounceTime); diff --git a/src/buttondevteam/thebuttonmcchat/TBMCChatAPI.java b/src/buttondevteam/thebuttonmcchat/TBMCChatAPI.java index f82fd39..0369dc0 100644 --- a/src/buttondevteam/thebuttonmcchat/TBMCChatAPI.java +++ b/src/buttondevteam/thebuttonmcchat/TBMCChatAPI.java @@ -35,7 +35,7 @@ public class TBMCChatAPI { * @param player * @param infoline */ - public void AddPlayerInfoForMods(TBMCPlayer player, String infoline) { + public void AddPlayerInfoForMods(ChatPlayer player, String infoline) { // TODO } @@ -48,12 +48,7 @@ public class TBMCChatAPI { * @param player * @param infoline */ - public void AddPlayerInfoForHover(TBMCPlayer player, String infoline) { + public void AddPlayerInfoForHover(ChatPlayer player, String infoline) { // TODO } - - public TBMCPlayer GetPlayer(Player player) //TODO: Move to the bucket - { //TODO: Enable offline playerinfo - - } } diff --git a/src/buttondevteam/thebuttonmcchat/commands/ChatonlyCommand.java b/src/buttondevteam/thebuttonmcchat/commands/ChatonlyCommand.java index 595355b..a88ae8d 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/ChatonlyCommand.java +++ b/src/buttondevteam/thebuttonmcchat/commands/ChatonlyCommand.java @@ -4,7 +4,7 @@ import org.bukkit.GameMode; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import buttondevteam.thebuttonmcchat.TBMCPlayer; +import buttondevteam.thebuttonmcchat.ChatPlayer; public final class ChatonlyCommand extends TBMCCommandBase { @@ -21,7 +21,7 @@ public final class ChatonlyCommand extends TBMCCommandBase { @Override public boolean OnCommand(CommandSender sender, String alias, String[] args) { Player player=(Player)sender; - TBMCPlayer p = TBMCPlayer.AllPlayers.get(player + ChatPlayer p = ChatPlayer.AllPlayers.get(player .getUniqueId()); p.ChatOnly = true; player.setGameMode(GameMode.SPECTATOR); @@ -39,4 +39,9 @@ public final class ChatonlyCommand extends TBMCCommandBase { return false; } + @Override + public boolean GetModOnly() { + return false; + } + } diff --git a/src/buttondevteam/thebuttonmcchat/commands/CommandCaller.java b/src/buttondevteam/thebuttonmcchat/commands/CommandCaller.java index f3016a1..0139560 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/CommandCaller.java +++ b/src/buttondevteam/thebuttonmcchat/commands/CommandCaller.java @@ -11,6 +11,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; +import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import org.reflections.Reflections; @@ -101,7 +102,11 @@ public class CommandCaller implements CommandExecutor { Bukkit.getConsoleSender().sendMessage("§cInternal error: Command not registered to CommandCaller"); return true; } - if (cmd.GetPlayerOnly() && sender == Bukkit.getConsoleSender()) { + if (cmd.GetModOnly() && PluginMain.permission.has(sender, "tbmc.admin")) { + sender.sendMessage("§cYou need to be a mod to use this command."); + return true; + } + if (cmd.GetPlayerOnly() && !(sender instanceof Player)) { sender.sendMessage("§cOnly ingame players can use this command."); return true; } diff --git a/src/buttondevteam/thebuttonmcchat/commands/MWikiCommand.java b/src/buttondevteam/thebuttonmcchat/commands/MWikiCommand.java index 40c04c4..6527766 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/MWikiCommand.java +++ b/src/buttondevteam/thebuttonmcchat/commands/MWikiCommand.java @@ -39,4 +39,9 @@ public class MWikiCommand extends TBMCCommandBase { return false; } + @Override + public boolean GetModOnly() { + return false; + } + } diff --git a/src/buttondevteam/thebuttonmcchat/commands/OOCCommand.java b/src/buttondevteam/thebuttonmcchat/commands/OOCCommand.java index 8c8921e..51a437e 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/OOCCommand.java +++ b/src/buttondevteam/thebuttonmcchat/commands/OOCCommand.java @@ -3,7 +3,7 @@ package buttondevteam.thebuttonmcchat.commands; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import buttondevteam.thebuttonmcchat.TBMCPlayer; +import buttondevteam.thebuttonmcchat.ChatPlayer; public final class OOCCommand extends TBMCCommandBase { @@ -21,12 +21,12 @@ public final class OOCCommand extends TBMCCommandBase { if (args.length == 0) { return false; } else { - TBMCPlayer.AddPlayerIfNeeded(player.getUniqueId()).RPMode = false; + ChatPlayer.AddPlayerIfNeeded(player.getUniqueId()).RPMode = false; String message = ""; for (String arg : args) message += arg + " "; player.chat(message.substring(0, message.length() - 1)); - TBMCPlayer.AddPlayerIfNeeded(player.getUniqueId()).RPMode = true; + ChatPlayer.AddPlayerIfNeeded(player.getUniqueId()).RPMode = true; } return true; } @@ -41,4 +41,9 @@ public final class OOCCommand extends TBMCCommandBase { return true; } + @Override + public boolean GetModOnly() { + return false; + } + } diff --git a/src/buttondevteam/thebuttonmcchat/commands/TBMCCommandBase.java b/src/buttondevteam/thebuttonmcchat/commands/TBMCCommandBase.java index 967fb36..2ec94f3 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/TBMCCommandBase.java +++ b/src/buttondevteam/thebuttonmcchat/commands/TBMCCommandBase.java @@ -9,10 +9,11 @@ public abstract class TBMCCommandBase { public abstract String[] GetHelpText(String alias); - public abstract boolean OnCommand(CommandSender sender, String alias, - String[] args); + public abstract boolean OnCommand(CommandSender sender, String alias, String[] args); public abstract String GetCommandPath(); public abstract boolean GetPlayerOnly(); + + public abstract boolean GetModOnly(); } diff --git a/src/buttondevteam/thebuttonmcchat/commands/UnlolCommand.java b/src/buttondevteam/thebuttonmcchat/commands/UnlolCommand.java index c8cc827..003c7cd 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/UnlolCommand.java +++ b/src/buttondevteam/thebuttonmcchat/commands/UnlolCommand.java @@ -15,8 +15,7 @@ public final class UnlolCommand extends TBMCCommandBase { @Override public String[] GetHelpText(String alias) { - return new String[] { - "§6---- Unlol/unlaugh ----", + 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", "Note that you can only unlaugh laughs that weren't unlaughed before" }; @@ -26,13 +25,11 @@ public final class UnlolCommand extends TBMCCommandBase { public boolean OnCommand(CommandSender sender, String alias, String[] args) { if (Lastlol != null) { if (Lastlol instanceof Player) - ((Player) Lastlol).addPotionEffect(new PotionEffect( - PotionEffectType.BLINDNESS, 10 * 20, 5, false, false)); - String msg = (sender instanceof Player ? ((Player) sender) - .getDisplayName() : sender.getName()) + ((Player) Lastlol) + .addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10 * 20, 5, false, false)); + String msg = (sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName()) + (Lastlolornot ? " unlolled " : " unlaughed ") - + (Lastlol instanceof Player ? ((Player) Lastlol) - .getDisplayName() : Lastlol.getName()); + + (Lastlol instanceof Player ? ((Player) Lastlol).getDisplayName() : Lastlol.getName()); for (Player pl : PluginMain.GetPlayers()) pl.sendMessage(msg); Bukkit.getServer().getConsoleSender().sendMessage(msg); @@ -51,4 +48,8 @@ public final class UnlolCommand extends TBMCCommandBase { return false; } + @Override + public boolean GetModOnly() { + return false; + } } diff --git a/src/buttondevteam/thebuttonmcchat/commands/YeehawCommand.java b/src/buttondevteam/thebuttonmcchat/commands/YeehawCommand.java index 4b6914f..29c7f76 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/YeehawCommand.java +++ b/src/buttondevteam/thebuttonmcchat/commands/YeehawCommand.java @@ -34,4 +34,8 @@ public class YeehawCommand extends TBMCCommandBase { return false; } + @Override + public boolean GetModOnly() { + return false; + } } diff --git a/src/buttondevteam/thebuttonmcchat/commands/appendtext/AppendTextCommandBase.java b/src/buttondevteam/thebuttonmcchat/commands/appendtext/AppendTextCommandBase.java index ccc16df..12f81ef 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/appendtext/AppendTextCommandBase.java +++ b/src/buttondevteam/thebuttonmcchat/commands/appendtext/AppendTextCommandBase.java @@ -25,4 +25,8 @@ public abstract class AppendTextCommandBase extends TBMCCommandBase { return false; } + @Override + public boolean GetModOnly() { + return false; + } } diff --git a/src/buttondevteam/thebuttonmcchat/commands/ucmds/AcceptCommand.java b/src/buttondevteam/thebuttonmcchat/commands/ucmds/AcceptCommand.java index b988da0..337072f 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/ucmds/AcceptCommand.java +++ b/src/buttondevteam/thebuttonmcchat/commands/ucmds/AcceptCommand.java @@ -8,7 +8,7 @@ import org.bukkit.entity.Player; import buttondevteam.thebuttonmcchat.FlairStates; import buttondevteam.thebuttonmcchat.PlayerJoinTimerTask; import buttondevteam.thebuttonmcchat.PluginMain; -import buttondevteam.thebuttonmcchat.TBMCPlayer; +import buttondevteam.thebuttonmcchat.ChatPlayer; public class AcceptCommand extends UCommandBase { @@ -22,7 +22,7 @@ public class AcceptCommand extends UCommandBase { @Override public boolean OnCommand(CommandSender sender, String alias, String[] args) { final Player player = (Player) sender; - TBMCPlayer p = TBMCPlayer.GetFromPlayer(player); + ChatPlayer p = ChatPlayer.GetFromPlayer(player); if (args.length < 1 && p.UserNames.size() > 1) { player.sendMessage("§9Multiple users commented your name. §bPlease pick one using /u accept "); StringBuilder sb = new StringBuilder(); diff --git a/src/buttondevteam/thebuttonmcchat/commands/ucmds/CCommand.java b/src/buttondevteam/thebuttonmcchat/commands/ucmds/CCommand.java index 3eea39b..c796861 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/ucmds/CCommand.java +++ b/src/buttondevteam/thebuttonmcchat/commands/ucmds/CCommand.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import buttondevteam.thebuttonmcchat.ChatFormatter; import buttondevteam.thebuttonmcchat.PluginMain; -import buttondevteam.thebuttonmcchat.TBMCPlayer; +import buttondevteam.thebuttonmcchat.ChatPlayer; public class CCommand extends UCommandBase { @@ -19,7 +19,7 @@ public class CCommand extends UCommandBase { @Override public boolean OnCommand(CommandSender sender, String alias, String[] args) { Player player = (Player) sender; - TBMCPlayer p = TBMCPlayer.AddPlayerIfNeeded(player + ChatPlayer p = ChatPlayer.AddPlayerIfNeeded(player .getUniqueId()); if (args.length < 1) { if (PluginMain.permission.has(player, "tbmc.rainbow")) { diff --git a/src/buttondevteam/thebuttonmcchat/commands/ucmds/IgnoreCommand.java b/src/buttondevteam/thebuttonmcchat/commands/ucmds/IgnoreCommand.java index d3d96c3..b91a656 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/ucmds/IgnoreCommand.java +++ b/src/buttondevteam/thebuttonmcchat/commands/ucmds/IgnoreCommand.java @@ -4,7 +4,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import buttondevteam.thebuttonmcchat.FlairStates; -import buttondevteam.thebuttonmcchat.TBMCPlayer; +import buttondevteam.thebuttonmcchat.ChatPlayer; public final class IgnoreCommand extends UCommandBase { @@ -19,7 +19,7 @@ public final class IgnoreCommand extends UCommandBase { @Override public boolean OnCommand(CommandSender sender, String alias, String[] args) { final Player player = (Player) sender; - TBMCPlayer p = TBMCPlayer.GetFromPlayer(player); + ChatPlayer p = ChatPlayer.GetFromPlayer(player); if (p.FlairState.equals(FlairStates.Accepted)) { player.sendMessage("§cYou can only ignore the \"write yoőu rname in the thread\" message."); return true; @@ -30,7 +30,7 @@ public final class IgnoreCommand extends UCommandBase { } if (!p.FlairState.equals(FlairStates.Ignored)) { p.FlairState = FlairStates.Ignored; - p.SetFlair(TBMCPlayer.FlairTimeNone); + p.SetFlair(ChatPlayer.FlairTimeNone); p.UserName = ""; player.sendMessage("§bYou have ignored the message. You can still use /u accept to get a flair.§r"); } else diff --git a/src/buttondevteam/thebuttonmcchat/commands/ucmds/NameCommand.java b/src/buttondevteam/thebuttonmcchat/commands/ucmds/NameCommand.java index c18d85b..0d07414 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/ucmds/NameCommand.java +++ b/src/buttondevteam/thebuttonmcchat/commands/ucmds/NameCommand.java @@ -2,7 +2,7 @@ package buttondevteam.thebuttonmcchat.commands.ucmds; import org.bukkit.command.CommandSender; -import buttondevteam.thebuttonmcchat.TBMCPlayer; +import buttondevteam.thebuttonmcchat.ChatPlayer; public class NameCommand extends UCommandBase { @@ -19,7 +19,7 @@ public class NameCommand extends UCommandBase { if (args.length == 1) { return false; } - TBMCPlayer mp = TBMCPlayer.GetFromName(args[1]); + ChatPlayer mp = ChatPlayer.GetFromName(args[1]); if (mp == null) { sender.sendMessage("§cUnknown user (player has to be online): " + args[1]); diff --git a/src/buttondevteam/thebuttonmcchat/commands/ucmds/UCommand.java b/src/buttondevteam/thebuttonmcchat/commands/ucmds/UCommand.java index b317870..dbc6aaa 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/ucmds/UCommand.java +++ b/src/buttondevteam/thebuttonmcchat/commands/ucmds/UCommand.java @@ -27,4 +27,8 @@ public final class UCommand extends TBMCCommandBase { return false; } + @Override + public boolean GetModOnly() { + return false; + } } diff --git a/src/buttondevteam/thebuttonmcchat/commands/ucmds/UCommandBase.java b/src/buttondevteam/thebuttonmcchat/commands/ucmds/UCommandBase.java index 81627f6..bfc88b8 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/ucmds/UCommandBase.java +++ b/src/buttondevteam/thebuttonmcchat/commands/ucmds/UCommandBase.java @@ -17,4 +17,9 @@ public abstract class UCommandBase extends TBMCCommandBase { public boolean GetPlayerOnly() { return true; } + + @Override + public boolean GetModOnly() { + return false; + } } diff --git a/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/AdminCommand.java b/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/AdminCommand.java index 19f9f6e..c418224 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/AdminCommand.java +++ b/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/AdminCommand.java @@ -26,4 +26,9 @@ public final class AdminCommand extends UCommandBase { public boolean GetPlayerOnly() { return false; } + + @Override + public boolean GetModOnly() { + return true; + } } diff --git a/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/AdminCommandBase.java b/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/AdminCommandBase.java index 4e610ee..78b8ec8 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/AdminCommandBase.java +++ b/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/AdminCommandBase.java @@ -4,7 +4,8 @@ import buttondevteam.thebuttonmcchat.commands.ucmds.UCommandBase; public abstract class AdminCommandBase extends UCommandBase { - public abstract String[] GetHelpText(String alias); //TODO: Require permission + public abstract String[] GetHelpText(String alias); // TODO: Require + // permission @Override public String GetUCommandPath() { @@ -18,4 +19,8 @@ public abstract class AdminCommandBase extends UCommandBase { public abstract String GetAdminCommandPath(); + @Override + public boolean GetModOnly() { + return true; + } } diff --git a/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/ConfirmCommand.java b/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/ConfirmCommand.java index 41ccb6c..139f807 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/ConfirmCommand.java +++ b/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/ConfirmCommand.java @@ -4,7 +4,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import buttondevteam.thebuttonmcchat.PluginMain; -import buttondevteam.thebuttonmcchat.TBMCPlayer; +import buttondevteam.thebuttonmcchat.ChatPlayer; public class ConfirmCommand extends AdminCommandBase { @@ -25,7 +25,7 @@ public class ConfirmCommand extends AdminCommandBase { PluginMain.LoadFiles(true); // TODO: Add players online for (Player p : PluginMain.GetPlayers()) - TBMCPlayer.AddPlayerIfNeeded(p.getUniqueId()); + ChatPlayer.AddPlayerIfNeeded(p.getUniqueId()); if (sender != PluginMain.Console) PluginMain.Console.sendMessage("§6-- Reloading done!§r"); sender.sendMessage("§6-- Reloading done!§r"); diff --git a/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/PlayerInfoCommand.java b/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/PlayerInfoCommand.java index a35656c..52f1ab1 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/PlayerInfoCommand.java +++ b/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/PlayerInfoCommand.java @@ -2,38 +2,34 @@ package buttondevteam.thebuttonmcchat.commands.ucmds.admin; import org.bukkit.command.CommandSender; -import buttondevteam.thebuttonmcchat.TBMCPlayer; +import buttondevteam.thebuttonmcchat.ChatPlayer; public class PlayerInfoCommand extends AdminCommandBase { @Override public String[] GetHelpText(String alias) { - return new String[] { - "§6---- Player info ----", + return new String[] { "§6---- Player info ----", "Shows some info about the player's flair, Reddit username(s) and other data known by the plugin", "Usage: /u admin playerinfo " }; } @Override - public boolean OnCommand(CommandSender sender, String alias, - String[] args) { + public boolean OnCommand(CommandSender sender, String alias, String[] args) { if (args.length == 0) { return false; } - TBMCPlayer p = TBMCPlayer.GetFromName(args[0]); + ChatPlayer p = ChatPlayer.GetFromName(args[0]); if (p == null) { - sender.sendMessage("§cPlayer not found: " + args[0] - + " - Currently only online players can be viewed§r"); + sender.sendMessage("§cPlayer not found: " + args[0] + "§r"); return true; } StringBuilder sb = new StringBuilder(); sb.append("§6Usernames:"); for (String username : p.UserNames) sb.append(" ").append(username); - sender.sendMessage(new String[] { "Player name: " + p.PlayerName, - "User flair: " + p.GetFormattedFlair(), - "Username: " + p.UserName, "Flair state: " + p.FlairState, - sb.toString(), "FCount: " + p.FCount, "FDeaths: " + p.FDeaths }); + sender.sendMessage(new String[] { "Player name: " + p.PlayerName, "User flair: " + p.GetFormattedFlair(), + "Username: " + p.UserName, "Flair state: " + p.FlairState, sb.toString(), "FCount: " + p.FCount, + "FDeaths: " + p.FDeaths }); return true; } diff --git a/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/SetFlairCommand.java b/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/SetFlairCommand.java index 13df666..0fbfd4e 100644 --- a/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/SetFlairCommand.java +++ b/src/buttondevteam/thebuttonmcchat/commands/ucmds/admin/SetFlairCommand.java @@ -5,7 +5,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import buttondevteam.thebuttonmcchat.FlairStates; -import buttondevteam.thebuttonmcchat.TBMCPlayer; +import buttondevteam.thebuttonmcchat.ChatPlayer; public class SetFlairCommand extends AdminCommandBase { @@ -32,11 +32,11 @@ public class SetFlairCommand extends AdminCommandBase { } short flairtime = 0x00; if (args[1].equalsIgnoreCase("non-presser")) - flairtime = TBMCPlayer.FlairTimeNonPresser; + flairtime = ChatPlayer.FlairTimeNonPresser; else if (args[1].equalsIgnoreCase("cant-press")) - flairtime = TBMCPlayer.FlairTimeCantPress; + flairtime = ChatPlayer.FlairTimeCantPress; else if (args[1].equalsIgnoreCase("none")) - flairtime = TBMCPlayer.FlairTimeNone; + flairtime = ChatPlayer.FlairTimeNone; else { try { flairtime = Short.parseShort(args[1]); @@ -54,7 +54,7 @@ public class SetFlairCommand extends AdminCommandBase { sender.sendMessage("§cUnknown value for cheater parameter. Run without args to see usage."); return true; } - TBMCPlayer mp = TBMCPlayer.AddPlayerIfNeeded(p + ChatPlayer mp = ChatPlayer.AddPlayerIfNeeded(p .getUniqueId()); mp.SetFlair(flairtime, cheater); mp.FlairState = FlairStates.Accepted;