From b5fd77747402ee10896ee716597890906e373106 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 7 Nov 2016 18:59:37 +0100 Subject: [PATCH 01/18] Fixed doc location --- src/main/java/buttondevteam/lib/chat/TBMCCommandBase.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/buttondevteam/lib/chat/TBMCCommandBase.java b/src/main/java/buttondevteam/lib/chat/TBMCCommandBase.java index 0379c9f..9576430 100644 --- a/src/main/java/buttondevteam/lib/chat/TBMCCommandBase.java +++ b/src/main/java/buttondevteam/lib/chat/TBMCCommandBase.java @@ -16,6 +16,8 @@ public abstract class TBMCCommandBase { } public abstract boolean OnCommand(CommandSender sender, String alias, String[] args); + + public abstract String[] GetHelpText(String alias); /** * The command's path, or name if top-level command.
@@ -26,9 +28,6 @@ public abstract class TBMCCommandBase { * * @return The command path, which is the command class name by default (removing any "command" from it) */ - - public abstract String[] GetHelpText(String alias); - public String GetCommandPath() { return getClass().getSimpleName().toLowerCase().replace("command", ""); } From a6502b6a1f4208d26806ec2854bad485c4b6cbc2 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 12 Nov 2016 20:30:49 +0100 Subject: [PATCH 02/18] Fixed getIntData() --- src/main/java/buttondevteam/lib/TBMCPlayer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/buttondevteam/lib/TBMCPlayer.java b/src/main/java/buttondevteam/lib/TBMCPlayer.java index bdb02c5..80cd053 100644 --- a/src/main/java/buttondevteam/lib/TBMCPlayer.java +++ b/src/main/java/buttondevteam/lib/TBMCPlayer.java @@ -157,8 +157,10 @@ public class TBMCPlayer implements AutoCloseable { if (!mname.startsWith("get")) throw new UnsupportedOperationException("Can only use getIntData from a getXYZ method"); Object obj = getLoadedPlayers().get(uuid).data.get(mname.substring("get".length()).toLowerCase()); - if (!(obj instanceof Integer)) - throw new UnsupportedOperationException("The retrieved object isn't a number: " + obj); + if (obj instanceof Short) + return (T) obj; + if (!(Integer.class.isAssignableFrom(obj.getClass()))) + throw new UnsupportedOperationException("The retrieved object isn't an integer: " + obj); Integer int_ = (Integer) obj; if (Short.class.isAssignableFrom(cl)) return (T) (Object) int_.shortValue(); From e2698179c78e5bbec953f0beb9405b2824a87d58 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 12 Nov 2016 21:04:41 +0100 Subject: [PATCH 03/18] Improved plugin update method --- .../java/buttondevteam/lib/TBMCCoreAPI.java | 49 ++++++++++++------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/src/main/java/buttondevteam/lib/TBMCCoreAPI.java b/src/main/java/buttondevteam/lib/TBMCCoreAPI.java index 09b6f9a..a968a6e 100644 --- a/src/main/java/buttondevteam/lib/TBMCCoreAPI.java +++ b/src/main/java/buttondevteam/lib/TBMCCoreAPI.java @@ -7,7 +7,6 @@ import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; -import java.nio.file.CopyOption; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.util.ArrayList; @@ -18,6 +17,7 @@ import java.util.Map.Entry; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; @@ -32,9 +32,11 @@ public final class TBMCCoreAPI { * * @param name * The plugin's repository name. - * @return Error message or empty string + * @param sender + * The command sender (if not console, messages will be printed to console as well). */ - public static String UpdatePlugin(String name) { + public static void UpdatePlugin(String name, CommandSender sender) { + info(sender, "Checking plugin name..."); List plugins = GetPluginNames(); String correctname = null; for (String plugin : plugins) { @@ -44,11 +46,9 @@ public final class TBMCCoreAPI { } } if (correctname == null) { - Bukkit.getLogger().warning("There was an error while updating TBMC plugin: " + name); - return "Can't find plugin: " + name; + error(sender, "Can't find plugin: " + name); } - Bukkit.getLogger().info("Updating TBMC plugin: " + correctname); - String ret = ""; + info(sender, "Updating TBMC plugin: " + correctname); URL url; File result = new File("plugins/" + correctname + ".jar_tmp"); File finalresult = new File("plugins/" + correctname + ".jar"); @@ -59,21 +59,36 @@ public final class TBMCCoreAPI { FileUtils.copyURLToFile(url, result); if (!result.exists() || result.length() < 25) { result.delete(); - ret = "The downloaded JAR is too small (smnaller than 25 bytes). Am I downloading from the right place?"; - } else + error(sender, "The downloaded JAR for " + correctname + + " is too small (smnaller than 25 bytes). Am I downloading from the right place?"); + } else { Files.move(result.toPath(), finalresult.toPath(), StandardCopyOption.REPLACE_EXISTING); + info(sender, "Updating plugin " + correctname + " done!"); + } } catch (FileNotFoundException e) { - ret = "Can't find JAR, the build probably failed. Build log (scroll to bottom):\nhttps://jitpack.io/com/github/TBMCPlugins/" - + correctname - + "/master-SNAPSHOT/build.log\nIf you'd like to rebuild the same commit, go to:\nhttps://jitpack.io/#TBMCPlugins/" - + correctname + "\nAnd delete the newest build."; + error(sender, + "Can't find JAR for " + correctname + ", the build probably failed. Build log (scroll to bottom):" + + "\n" + "https://jitpack.io/com/github/TBMCPlugins/" + correctname + + "/master-SNAPSHOT/build.log\nIf you'd like to rebuild the same commit, go to:\nhttps://jitpack.io/#TBMCPlugins/" + + correctname + "\nAnd delete the newest build."); } catch (IOException e) { - ret = "IO error!\n" + e.getMessage(); + error(sender, "IO error while updating " + correctname + "\n" + e.getMessage()); } catch (Exception e) { - Bukkit.getLogger().warning("Error!\n" + e); - ret = e.toString(); + e.printStackTrace(); + error(sender, "Unknown error while updating " + correctname + ": " + e); } - return ret; + } + + private static void error(CommandSender sender, String message) { + if (!sender.equals(Bukkit.getConsoleSender())) + Bukkit.getLogger().warning(message); + sender.sendMessage("§c" + message); + } + + private static void info(CommandSender sender, String message) { + if (!sender.equals(Bukkit.getConsoleSender())) + Bukkit.getLogger().info(message); + sender.sendMessage("§b" + message); } /** From 8dfea2032f335be890a35a3e14c1d8bc964327ed Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 15 Nov 2016 22:34:50 +0100 Subject: [PATCH 04/18] Moved everything for Channel.java --- .../java/buttondevteam/lib/chat/Channel.java | 36 +++++++++++++++++++ .../java/buttondevteam/lib/chat/Color.java | 19 ++++++++++ .../java/buttondevteam/lib/chat/Format.java | 24 +++++++++++++ .../java/buttondevteam/lib/chat/Priority.java | 14 ++++++++ .../buttondevteam/lib/chat/TBMCChatAPI.java | 5 +++ .../lib/chat/TellrawSerializableEnum.java | 5 +++ 6 files changed, 103 insertions(+) create mode 100644 src/main/java/buttondevteam/lib/chat/Channel.java create mode 100644 src/main/java/buttondevteam/lib/chat/Color.java create mode 100644 src/main/java/buttondevteam/lib/chat/Format.java create mode 100644 src/main/java/buttondevteam/lib/chat/Priority.java create mode 100644 src/main/java/buttondevteam/lib/chat/TellrawSerializableEnum.java diff --git a/src/main/java/buttondevteam/lib/chat/Channel.java b/src/main/java/buttondevteam/lib/chat/Channel.java new file mode 100644 index 0000000..5a257a4 --- /dev/null +++ b/src/main/java/buttondevteam/lib/chat/Channel.java @@ -0,0 +1,36 @@ +package buttondevteam.lib.chat; + +import java.util.ArrayList; +import java.util.List; + +public class Channel { + public final String DisplayName; + public final Color color; + public final String Command; + + private static List channels = new ArrayList<>(); + + public Channel(String displayname, Color color, String command) { + DisplayName = displayname; + this.color = color; + Command = command; + } + + static { + channels.add(GlobalChat = new Channel("§fg§f", Color.White, "g")); + channels.add(TownChat = new Channel("§3TC§f", Color.DarkAqua, "tc")); + channels.add(NationChat = new Channel("§6NC§f", Color.Gold, "nc")); + channels.add(AdminChat = new Channel("§cADMIN§f", Color.Red, "a")); + channels.add(ModChat = new Channel("§9MOD§f", Color.Blue, "mod")); + } + + public static List getChannels() { + return channels; + } + + public static Channel GlobalChat; + public static Channel TownChat; + public static Channel NationChat; + public static Channel AdminChat; + public static Channel ModChat; +} diff --git a/src/main/java/buttondevteam/lib/chat/Color.java b/src/main/java/buttondevteam/lib/chat/Color.java new file mode 100644 index 0000000..7849f98 --- /dev/null +++ b/src/main/java/buttondevteam/lib/chat/Color.java @@ -0,0 +1,19 @@ +package buttondevteam.lib.chat; + +public enum Color implements TellrawSerializableEnum { + Black("black"), DarkBlue("dark_blue"), DarkGreen("dark_green"), DarkAqua("dark_aqua"), DarkRed( + "dark_red"), DarkPurple("dark_purple"), Gold("gold"), Gray("gray"), DarkGray("dark_gray"), Blue( + "blue"), Green("green"), Aqua("aqua"), Red( + "red"), LightPurple("light_purple"), Yellow("yellow"), White("white"), RPC("rpc"); + + private String name; + + Color(String name) { + this.name = name; + } + + @Override + public String getName() { + return name; + } +} \ No newline at end of file diff --git a/src/main/java/buttondevteam/lib/chat/Format.java b/src/main/java/buttondevteam/lib/chat/Format.java new file mode 100644 index 0000000..b13d45b --- /dev/null +++ b/src/main/java/buttondevteam/lib/chat/Format.java @@ -0,0 +1,24 @@ +package buttondevteam.lib.chat; + +public enum Format implements TellrawSerializableEnum { + Bold("bold"), Underlined("underlined"), Italic("italic"), Strikethrough("strikethrough"), Obfuscated( + "obfuscated"); + // TODO: Add format codes to /u c + private String name; + + Format(String name) { + this.name = name; + this.flag = 1 << this.ordinal(); + } + + @Override + public String getName() { + return name; + } + + private final int flag; + + public int getFlag() { + return flag; + } +} \ No newline at end of file diff --git a/src/main/java/buttondevteam/lib/chat/Priority.java b/src/main/java/buttondevteam/lib/chat/Priority.java new file mode 100644 index 0000000..2a2f18f --- /dev/null +++ b/src/main/java/buttondevteam/lib/chat/Priority.java @@ -0,0 +1,14 @@ +package buttondevteam.lib.chat; + +public enum Priority { + Low(0), Normal(1), High(2); + private int val; + + Priority(int v) { + val = v; + } + + public int GetValue() { + return val; + } +} diff --git a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java index 6df5ab4..4d58544 100644 --- a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java +++ b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java @@ -6,6 +6,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Set; +import org.bukkit.command.CommandSender; import org.bukkit.plugin.java.JavaPlugin; import org.reflections.Reflections; import org.reflections.scanners.SubTypesScanner; @@ -160,4 +161,8 @@ public class TBMCChatAPI { } return true; } + + public static void SendChatMessage(Channel channel, CommandSender sender, String message) { + // TODO + } } diff --git a/src/main/java/buttondevteam/lib/chat/TellrawSerializableEnum.java b/src/main/java/buttondevteam/lib/chat/TellrawSerializableEnum.java new file mode 100644 index 0000000..1b10963 --- /dev/null +++ b/src/main/java/buttondevteam/lib/chat/TellrawSerializableEnum.java @@ -0,0 +1,5 @@ +package buttondevteam.lib.chat; + +public interface TellrawSerializableEnum { + public String getName(); +} From 656e136b49410d59a0a47f89aefded473b4d74e1 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 18 Nov 2016 20:13:39 +0100 Subject: [PATCH 05/18] Added overload to get subcmds without a cmd object --- .../java/buttondevteam/lib/chat/TBMCChatAPI.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java index 4d58544..82b3e65 100644 --- a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java +++ b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java @@ -31,11 +31,22 @@ public class TBMCChatAPI { * @return The subcommands */ public static String[] GetSubCommands(TBMCCommandBase command) { + return GetSubCommands(command.GetCommandPath()); + } + + /** + * Returns messages formatted for Minecraft chat listing the subcommands of the command. + * + * @param command + * The command which we want the subcommands of + * @return The subcommands + */ + public static String[] GetSubCommands(String command) { ArrayList cmds = new ArrayList(); cmds.add("§6---- Subcommands ----"); for (TBMCCommandBase cmd : TBMCChatAPI.GetCommands().values()) { - if (cmd.GetCommandPath().startsWith(command.GetCommandPath() + " ")) { - int ind = cmd.GetCommandPath().indexOf(' ', command.GetCommandPath().length() + 2); + if (cmd.GetCommandPath().startsWith(command + " ")) { + int ind = cmd.GetCommandPath().indexOf(' ', command.length() + 2); if (ind >= 0) continue; cmds.add("/" + cmd.GetCommandPath()); From c01063ccfab98e4426bab4a0692ae326a6d7b4a0 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 18 Nov 2016 20:17:59 +0100 Subject: [PATCH 06/18] Commented unnecessary messages out --- src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java index 82b3e65..1be4cda 100644 --- a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java +++ b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java @@ -115,7 +115,7 @@ public class TBMCChatAPI { * The command's class to create it (because why let you create the command class) */ public static void AddCommand(JavaPlugin plugin, Class thecmdclass, Object... params) { - plugin.getLogger().info("Registering command " + thecmdclass.getSimpleName() + " for " + plugin.getName()); + // plugin.getLogger().info("Registering command " + thecmdclass.getSimpleName() + " for " + plugin.getName()); try { TBMCCommandBase c; if (params.length > 0) @@ -151,7 +151,7 @@ public class TBMCChatAPI { public static void AddCommand(JavaPlugin plugin, TBMCCommandBase cmd) { if (!CheckForNulls(plugin, cmd)) return; - plugin.getLogger().info("Registering command /" + cmd.GetCommandPath() + " for " + plugin.getName()); + // plugin.getLogger().info("Registering command /" + cmd.GetCommandPath() + " for " + plugin.getName()); try { cmd.plugin = plugin; commands.put(cmd.GetCommandPath(), cmd); From 5b13548fa4b80af6e9db10d6fa7e428801f03788 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 18 Nov 2016 22:48:49 +0100 Subject: [PATCH 07/18] Started chat msg sending API... --- .../java/buttondevteam/lib/TBMCChatEvent.java | 47 +++++++++++++++++++ .../buttondevteam/lib/chat/TBMCChatAPI.java | 5 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/main/java/buttondevteam/lib/TBMCChatEvent.java diff --git a/src/main/java/buttondevteam/lib/TBMCChatEvent.java b/src/main/java/buttondevteam/lib/TBMCChatEvent.java new file mode 100644 index 0000000..2f00575 --- /dev/null +++ b/src/main/java/buttondevteam/lib/TBMCChatEvent.java @@ -0,0 +1,47 @@ +package buttondevteam.lib; + +import org.bukkit.command.CommandSender; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import buttondevteam.lib.chat.Channel; + +public class TBMCChatEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + + private Channel channel; + private CommandSender sender; + private String message; + + public TBMCChatEvent(CommandSender sender, Channel channel, String message) { + this.sender = sender; + this.channel = channel; + this.message = message; // TODO: Message object with data? + } + + /* + * public TBMCPlayer getPlayer() { return TBMCPlayer.getPlayer(sender); // TODO: Get Chroma user } + */ + + public Channel getChannel() { + return channel; + } + + public CommandSender getSender() { + return sender; + } + + public String getMessage() { + return message; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + +} diff --git a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java index 1be4cda..3a62ef6 100644 --- a/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java +++ b/src/main/java/buttondevteam/lib/chat/TBMCChatAPI.java @@ -6,6 +6,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Set; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.plugin.java.JavaPlugin; import org.reflections.Reflections; @@ -13,6 +14,7 @@ import org.reflections.scanners.SubTypesScanner; import org.reflections.util.ClasspathHelper; import org.reflections.util.ConfigurationBuilder; +import buttondevteam.lib.TBMCChatEvent; import buttondevteam.lib.TBMCCoreAPI; public class TBMCChatAPI { @@ -174,6 +176,7 @@ public class TBMCChatAPI { } public static void SendChatMessage(Channel channel, CommandSender sender, String message) { - // TODO + TBMCChatEvent event = new TBMCChatEvent(sender, channel, message); + Bukkit.getPluginManager().callEvent(event); } } From ba95f628a04d8fdf7c5440954b43b9a7b32a67f4 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 19 Nov 2016 19:20:07 +0100 Subject: [PATCH 08/18] Updated doc --- src/main/java/buttondevteam/lib/chat/TBMCCommandBase.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/buttondevteam/lib/chat/TBMCCommandBase.java b/src/main/java/buttondevteam/lib/chat/TBMCCommandBase.java index 9576430..111e057 100644 --- a/src/main/java/buttondevteam/lib/chat/TBMCCommandBase.java +++ b/src/main/java/buttondevteam/lib/chat/TBMCCommandBase.java @@ -14,17 +14,16 @@ public abstract class TBMCCommandBase { public TBMCCommandBase() { } - + public abstract boolean OnCommand(CommandSender sender, String alias, String[] args); - + public abstract String[] GetHelpText(String alias); /** * The command's path, or name if top-level command.
* For example:
* "u admin updateplugin" or "u" for the top level one
- *
- * Note: If you have a command which has subcommands (like /u admin), you need a separate command class for that as well. + * The path must be lowercase!
* * @return The command path, which is the command class name by default (removing any "command" from it) */ From 96daaf032d9163a51cde56e403e25758eb6e912e Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 19 Nov 2016 23:40:57 +0100 Subject: [PATCH 09/18] Moved debug potatoes from AliPresents --- .../buttondevteam/lib/DebugPotatoAPI.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/main/java/buttondevteam/lib/DebugPotatoAPI.java diff --git a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java new file mode 100644 index 0000000..6e6851c --- /dev/null +++ b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java @@ -0,0 +1,59 @@ +package buttondevteam.lib; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class DebugPotatoAPI { + public static ItemStack CreateDebugPotato(List message){ + ItemStack potato = new ItemStack(Material.BAKED_POTATO); + ItemMeta meta = potato.getItemMeta(); + meta.setDisplayName("Spicy Debug Potato"); + meta.setLore(message); + potato.setItemMeta(meta); + potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10); + return potato; + } + public static ItemStack CreateDebugPotato(String message){ + return CreateDebugPotato(Arrays.asList(message)); + } + public static void SendDebugPotato(Player player, List message){ + player.getInventory().addItem(CreateDebugPotato(message)); + player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SLIME_SQUISH, 0, 0); + return; + } + public static void SendDebugPotato(Player player, String[] message){ + SendDebugPotato(player, Arrays.asList(message)); + } + public static void SendDebugPotato(Player player, String message){ + + SendDebugPotato(player, StringToMessage(message)); + } + public static List StringToMessage(String message){ + String[] splitString = message.split("\\s+"); + List newMessage = new ArrayList(); + String currentLine = ""; + int currentLineLength = 0; + int wordlength; + int maxLineLength = 40; + for (String word : splitString){ + wordlength = word.length(); + if (currentLineLength == 0 || (currentLineLength + wordlength) < maxLineLength){ + currentLine += word + " "; + currentLineLength += wordlength +1; + }else{ + newMessage.add(currentLine); + currentLine = word + " "; + currentLineLength = word.length(); + } + } + return newMessage; + } +} From 1748bc0461822fbe133453dbb776d27b951b207e Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 19 Nov 2016 23:45:35 +0100 Subject: [PATCH 10/18] Small fixes and formatting --- .../buttondevteam/lib/DebugPotatoAPI.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java index 6e6851c..867b7fe 100644 --- a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java +++ b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java @@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; public class DebugPotatoAPI { - public static ItemStack CreateDebugPotato(List message){ + public static ItemStack CreateDebugPotato(List message) { ItemStack potato = new ItemStack(Material.BAKED_POTATO); ItemMeta meta = potato.getItemMeta(); meta.setDisplayName("Spicy Debug Potato"); @@ -21,34 +21,38 @@ public class DebugPotatoAPI { potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10); return potato; } - public static ItemStack CreateDebugPotato(String message){ - return CreateDebugPotato(Arrays.asList(message)); + + public static ItemStack CreateDebugPotato(String message) { + return CreateDebugPotato(WordWrap(message)); } - public static void SendDebugPotato(Player player, List message){ + + public static void SendDebugPotato(Player player, List message) { player.getInventory().addItem(CreateDebugPotato(message)); player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SLIME_SQUISH, 0, 0); return; } - public static void SendDebugPotato(Player player, String[] message){ + + public static void SendDebugPotato(Player player, String[] message) { SendDebugPotato(player, Arrays.asList(message)); } - public static void SendDebugPotato(Player player, String message){ - - SendDebugPotato(player, StringToMessage(message)); + + public static void SendDebugPotato(Player player, String message) { + SendDebugPotato(player, WordWrap(message)); } - public static List StringToMessage(String message){ + + public static List WordWrap(String message) { String[] splitString = message.split("\\s+"); List newMessage = new ArrayList(); String currentLine = ""; int currentLineLength = 0; int wordlength; int maxLineLength = 40; - for (String word : splitString){ + for (String word : splitString) { wordlength = word.length(); - if (currentLineLength == 0 || (currentLineLength + wordlength) < maxLineLength){ + if (currentLineLength == 0 || (currentLineLength + wordlength) < maxLineLength) { currentLine += word + " "; - currentLineLength += wordlength +1; - }else{ + currentLineLength += wordlength + 1; + } else { newMessage.add(currentLine); currentLine = word + " "; currentLineLength = word.length(); From 64faa95b3b0d61d9438cb82f8aef6645106fca09 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 20 Nov 2016 01:37:24 +0100 Subject: [PATCH 11/18] Added bug potatoes... --- .../java/buttondevteam/lib/TBMCCoreAPI.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/buttondevteam/lib/TBMCCoreAPI.java b/src/main/java/buttondevteam/lib/TBMCCoreAPI.java index a968a6e..01cdf23 100644 --- a/src/main/java/buttondevteam/lib/TBMCCoreAPI.java +++ b/src/main/java/buttondevteam/lib/TBMCCoreAPI.java @@ -13,11 +13,14 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; +import java.util.Optional; +import java.util.Random; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; @@ -125,6 +128,13 @@ public final class TBMCCoreAPI { private static HashMap exceptionsToSend = new HashMap<>(); + private static final String[] potatoMessages = new String[] { // + "Well shit", // + "Wait what", // + "Hwat", // + "Wat" // + }; + /** * Send exception to the {@link TBMCExceptionEvent}. * @@ -141,6 +151,13 @@ public final class TBMCCoreAPI { exceptionsToSend.put(sourcemsg, e); Bukkit.getLogger().warning(sourcemsg); e.printStackTrace(); + Optional randomPlayer = Bukkit.getOnlinePlayers().stream().findAny(); + if (randomPlayer.isPresent()) + DebugPotatoAPI.SendDebugPotato(randomPlayer.get(), + new String[] { // + "§b§o" + potatoMessages[new Random().nextInt(potatoMessages.length)], // + "§c§o" + sourcemsg, // + "§a§oFind a dev to fix this issue" }); } /** @@ -159,6 +176,10 @@ public final class TBMCCoreAPI { * Send exceptions that haven't been sent (their events didn't get handled). This method is used by the DiscordPlugin's ready event */ public static void SendUnsentExceptions() { + if (exceptionsToSend.size() > 20) { + exceptionsToSend.clear(); // Don't call more and more events if all the handler plugins are unloaded + Bukkit.getLogger().warning("Unhandled exception list is over 20! Clearing!"); + } for (Entry entry : exceptionsToSend.entrySet()) { TBMCExceptionEvent event = new TBMCExceptionEvent(entry.getKey(), entry.getValue()); Bukkit.getPluginManager().callEvent(event); From a713fb987ee3c2c7d95990dc98e5dbad0b5ba22c Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 20 Nov 2016 02:16:39 +0100 Subject: [PATCH 12/18] Reestructured debug potatoes and added per-exception names --- .../java/buttondevteam/lib/DebugPotato.java | 65 +++++++++++++++++++ .../buttondevteam/lib/DebugPotatoAPI.java | 49 ++------------ .../java/buttondevteam/lib/TBMCCoreAPI.java | 14 ++-- 3 files changed, 81 insertions(+), 47 deletions(-) create mode 100644 src/main/java/buttondevteam/lib/DebugPotato.java diff --git a/src/main/java/buttondevteam/lib/DebugPotato.java b/src/main/java/buttondevteam/lib/DebugPotato.java new file mode 100644 index 0000000..2b68089 --- /dev/null +++ b/src/main/java/buttondevteam/lib/DebugPotato.java @@ -0,0 +1,65 @@ +package buttondevteam.lib; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.entity.Player; + +public class DebugPotato { + private List message; + private String type; + + public void Send(Player player) { + DebugPotatoAPI.SendDebugPotato(this, player); + } + + public List getMessage() { + return message; + } + + public DebugPotato setMessage(List message) { + this.message = message; + return this; + } + + public DebugPotato setMessage(String message) { + this.message = WordWrap(message); + return this; + } + + public DebugPotato setMessage(String[] message) { + this.message = Arrays.asList(message); + return this; + } + + public String getType() { + return type; + } + + public DebugPotato setType(String type) { + this.type = type; + return this; + } + + public static List WordWrap(String message) { + String[] splitString = message.split("\\s+"); + List newMessage = new ArrayList(); + String currentLine = ""; + int currentLineLength = 0; + int wordlength; + int maxLineLength = 40; + for (String word : splitString) { + wordlength = word.length(); + if (currentLineLength == 0 || (currentLineLength + wordlength) < maxLineLength) { + currentLine += word + " "; + currentLineLength += wordlength + 1; + } else { + newMessage.add(currentLine); + currentLine = word + " "; + currentLineLength = word.length(); + } + } + return newMessage; + } +} diff --git a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java index 867b7fe..fa7d699 100644 --- a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java +++ b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java @@ -1,9 +1,5 @@ package buttondevteam.lib; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.enchantments.Enchantment; @@ -12,52 +8,21 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; public class DebugPotatoAPI { - public static ItemStack CreateDebugPotato(List message) { + private static ItemStack CreateDebugPotato(DebugPotato dp) { ItemStack potato = new ItemStack(Material.BAKED_POTATO); ItemMeta meta = potato.getItemMeta(); - meta.setDisplayName("Spicy Debug Potato"); - meta.setLore(message); + meta.setDisplayName(dp.getType() == null ? "Spicy Debug Potato" : dp.getType()); + if (dp.getMessage() == null) + throw new IllegalArgumentException("Potato message is empty!"); + meta.setLore(dp.getMessage()); potato.setItemMeta(meta); potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10); return potato; } - public static ItemStack CreateDebugPotato(String message) { - return CreateDebugPotato(WordWrap(message)); - } - - public static void SendDebugPotato(Player player, List message) { - player.getInventory().addItem(CreateDebugPotato(message)); + public static void SendDebugPotato(DebugPotato dp, Player player) { + player.getInventory().addItem(CreateDebugPotato(dp)); player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SLIME_SQUISH, 0, 0); return; } - - public static void SendDebugPotato(Player player, String[] message) { - SendDebugPotato(player, Arrays.asList(message)); - } - - public static void SendDebugPotato(Player player, String message) { - SendDebugPotato(player, WordWrap(message)); - } - - public static List WordWrap(String message) { - String[] splitString = message.split("\\s+"); - List newMessage = new ArrayList(); - String currentLine = ""; - int currentLineLength = 0; - int wordlength; - int maxLineLength = 40; - for (String word : splitString) { - wordlength = word.length(); - if (currentLineLength == 0 || (currentLineLength + wordlength) < maxLineLength) { - currentLine += word + " "; - currentLineLength += wordlength + 1; - } else { - newMessage.add(currentLine); - currentLine = word + " "; - currentLineLength = word.length(); - } - } - return newMessage; - } } diff --git a/src/main/java/buttondevteam/lib/TBMCCoreAPI.java b/src/main/java/buttondevteam/lib/TBMCCoreAPI.java index 01cdf23..f4dab65 100644 --- a/src/main/java/buttondevteam/lib/TBMCCoreAPI.java +++ b/src/main/java/buttondevteam/lib/TBMCCoreAPI.java @@ -153,11 +153,15 @@ public final class TBMCCoreAPI { e.printStackTrace(); Optional randomPlayer = Bukkit.getOnlinePlayers().stream().findAny(); if (randomPlayer.isPresent()) - DebugPotatoAPI.SendDebugPotato(randomPlayer.get(), - new String[] { // - "§b§o" + potatoMessages[new Random().nextInt(potatoMessages.length)], // - "§c§o" + sourcemsg, // - "§a§oFind a dev to fix this issue" }); + DebugPotatoAPI.SendDebugPotato( + new DebugPotato() + .setMessage(new String[] { // + "§b§o" + potatoMessages[new Random().nextInt(potatoMessages.length)], // + "§c§o" + sourcemsg, // + "§a§oFind a dev to fix this issue" }) + .setType(e instanceof IOException ? "Potato on a Stick" + : e instanceof ClassCastException ? "Square Potato" : "Plain Potato"), + randomPlayer.get()); } /** From 995f40c9abc82c0dcd036e31d18469029d81c26f Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 20 Nov 2016 02:26:43 +0100 Subject: [PATCH 13/18] Added documentation and Gary --- .../java/buttondevteam/lib/DebugPotato.java | 46 ++++++++++++++++++- src/main/java/buttondevteam/lib/Gary.java | 34 ++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/main/java/buttondevteam/lib/Gary.java diff --git a/src/main/java/buttondevteam/lib/DebugPotato.java b/src/main/java/buttondevteam/lib/DebugPotato.java index 2b68089..d55f124 100644 --- a/src/main/java/buttondevteam/lib/DebugPotato.java +++ b/src/main/java/buttondevteam/lib/DebugPotato.java @@ -10,39 +10,83 @@ public class DebugPotato { private List message; private String type; + /** + * Send the debug potato to a player + * + * @param player + * The player + */ public void Send(Player player) { DebugPotatoAPI.SendDebugPotato(this, player); } + /** + * Get the message (lore of the potato). + * + * @return The message + */ public List getMessage() { return message; } + /** + * Sets the message (lore of the potato). + * + * @param message + * The message + * @return This potato + */ public DebugPotato setMessage(List message) { this.message = message; return this; } + /** + * Sets the message (lore of the potato). It will be word wrapped automatically. + * + * @param message + * The message + * @return This potato + */ public DebugPotato setMessage(String message) { this.message = WordWrap(message); return this; } + /** + * Sets the message (lore of the potato). + * + * @param message + * The message + * @return This potato + */ public DebugPotato setMessage(String[] message) { this.message = Arrays.asList(message); return this; } + /** + * Gets the type (potato name). + * + * @return The type + */ public String getType() { return type; } + /** + * Sets the type (potato name). + * + * @param type + * The type + * @return This potato + */ public DebugPotato setType(String type) { this.type = type; return this; } - public static List WordWrap(String message) { + private static List WordWrap(String message) { String[] splitString = message.split("\\s+"); List newMessage = new ArrayList(); String currentLine = ""; diff --git a/src/main/java/buttondevteam/lib/Gary.java b/src/main/java/buttondevteam/lib/Gary.java new file mode 100644 index 0000000..beed5ca --- /dev/null +++ b/src/main/java/buttondevteam/lib/Gary.java @@ -0,0 +1,34 @@ +package buttondevteam.lib; + +import java.util.List; + +public class Gary extends DebugPotato { + + public Gary() { + super.setMessage("I'M A POTATO"); + } + + /** + * Gary has a fixed message, therefore this method has no effect. + */ + @Override + public DebugPotato setMessage(List message) { + return this; + } + + /** + * Gary has a fixed message, therefore this method has no effect. + */ + @Override + public DebugPotato setMessage(String message) { + return this; + } + + /** + * Gary has a fixed message, therefore this method has no effect. + */ + @Override + public DebugPotato setMessage(String[] message) { + return this; + } +} From 34529c76a61298ac3f7306b92c5d38997f7816f0 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sat, 19 Nov 2016 20:28:24 -0500 Subject: [PATCH 14/18] Made potatoes happy and fun --- src/main/java/buttondevteam/lib/DebugPotatoAPI.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java index fa7d699..be138c8 100644 --- a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java +++ b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java @@ -1,5 +1,8 @@ package buttondevteam.lib; +import java.util.ArrayList; +import java.util.List; + import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.enchantments.Enchantment; @@ -12,9 +15,13 @@ public class DebugPotatoAPI { ItemStack potato = new ItemStack(Material.BAKED_POTATO); ItemMeta meta = potato.getItemMeta(); meta.setDisplayName(dp.getType() == null ? "Spicy Debug Potato" : dp.getType()); - if (dp.getMessage() == null) - throw new IllegalArgumentException("Potato message is empty!"); - meta.setLore(dp.getMessage()); + if (dp.getMessage() == null){ + List message = new ArrayList(); + message.add("nullMessage"); + meta.setLore(message); + }else{ + meta.setLore(dp.getMessage()); + } potato.setItemMeta(meta); potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10); return potato; From aabc2b057fb65cdef28093d2fb169957d3636f80 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 20 Nov 2016 02:30:25 +0100 Subject: [PATCH 15/18] No! My way! --- src/main/java/buttondevteam/lib/DebugPotatoAPI.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java index be138c8..da415eb 100644 --- a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java +++ b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java @@ -15,13 +15,9 @@ public class DebugPotatoAPI { ItemStack potato = new ItemStack(Material.BAKED_POTATO); ItemMeta meta = potato.getItemMeta(); meta.setDisplayName(dp.getType() == null ? "Spicy Debug Potato" : dp.getType()); - if (dp.getMessage() == null){ - List message = new ArrayList(); - message.add("nullMessage"); - meta.setLore(message); - }else{ - meta.setLore(dp.getMessage()); - } + if (dp.getMessage() == null) + dp.setMessage("nullMessage"); + meta.setLore(dp.getMessage()); potato.setItemMeta(meta); potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10); return potato; From 282adbc09884d9cab939875108abdc5dea16633f Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 20 Nov 2016 02:44:22 +0100 Subject: [PATCH 16/18] Fixed NPE --- src/main/java/buttondevteam/lib/TBMCPlayer.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/buttondevteam/lib/TBMCPlayer.java b/src/main/java/buttondevteam/lib/TBMCPlayer.java index 80cd053..203328f 100644 --- a/src/main/java/buttondevteam/lib/TBMCPlayer.java +++ b/src/main/java/buttondevteam/lib/TBMCPlayer.java @@ -157,6 +157,8 @@ public class TBMCPlayer implements AutoCloseable { if (!mname.startsWith("get")) throw new UnsupportedOperationException("Can only use getIntData from a getXYZ method"); Object obj = getLoadedPlayers().get(uuid).data.get(mname.substring("get".length()).toLowerCase()); + if (obj == null) + return null; if (obj instanceof Short) return (T) obj; if (!(Integer.class.isAssignableFrom(obj.getClass()))) From fb41e090b80e742379fd55ee95c02fd8ad144059 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sat, 19 Nov 2016 21:12:16 -0500 Subject: [PATCH 17/18] Moved potatoToItemStack to potato Makes things neeater --- .../java/buttondevteam/lib/DebugPotato.java | 19 +++++++++++++ .../buttondevteam/lib/DebugPotatoAPI.java | 27 +------------------ 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/main/java/buttondevteam/lib/DebugPotato.java b/src/main/java/buttondevteam/lib/DebugPotato.java index d55f124..adb3c65 100644 --- a/src/main/java/buttondevteam/lib/DebugPotato.java +++ b/src/main/java/buttondevteam/lib/DebugPotato.java @@ -4,7 +4,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; public class DebugPotato { private List message; @@ -106,4 +110,19 @@ public class DebugPotato { } return newMessage; } + public ItemStack toItemStack() { + ItemStack potato = new ItemStack(Material.BAKED_POTATO); + ItemMeta meta = potato.getItemMeta(); + meta.setDisplayName(this.getType() == null ? "Spicy Debug Potato" : this.getType()); + if (this.getMessage() == null){ + List message = new ArrayList(); + message.add("nullMessage"); + meta.setLore(message); + }else{ + meta.setLore(this.getMessage()); + } + potato.setItemMeta(meta); + potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10); + return potato; + } } diff --git a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java index be138c8..99c690e 100644 --- a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java +++ b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java @@ -1,35 +1,10 @@ package buttondevteam.lib; -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; public class DebugPotatoAPI { - private static ItemStack CreateDebugPotato(DebugPotato dp) { - ItemStack potato = new ItemStack(Material.BAKED_POTATO); - ItemMeta meta = potato.getItemMeta(); - meta.setDisplayName(dp.getType() == null ? "Spicy Debug Potato" : dp.getType()); - if (dp.getMessage() == null){ - List message = new ArrayList(); - message.add("nullMessage"); - meta.setLore(message); - }else{ - meta.setLore(dp.getMessage()); - } - potato.setItemMeta(meta); - potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10); - return potato; - } - public static void SendDebugPotato(DebugPotato dp, Player player) { - player.getInventory().addItem(CreateDebugPotato(dp)); - player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SLIME_SQUISH, 0, 0); + player.getInventory().addItem(dp.toItemStack()); return; } } From 272068d39f9b242e883c7a08a9a11b3a888f9faa Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Mon, 21 Nov 2016 13:29:40 -0500 Subject: [PATCH 18/18] Moved Send() to DebugPotato, from DPAPI Moved DebugPotatoAPI.sendDebugPotato() to DebugPotato.send(), and deprecated DebugPotatoAPI. Changed TBMCCoreAPI to reflect the deprecation --- src/main/java/buttondevteam/lib/DebugPotato.java | 5 +++-- src/main/java/buttondevteam/lib/DebugPotatoAPI.java | 3 +++ src/main/java/buttondevteam/lib/TBMCCoreAPI.java | 10 +++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/buttondevteam/lib/DebugPotato.java b/src/main/java/buttondevteam/lib/DebugPotato.java index adb3c65..48f195a 100644 --- a/src/main/java/buttondevteam/lib/DebugPotato.java +++ b/src/main/java/buttondevteam/lib/DebugPotato.java @@ -20,8 +20,9 @@ public class DebugPotato { * @param player * The player */ - public void Send(Player player) { - DebugPotatoAPI.SendDebugPotato(this, player); + public void Send(Player player){ + player.getInventory().addItem(this.toItemStack()); + return; } /** diff --git a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java index 99c690e..5b78edd 100644 --- a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java +++ b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java @@ -2,7 +2,10 @@ package buttondevteam.lib; import org.bukkit.entity.Player; +/**@deprecated + * Fully Replaced by DebugPotato Class - Construct a DebugPotato*/ public class DebugPotatoAPI { + /**@deprecated Replaced by DebugPotato.send*/ public static void SendDebugPotato(DebugPotato dp, Player player) { player.getInventory().addItem(dp.toItemStack()); return; diff --git a/src/main/java/buttondevteam/lib/TBMCCoreAPI.java b/src/main/java/buttondevteam/lib/TBMCCoreAPI.java index f4dab65..56ba8ce 100644 --- a/src/main/java/buttondevteam/lib/TBMCCoreAPI.java +++ b/src/main/java/buttondevteam/lib/TBMCCoreAPI.java @@ -152,16 +152,16 @@ public final class TBMCCoreAPI { Bukkit.getLogger().warning(sourcemsg); e.printStackTrace(); Optional randomPlayer = Bukkit.getOnlinePlayers().stream().findAny(); - if (randomPlayer.isPresent()) - DebugPotatoAPI.SendDebugPotato( - new DebugPotato() + if (randomPlayer.isPresent()){ + DebugPotato potato = new DebugPotato() .setMessage(new String[] { // "§b§o" + potatoMessages[new Random().nextInt(potatoMessages.length)], // "§c§o" + sourcemsg, // "§a§oFind a dev to fix this issue" }) .setType(e instanceof IOException ? "Potato on a Stick" - : e instanceof ClassCastException ? "Square Potato" : "Plain Potato"), - randomPlayer.get()); + : e instanceof ClassCastException ? "Square Potato" : "Plain Potato"); + potato.Send(randomPlayer.get()); + } } /**