From 88557f85cb5b1aad467529a2dad38978a9d05869 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 25 Jun 2016 12:51:04 +0200 Subject: [PATCH] Numerous fixes related to reloading the plugin, flairs and yeehaws --- plugin.yml | 2 ++ .../norbipeti/thebuttonmcchat/MaybeOfflinePlayer.java | 3 +++ src/io/github/norbipeti/thebuttonmcchat/PlayerListener.java | 1 - .../norbipeti/thebuttonmcchat/commands/CommandCaller.java | 4 ++-- .../norbipeti/thebuttonmcchat/commands/MWikiCommand.java | 2 +- .../norbipeti/thebuttonmcchat/commands/YeehawCommand.java | 2 +- .../thebuttonmcchat/commands/appendtext/ShrugCommand.java | 2 +- .../commands/ucmds/admin/ConfirmCommand.java | 6 ++++++ .../thebuttonmcchat/commands/ucmds/admin/ReloadCommand.java | 2 +- 9 files changed, 17 insertions(+), 7 deletions(-) diff --git a/plugin.yml b/plugin.yml index d25bbc3..36f08e6 100644 --- a/plugin.yml +++ b/plugin.yml @@ -21,6 +21,8 @@ commands: description: Enable chat only mode. Useful for chat clients. shrug: description: Shrug. + yeehaw: + description: This command makes you yeehaw. author: NorbiPeti depend: [Essentials, Towny, Minigames, Votifier, WorldGuard, WorldEdit, ProtocolLib, FastLogin, Vault, AuthMe] permissions: diff --git a/src/io/github/norbipeti/thebuttonmcchat/MaybeOfflinePlayer.java b/src/io/github/norbipeti/thebuttonmcchat/MaybeOfflinePlayer.java index b4ab8cf..e026b21 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/MaybeOfflinePlayer.java +++ b/src/io/github/norbipeti/thebuttonmcchat/MaybeOfflinePlayer.java @@ -46,6 +46,9 @@ public class MaybeOfflinePlayer { player.FlairTime = FlairTimeNone; player.FlairState = FlairStates.NoComment; player.UserNames = new ArrayList<>(); + Player p = Bukkit.getPlayer(uuid); + if (p != null) + player.PlayerName = p.getName(); AllPlayers.put(uuid, player); return player; } diff --git a/src/io/github/norbipeti/thebuttonmcchat/PlayerListener.java b/src/io/github/norbipeti/thebuttonmcchat/PlayerListener.java index 9161b60..65a6935 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/PlayerListener.java +++ b/src/io/github/norbipeti/thebuttonmcchat/PlayerListener.java @@ -74,7 +74,6 @@ public class PlayerListener implements Listener { final Player p = event.getPlayer(); MaybeOfflinePlayer mp = MaybeOfflinePlayer.AddPlayerIfNeeded(p .getUniqueId()); - mp.PlayerName = p.getName(); if (!mp.FlairState.equals(FlairStates.NoComment)) { PluginMain.ConfirmUserMessage(mp); Timer timer = new Timer(); diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/CommandCaller.java b/src/io/github/norbipeti/thebuttonmcchat/commands/CommandCaller.java index b398d95..3836765 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/CommandCaller.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/CommandCaller.java @@ -63,8 +63,8 @@ public class CommandCaller implements CommandExecutor { { PluginCommand pc = plugin.getCommand(c.GetCommandPath()); if (pc == null) - System.out.println("Can't find top-level command: " - + c.GetCommandPath()); + new Exception("Can't find top-level command: " + + c.GetCommandPath()).printStackTrace(); else pc.setExecutor(cc); } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/MWikiCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/MWikiCommand.java index 1226fa8..1041b97 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/MWikiCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/MWikiCommand.java @@ -26,7 +26,7 @@ public class MWikiCommand extends TBMCCommandBase { else sender.sendMessage("§bMinecraft Wiki link: http://minecraft.gamepedia.com/index.php?search=" + query + "&title=Special%3ASearch&go=Go"); - return false; + return true; } @Override diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/YeehawCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/YeehawCommand.java index 35739e0..b21dace 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/YeehawCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/YeehawCommand.java @@ -19,7 +19,7 @@ public class YeehawCommand extends TBMCCommandBase { p.playSound(p.getLocation(), "tbmc.yeehaw", 1f, 1f); p.sendMessage("§b* " + (sender instanceof Player ? ((Player) sender) - .getDisplayName() : sender.getName()) + " YEEHAWs."); + .getDisplayName() : sender.getName()) + " §bYEEHAWs."); } //Even a cmdblock could yeehaw in theory return true; } diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/appendtext/ShrugCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/appendtext/ShrugCommand.java index 8fc8475..aa69e73 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/appendtext/ShrugCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/appendtext/ShrugCommand.java @@ -12,7 +12,7 @@ public final class ShrugCommand extends AppendTextCommandBase { @Override public String GetAppendedText() { - return "¯\\_(ツ)_/¯"; + return "¯\\\\\\_(ツ)\\_/¯"; //TODO: Escape format codes } @Override diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ConfirmCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ConfirmCommand.java index 894e55c..2b5d050 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ConfirmCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ConfirmCommand.java @@ -1,8 +1,10 @@ package io.github.norbipeti.thebuttonmcchat.commands.ucmds.admin; +import io.github.norbipeti.thebuttonmcchat.MaybeOfflinePlayer; import io.github.norbipeti.thebuttonmcchat.PluginMain; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; public class ConfirmCommand extends AdminCommandBase { @@ -21,9 +23,13 @@ public class ConfirmCommand extends AdminCommandBase { .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()) + MaybeOfflinePlayer.AddPlayerIfNeeded(p.getUniqueId()); if (sender != PluginMain.Console) PluginMain.Console.sendMessage("§6-- Reloading done!§r"); sender.sendMessage("§6-- Reloading done!§r"); + ReloadCommand.Reloader = null; } catch (Exception e) { System.out.println("Error!\n" + e); if (sender != PluginMain.Console) diff --git a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ReloadCommand.java b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ReloadCommand.java index 9230fcd..ea332e1 100644 --- a/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ReloadCommand.java +++ b/src/io/github/norbipeti/thebuttonmcchat/commands/ucmds/admin/ReloadCommand.java @@ -20,7 +20,7 @@ public final class ReloadCommand extends AdminCommandBase { 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 done.§r"); + sender.sendMessage("§bMake sure to save the current settings before you modify and reload them! Type /u admin confirm when ready.§r"); return true; }