summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <md_5@bigpond.com>2012-02-11 13:45:15 +1100
committermd_5 <md_5@bigpond.com>2012-02-12 08:19:24 +1100
commit62cd219b4ecd48464037dd898ed14ab7de4972b2 (patch)
tree79dd5e7029aee409c8e2b46abe54599e0a9655e6
parent2d56de1483a8dbd75cba146fae4a0dbe4270b1e3 (diff)
downloadEssentials-62cd219b4ecd48464037dd898ed14ab7de4972b2.tar
Essentials-62cd219b4ecd48464037dd898ed14ab7de4972b2.tar.gz
Essentials-62cd219b4ecd48464037dd898ed14ab7de4972b2.tar.lz
Essentials-62cd219b4ecd48464037dd898ed14ab7de4972b2.tar.xz
Essentials-62cd219b4ecd48464037dd898ed14ab7de4972b2.zip
Clean up the CommandException stack traces so they appear as if Essentials was never there.
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java
index 21f2e38ea..3ee7c1777 100644
--- a/Essentials/src/com/earth2me/essentials/Essentials.java
+++ b/Essentials/src/com/earth2me/essentials/Essentials.java
@@ -32,15 +32,20 @@ import com.earth2me.essentials.signs.SignPlayerListener;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
+import java.lang.reflect.Array;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.Command;
+import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
@@ -277,7 +282,29 @@ public class Essentials extends JavaPlugin implements IEssentials
if (pc != null)
{
alternativeCommandsHandler.executed(commandLabel, pc.getLabel());
- return pc.execute(sender, commandLabel, args);
+ try
+ {
+ return pc.execute(sender, commandLabel, args);
+ }
+ catch (final Exception ex)
+ {
+ final ArrayList<StackTraceElement> elements = new ArrayList<StackTraceElement>(Arrays.asList(ex.getStackTrace()));
+ elements.remove(0);
+ final ArrayList<StackTraceElement> toRemove = new ArrayList<StackTraceElement>();
+ for (final StackTraceElement e : elements)
+ {
+ if (e.getClassName().equals("com.earth2me.essentials.Essentials"))
+ {
+ toRemove.add(e);
+ }
+ }
+ elements.removeAll(toRemove);
+ final StackTraceElement[] trace = elements.toArray(new StackTraceElement[elements.size()]);
+ ex.setStackTrace(trace);
+ ex.printStackTrace();
+ sender.sendMessage(ChatColor.RED + "An internal error occurred while attempting to perform this command");
+ return true;
+ }
}
}