From fe51c015dbdc79f4288f2d356893cf796e41de18 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 29 Oct 2016 19:47:13 +0200 Subject: [PATCH] Removed reload command and fixed errors --- .../buttondevteam/chat/PlayerListener.java | 15 ++--- .../java/buttondevteam/chat/PluginMain.java | 62 +++++++++---------- .../chat/commands/ChatonlyCommand.java | 15 +++-- .../chat/commands/OOCCommand.java | 6 +- .../chat/commands/ucmds/AcceptCommand.java | 37 ++++++----- .../chat/commands/ucmds/CCommand.java | 3 +- .../chat/commands/ucmds/IgnoreCommand.java | 16 ++--- .../chat/commands/ucmds/NameCommand.java | 11 ++-- .../commands/ucmds/admin/ConfirmCommand.java | 47 -------------- .../ucmds/admin/PlayerInfoCommand.java | 17 +++-- .../commands/ucmds/admin/ReloadCommand.java | 31 ---------- .../commands/ucmds/admin/SetFlairCommand.java | 15 ++--- 12 files changed, 102 insertions(+), 173 deletions(-) delete mode 100644 src/main/java/buttondevteam/chat/commands/ucmds/admin/ConfirmCommand.java delete mode 100644 src/main/java/buttondevteam/chat/commands/ucmds/admin/ReloadCommand.java diff --git a/src/main/java/buttondevteam/chat/PlayerListener.java b/src/main/java/buttondevteam/chat/PlayerListener.java index c7b1679..fc0e40a 100644 --- a/src/main/java/buttondevteam/chat/PlayerListener.java +++ b/src/main/java/buttondevteam/chat/PlayerListener.java @@ -14,7 +14,6 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -68,9 +67,7 @@ public class PlayerListener implements Listener { @EventHandler public void onPlayerLoad(TBMCPlayerLoadEvent e) { - YamlConfiguration yc = e.GetPlayerConfig(); ChatPlayer cp = e.GetPlayer().asPluginPlayer(ChatPlayer.class); - short tcp = (short) yc.getInt("flairtime"); cp.FlairUpdate(); } @@ -187,7 +184,7 @@ public class PlayerListener implements Listener { if (event.getMessage().length() < 2) return; int index = event.getMessage().indexOf(" "); - ChatPlayer mp = ChatPlayer.OnlinePlayers.get(event.getPlayer().getUniqueId()); + ChatPlayer mp = TBMCPlayer.getPlayer(event.getPlayer()).asPluginPlayer(ChatPlayer.class); String cmd = ""; if (index == -1) { cmd = event.getMessage().substring(1); @@ -366,10 +363,10 @@ public class PlayerListener implements Listener { Ftimer.cancel(); ActiveF = true; FCount = 0; - FPlayer = ChatPlayer.OnlinePlayers.get(e.getEntity().getUniqueId()); - FPlayer.FDeaths++; + FPlayer = TBMCPlayer.getPlayer(e.getEntity().getUniqueId()).asPluginPlayer(ChatPlayer.class); + FPlayer.setFDeaths(FPlayer.getFDeaths() + 1); for (Player p : PluginMain.GetPlayers()) { - ChatPlayer mp = ChatPlayer.OnlinePlayers.get(p.getUniqueId()); + ChatPlayer mp = TBMCPlayer.getPlayerAs(p.getUniqueId(), ChatPlayer.class); mp.PressedF = false; p.sendMessage("§bPress F to pay respects.§r"); } @@ -430,14 +427,14 @@ public class PlayerListener implements Listener { @EventHandler public void onPlayerMove(PlayerMoveEvent e) { - ChatPlayer mp = ChatPlayer.GetFromPlayer(e.getPlayer()); + ChatPlayer mp = TBMCPlayer.getPlayerAs(e.getPlayer(), ChatPlayer.class); if (mp.ChatOnly) e.setCancelled(true); } @EventHandler(priority = EventPriority.LOWEST) public void onPlayerTeleport(PlayerTeleportEvent e) { - if (ChatPlayer.GetFromPlayer(e.getPlayer()).ChatOnly) { + if (TBMCPlayer.getPlayerAs(e.getPlayer(), ChatPlayer.class).ChatOnly) { e.setCancelled(true); e.getPlayer().sendMessage("§cYou are not allowed to teleport while in chat-only mode."); } diff --git a/src/main/java/buttondevteam/chat/PluginMain.java b/src/main/java/buttondevteam/chat/PluginMain.java index bdca296..212721d 100644 --- a/src/main/java/buttondevteam/chat/PluginMain.java +++ b/src/main/java/buttondevteam/chat/PluginMain.java @@ -18,6 +18,7 @@ import org.htmlcleaner.TagNode; import buttondevteam.chat.commands.CommandCaller; import buttondevteam.chat.commands.YeehawCommand; import buttondevteam.lib.TBMCCoreAPI; +import buttondevteam.lib.TBMCPlayer; import buttondevteam.lib.chat.TBMCChatAPI; import com.google.gson.JsonArray; @@ -70,7 +71,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. getServer().getPluginManager().registerEvents(new PlayerListener(), this); TBMCChatAPI.AddCommands(this, YeehawCommand.class); Console = this.getServer().getConsoleSender(); - LoadFiles(false); + LoadFiles(); SB = PluginMain.Instance.getServer().getScoreboardManager().getMainScoreboard(); // Main can be detected with @a[score_...] if (SB.getObjective("town") == null) @@ -138,19 +139,20 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. ign = ign.trim(); if (PlayersWithFlairs.contains(ign)) continue; - ChatPlayer mp = ChatPlayer.getFromName(ign); // Loads player file - if (mp == null) - continue; - /* - * if (!JoinedBefore(mp, 2015, 6, 5)) continue; - */ - if (!mp.UserNames.contains(author)) - mp.UserNames.add(author); - if (mp.FlairState.equals(FlairStates.NoComment)) { - mp.FlairState = FlairStates.Commented; - ConfirmUserMessage(mp); - } else - PlayersWithFlairs.add(ign); + try (ChatPlayer mp = TBMCPlayer.getFromName(ign).asPluginPlayer(ChatPlayer.class)) { // Loads player file + if (mp == null) + continue; + /* + * if (!JoinedBefore(mp, 2015, 6, 5)) continue; + */ + if (!mp.getUserNames().contains(author)) + mp.getUserNames().add(author); + if (mp.getFlairState().equals(FlairStates.NoComment)) { + mp.setFlairState(FlairStates.Commented); + ConfirmUserMessage(mp); + } else + PlayersWithFlairs.add(ign); + } try { Thread.sleep(10); } catch (InterruptedException ex) { @@ -169,8 +171,9 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. } public void DownloadFlair(ChatPlayer mp) throws MalformedURLException, IOException { - String[] flairdata = TBMCCoreAPI.DownloadString("http://karmadecay.com/thebutton-data.php?users=" + mp.UserName) - .replace("\"", "").split(":"); + String[] flairdata = TBMCCoreAPI + .DownloadString("http://karmadecay.com/thebutton-data.php?users=" + mp.getUserName()).replace("\"", "") + .split(":"); String flair; if (flairdata.length > 1) flair = flairdata[1]; @@ -181,14 +184,14 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. flairclass = flairdata[2]; else flairclass = "unknown"; - SetFlair(mp, flair, flairclass, mp.UserName); + SetFlair(mp, flair, flairclass, mp.getUserName()); } public static Exception LastException; private void SetFlair(ChatPlayer p, String text, String flairclass, String username) { - p.UserName = username; - p.FlairState = FlairStates.Recognised; + p.setUserName(username); + p.setFlairState(FlairStates.Recognised); switch (flairclass) { case "cheater": p.SetFlair(Short.parseShort(text), true); @@ -205,20 +208,20 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. p.SetFlair(ChatPlayer.FlairTimeCantPress); } } catch (Exception e) { - p.FlairState = FlairStates.Commented; // Flair unknown + p.setFlairState(FlairStates.Commented); // Flair unknown p.SetFlair(ChatPlayer.FlairTimeNone); e.printStackTrace(); } } else { try { if (CheckForJoinDate(p)) { - p.FlairState = FlairStates.Commented; // Flair unknown + p.setFlairState(FlairStates.Commented); // Flair unknown p.SetFlair(ChatPlayer.FlairTimeNone); } else { p.SetFlair(ChatPlayer.FlairTimeCantPress); } } catch (Exception e) { - p.FlairState = FlairStates.Commented; // Flair unknown + p.setFlairState(FlairStates.Commented); // Flair unknown p.SetFlair(ChatPlayer.FlairTimeNone); e.printStackTrace(); } @@ -235,7 +238,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. } 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); + URL url = new URL("https://www.reddit.com/u/" + mp.getUserName()); URLConnection con = url.openConnection(); con.setRequestProperty("User-Agent", "TheButtonAutoFlair"); InputStream in = con.getInputStream(); @@ -253,9 +256,9 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. } 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) + Player p = Bukkit.getPlayer(mp.getUuid()); + if (mp.getFlairState().equals(FlairStates.Commented) && p != null) + if (mp.getUserNames().size() > 1) p.sendMessage( "§9Multiple Reddit users commented your name. You can select with /u accept.§r §6Type /u accept or /u ignore§r"); else @@ -269,12 +272,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15. public static ArrayList AnnounceMessages = new ArrayList<>(); public static int AnnounceTime = 15 * 60 * 1000; - public static void LoadFiles(boolean reload) { - if (reload) { - PluginMain.Instance.getLogger().info("Cleanup for reloading..."); - ChatPlayer.OnlinePlayers.clear(); - AnnounceMessages.clear(); - } + public static void LoadFiles() { PluginMain.Instance.getLogger().info("Loading files..."); try { File file = new File("TBMC/chatsettings.yml"); diff --git a/src/main/java/buttondevteam/chat/commands/ChatonlyCommand.java b/src/main/java/buttondevteam/chat/commands/ChatonlyCommand.java index 0536ef6..90a71f9 100644 --- a/src/main/java/buttondevteam/chat/commands/ChatonlyCommand.java +++ b/src/main/java/buttondevteam/chat/commands/ChatonlyCommand.java @@ -5,25 +5,24 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import buttondevteam.chat.ChatPlayer; +import buttondevteam.lib.TBMCPlayer; import buttondevteam.lib.chat.TBMCCommandBase; public final class ChatonlyCommand extends TBMCCommandBase { @Override public String[] GetHelpText(String alias) { - return new String[]{ - "§6---- Chat-only mode ----", - "This mode makes you invincible but unable to move, teleport or interact with the world in any way", - "It was designed for chat clients", - "Once enabled, the only way of disabling it is by relogging to the server" + return new String[] { "§6---- Chat-only mode ----", // + "This mode makes you invincible but unable to move, teleport or interact with the world in any way", // + "It was designed for chat clients", // + "Once enabled, the only way of disabling it is by relogging to the server" // }; } @Override public boolean OnCommand(CommandSender sender, String alias, String[] args) { - Player player=(Player)sender; - ChatPlayer p = ChatPlayer.OnlinePlayers.get(player - .getUniqueId()); + Player player = (Player) sender; + ChatPlayer p = TBMCPlayer.getPlayerAs(player, ChatPlayer.class); p.ChatOnly = true; player.setGameMode(GameMode.SPECTATOR); player.sendMessage("§bChat-only mode enabled. You are now invincible."); diff --git a/src/main/java/buttondevteam/chat/commands/OOCCommand.java b/src/main/java/buttondevteam/chat/commands/OOCCommand.java index 0950427..c297a21 100644 --- a/src/main/java/buttondevteam/chat/commands/OOCCommand.java +++ b/src/main/java/buttondevteam/chat/commands/OOCCommand.java @@ -4,6 +4,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import buttondevteam.chat.ChatPlayer; +import buttondevteam.lib.TBMCPlayer; import buttondevteam.lib.chat.TBMCCommandBase; public final class OOCCommand extends TBMCCommandBase { @@ -21,12 +22,13 @@ public final class OOCCommand extends TBMCCommandBase { if (args.length == 0) { return false; } else { - ChatPlayer.GetFromPlayer(player).RPMode = false; + final ChatPlayer cp = TBMCPlayer.getPlayerAs(player, ChatPlayer.class); + cp.RPMode = false; String message = ""; for (String arg : args) message += arg + " "; player.chat(message.substring(0, message.length() - 1)); - ChatPlayer.GetFromPlayer(player).RPMode = true; + cp.RPMode = true; } return true; } diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/AcceptCommand.java b/src/main/java/buttondevteam/chat/commands/ucmds/AcceptCommand.java index 47cd952..7156db0 100644 --- a/src/main/java/buttondevteam/chat/commands/ucmds/AcceptCommand.java +++ b/src/main/java/buttondevteam/chat/commands/ucmds/AcceptCommand.java @@ -9,35 +9,36 @@ import buttondevteam.chat.ChatPlayer; import buttondevteam.chat.FlairStates; import buttondevteam.chat.PlayerJoinTimerTask; import buttondevteam.chat.PluginMain; +import buttondevteam.lib.TBMCPlayer; public class AcceptCommand extends UCommandBase { @Override public String[] GetHelpText(String alias) { - return new String[] { "§6---- Accept flair ----", - "Accepts a flair from Reddit", - "Use /u accept if you commented from multiple accounts" }; + return new String[] { "§6---- Accept flair ----", // + "Accepts a flair from Reddit", // + "Use /u accept if you commented from multiple accounts" // + }; } @Override public boolean OnCommand(CommandSender sender, String alias, String[] args) { final Player player = (Player) sender; - ChatPlayer p = ChatPlayer.GetFromPlayer(player); - if (args.length < 1 && p.UserNames.size() > 1) { + ChatPlayer p = TBMCPlayer.getPlayerAs(player, ChatPlayer.class); + if (args.length < 1 && p.getUserNames().size() > 1) { player.sendMessage("§9Multiple users commented your name. §bPlease pick one using /u accept "); StringBuilder sb = new StringBuilder(); sb.append("§6Usernames:"); - for (String username : p.UserNames) + for (String username : p.getUserNames()) sb.append(" ").append(username); player.sendMessage(sb.toString()); return true; } - if (p.FlairState.equals(FlairStates.NoComment) - || p.UserNames.size() == 0) { - player.sendMessage("§cError: You need to write your username to the reddit thread at /r/TheButtonMinecraft§r"); + if (p.getFlairState().equals(FlairStates.NoComment) || p.getUserNames().size() == 0) { + player.sendMessage("§cError: You need to write your username to the reddit thread at /r/ChromaGamers§r"); return true; } - if (args.length > 0 && !p.UserNames.contains(args[0])) { + if (args.length > 0 && !p.getUserNames().contains(args[0])) { player.sendMessage("§cError: Unknown name: " + args[0] + "§r"); return true; } @@ -46,14 +47,14 @@ public class AcceptCommand extends UCommandBase { return true; } - if ((args.length > 0 ? args[0] : p.UserNames.get(0)).equals(p.UserName)) { + if ((args.length > 0 ? args[0] : p.getUserNames().get(0)).equals(p.getUserName())) { player.sendMessage("§cYou already have this user's flair.§r"); return true; } if (args.length > 0) - p.UserName = args[0]; + p.setUserName(args[0]); else - p.UserName = p.UserNames.get(0); + p.setUserName(p.getUserNames().get(0)); player.sendMessage("§bObtaining flair..."); p.Working = true; @@ -65,18 +66,20 @@ public class AcceptCommand extends UCommandBase { PluginMain.Instance.DownloadFlair(mp); } catch (Exception e) { e.printStackTrace(); - player.sendMessage("Sorry, but an error occured while trying to get your flair. Please contact a mod."); + player.sendMessage( + "Sorry, but an error occured while trying to get your flair. Please contact a mod."); mp.Working = false; return; } - if (mp.FlairState.equals(FlairStates.Commented)) { - player.sendMessage("Sorry, but your flair isn't recorded. Please ask an admin to set it for you. Also, prepare a comment on /r/thebutton, if possible."); + if (mp.getFlairState().equals(FlairStates.Commented)) { + player.sendMessage( + "Sorry, but your flair isn't recorded. Please ask an admin to set it for you. Also, prepare a comment on /r/thebutton, if possible."); mp.Working = false; return; } String flair = mp.GetFormattedFlair(); - mp.FlairState = FlairStates.Accepted; + mp.setFlairState(FlairStates.Accepted); PluginMain.ConfirmUserMessage(mp); player.sendMessage("§bYour flair has been set:§r " + flair); mp.Working = false; diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/CCommand.java b/src/main/java/buttondevteam/chat/commands/ucmds/CCommand.java index 177f1e7..5001d92 100644 --- a/src/main/java/buttondevteam/chat/commands/ucmds/CCommand.java +++ b/src/main/java/buttondevteam/chat/commands/ucmds/CCommand.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Player; import buttondevteam.chat.ChatPlayer; import buttondevteam.chat.PluginMain; import buttondevteam.chat.formatting.ChatFormatter; +import buttondevteam.lib.TBMCPlayer; public class CCommand extends UCommandBase { @@ -18,7 +19,7 @@ public class CCommand extends UCommandBase { @Override public boolean OnCommand(CommandSender sender, String alias, String[] args) { Player player = (Player) sender; - ChatPlayer p = ChatPlayer.GetFromPlayer(player); + ChatPlayer p = TBMCPlayer.getPlayerAs(player, ChatPlayer.class); if (args.length < 1) { if (PluginMain.permission.has(player, "tbmc.rainbow")) { p.RainbowPresserColorMode = !p.RainbowPresserColorMode; diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/IgnoreCommand.java b/src/main/java/buttondevteam/chat/commands/ucmds/IgnoreCommand.java index d0268de..9bd5c5c 100644 --- a/src/main/java/buttondevteam/chat/commands/ucmds/IgnoreCommand.java +++ b/src/main/java/buttondevteam/chat/commands/ucmds/IgnoreCommand.java @@ -5,13 +5,13 @@ import org.bukkit.entity.Player; import buttondevteam.chat.ChatPlayer; import buttondevteam.chat.FlairStates; +import buttondevteam.lib.TBMCPlayer; public final class IgnoreCommand extends UCommandBase { @Override public String[] GetHelpText(String alias) { - return new String[] { - "§6---- Ignore flair ----", + return new String[] { "§6---- Ignore flair ----", "Stop the \"write your name in the thread\" message from showing up", "Use /u ignore if you commented from multiple accounts" }; } @@ -19,19 +19,19 @@ public final class IgnoreCommand extends UCommandBase { @Override public boolean OnCommand(CommandSender sender, String alias, String[] args) { final Player player = (Player) sender; - ChatPlayer p = ChatPlayer.GetFromPlayer(player); - if (p.FlairState.equals(FlairStates.Accepted)) { + ChatPlayer p = TBMCPlayer.getPlayerAs(player, ChatPlayer.class); + if (p.getFlairState().equals(FlairStates.Accepted)) { player.sendMessage("§cYou can only ignore the \"write your name in the thread\" message."); return true; } - if (p.FlairState.equals(FlairStates.Commented)) { + if (p.getFlairState().equals(FlairStates.Commented)) { player.sendMessage("Sorry, but your flair isn't recorded. Please ask a mod to set it for you."); return true; } - if (!p.FlairState.equals(FlairStates.Ignored)) { - p.FlairState = FlairStates.Ignored; + if (!p.getFlairState().equals(FlairStates.Ignored)) { + p.setFlairState(FlairStates.Ignored); p.SetFlair(ChatPlayer.FlairTimeNone); - p.UserName = ""; + p.setUserName(""); player.sendMessage("§bYou have ignored the message.§r"); } else player.sendMessage("§cYou already ignored the message.§r"); diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/NameCommand.java b/src/main/java/buttondevteam/chat/commands/ucmds/NameCommand.java index 02adfb0..8e77d85 100644 --- a/src/main/java/buttondevteam/chat/commands/ucmds/NameCommand.java +++ b/src/main/java/buttondevteam/chat/commands/ucmds/NameCommand.java @@ -3,13 +3,13 @@ package buttondevteam.chat.commands.ucmds; import org.bukkit.command.CommandSender; import buttondevteam.chat.ChatPlayer; +import buttondevteam.lib.TBMCPlayer; public class NameCommand extends UCommandBase { @Override public String[] GetHelpText(String alias) { - return new String[] { - "§6---- Get username ----", + return new String[] { "§6---- Get username ----", "This command allows you to see the Reddit username of a player if they have one associated", "Usage: /u name " }; } @@ -19,13 +19,12 @@ public class NameCommand extends UCommandBase { if (args.length == 0) { return false; } - ChatPlayer mp = ChatPlayer.getFromName(args[0]); + ChatPlayer mp = TBMCPlayer.getFromName(args[0]).asPluginPlayer(ChatPlayer.class); if (mp == null) { - sender.sendMessage("§cUnknown user: " - + args[0]); + sender.sendMessage("§cUnknown user: " + args[0]); return true; } - sender.sendMessage("§bUsername of " + args[0] + ": " + mp.UserName); + sender.sendMessage("§bUsername of " + args[0] + ": " + mp.getUserName()); return true; } diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/admin/ConfirmCommand.java b/src/main/java/buttondevteam/chat/commands/ucmds/admin/ConfirmCommand.java deleted file mode 100644 index 2a667db..0000000 --- a/src/main/java/buttondevteam/chat/commands/ucmds/admin/ConfirmCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -package buttondevteam.chat.commands.ucmds.admin; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import buttondevteam.chat.ChatPlayer; -import buttondevteam.chat.PluginMain; - -public class ConfirmCommand extends AdminCommandBase { - - @Override - public String[] GetHelpText(String alias) { - return new String[] { "§6--- Confirm reload ----", "Use this after using /u admin reload and /u admin save" }; - } - - @Override - public boolean OnCommand(CommandSender sender, String alias, String[] args) { - if (ReloadCommand.Reloader == sender) { - try { - if (sender != PluginMain.Console) - PluginMain.Console.sendMessage("§6-- Reloading The Button Minecraft plugin...§r"); - sender.sendMessage("§6-- Reloading The Button Minecraft plugin...§r"); - PluginMain.LoadFiles(true); - // TODO: Add players online - for (Player p : PluginMain.GetPlayers()) - ChatPlayer.GetFromPlayer(p); // TODO: Reload other TBMC plugin data? - if (sender != PluginMain.Console) - PluginMain.Console.sendMessage("§6-- Reloading done!§r"); - sender.sendMessage("§6-- Reloading done!§r"); - ReloadCommand.Reloader = null; - } catch (Exception e) { - PluginMain.Instance.getLogger().warning("Error!\n" + e); - if (sender != PluginMain.Console) - sender.sendMessage("§cAn error occured. See console for details.§r"); - PluginMain.LastException = e; - } - } else - sender.sendMessage("§cYou need to do /u admin reload first.§r"); - return true; - } - - @Override - public String GetAdminCommandPath() { - return "confirm"; - } - -} diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/admin/PlayerInfoCommand.java b/src/main/java/buttondevteam/chat/commands/ucmds/admin/PlayerInfoCommand.java index a28aef1..5a2401d 100644 --- a/src/main/java/buttondevteam/chat/commands/ucmds/admin/PlayerInfoCommand.java +++ b/src/main/java/buttondevteam/chat/commands/ucmds/admin/PlayerInfoCommand.java @@ -3,6 +3,7 @@ package buttondevteam.chat.commands.ucmds.admin; import org.bukkit.command.CommandSender; import buttondevteam.chat.ChatPlayer; +import buttondevteam.lib.TBMCPlayer; public class PlayerInfoCommand extends AdminCommandBase { @@ -18,18 +19,24 @@ public class PlayerInfoCommand extends AdminCommandBase { if (args.length == 0) { return false; } - ChatPlayer p = ChatPlayer.getFromName(args[0]); + ChatPlayer p = TBMCPlayer.getFromName(args[0]).asPluginPlayer(ChatPlayer.class); if (p == null) { sender.sendMessage("§cPlayer not found: " + args[0] + "§r"); return true; } StringBuilder sb = new StringBuilder(); sb.append("§6Usernames:"); - for (String username : p.UserNames) + for (String username : p.getUserNames()) 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.getPlayerName(), // + "User flair: " + p.GetFormattedFlair(), // + "Username: " + p.getUserName(), // + "Flair state: " + p.getFlairState(), // + sb.toString(), // + "FCount: " + p.getFCount(), // + "FDeaths: " + p.getFDeaths() // + }); return true; } diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/admin/ReloadCommand.java b/src/main/java/buttondevteam/chat/commands/ucmds/admin/ReloadCommand.java deleted file mode 100644 index 5d45ed1..0000000 --- a/src/main/java/buttondevteam/chat/commands/ucmds/admin/ReloadCommand.java +++ /dev/null @@ -1,31 +0,0 @@ -package buttondevteam.chat.commands.ucmds.admin; - -import org.bukkit.command.CommandSender; - -public final class ReloadCommand extends AdminCommandBase { - - @Override - public String[] GetHelpText(String alias) { - return new String[] { "§6---- Reload plugin ----", "This command allows you to reload the plugin's config", - "This isn't the same as reloading the server, and should not cause any issues with other plugins", - "Save the config by using /u admin save before you reload it", - "Because of this, you'll need to confirm the reload with /u admin confirm" }; - } - - public static CommandSender Reloader; - - @Override - public boolean OnCommand(CommandSender sender, String alias, String[] args) { - Reloader = sender; - sender.sendMessage( - "§bMake sure to save the current settings before you modify and reload them! Type /u admin confirm when ready.§r"); - sender.sendMessage("§bNote that this command may not set players up correctly as of now."); - return true; - } - - @Override - public String GetAdminCommandPath() { - return "reload"; - } - -} diff --git a/src/main/java/buttondevteam/chat/commands/ucmds/admin/SetFlairCommand.java b/src/main/java/buttondevteam/chat/commands/ucmds/admin/SetFlairCommand.java index dc90362..1f0934f 100644 --- a/src/main/java/buttondevteam/chat/commands/ucmds/admin/SetFlairCommand.java +++ b/src/main/java/buttondevteam/chat/commands/ucmds/admin/SetFlairCommand.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Player; import buttondevteam.chat.ChatPlayer; import buttondevteam.chat.FlairStates; +import buttondevteam.lib.TBMCPlayer; public class SetFlairCommand extends AdminCommandBase { @@ -52,18 +53,18 @@ public class SetFlairCommand extends AdminCommandBase { sender.sendMessage("§cUnknown value for cheater parameter. Run without args to see usage."); return true; } - ChatPlayer mp = ChatPlayer.GetFromPlayer(p); + ChatPlayer mp = TBMCPlayer.getPlayerAs(p, ChatPlayer.class); mp.SetFlair(flairtime, cheater); - mp.FlairState = FlairStates.Accepted; + mp.setFlairState(FlairStates.Accepted); if (args.length < 4) - mp.UserName = ""; + mp.setUserName(""); else { - mp.UserName = args[3]; - if (!mp.UserNames.contains(args[3])) - mp.UserNames.add(args[3]); + mp.setUserName(args[3]); + if (!mp.getUserNames().contains(args[3])) + mp.getUserNames().add(args[3]); } sender.sendMessage( - "§bThe flair has been set. Player: " + mp.PlayerName + " Flair: " + mp.GetFormattedFlair() + "§r"); + "§bThe flair has been set. Player: " + mp.getPlayerName() + " Flair: " + mp.GetFormattedFlair() + "§r"); return true; }