From c2bebbcdbbeafa61e0ffd5faf5bc78bc16afcc69 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Fri, 19 Oct 2012 15:46:28 -0500 Subject: [PATCH] Override toString() method in Command Overriding the toString() method provides more human-readable feedback when a problem occurs, including the version of the plugin if applicable. By: Wesley Wolfe --- paper-api/src/main/java/org/bukkit/command/Command.java | 5 +++++ .../src/main/java/org/bukkit/command/PluginCommand.java | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/command/Command.java b/paper-api/src/main/java/org/bukkit/command/Command.java index b0b7f21f1c..1695742527 100644 --- a/paper-api/src/main/java/org/bukkit/command/Command.java +++ b/paper-api/src/main/java/org/bukkit/command/Command.java @@ -350,4 +350,9 @@ public abstract class Command { } } } + + @Override + public String toString() { + return getClass().getName() + '(' + name + ')'; + } } diff --git a/paper-api/src/main/java/org/bukkit/command/PluginCommand.java b/paper-api/src/main/java/org/bukkit/command/PluginCommand.java index f82e3ed368..d34140c303 100644 --- a/paper-api/src/main/java/org/bukkit/command/PluginCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/PluginCommand.java @@ -144,4 +144,12 @@ public final class PluginCommand extends Command implements PluginIdentifiableCo } return completions; } + + @Override + public String toString() { + StringBuilder stringBuilder = new StringBuilder(super.toString()); + stringBuilder.deleteCharAt(stringBuilder.length() - 1); + stringBuilder.append(", ").append(owningPlugin.getDescription().getFullName()).append(')'); + return stringBuilder.toString(); + } }