Add in standard usage message for commands that have improper syntax.

This commit is contained in:
Steven Lawson 2013-04-09 22:32:04 -04:00
parent 3c9ca8c08a
commit e665d5fcbf
3 changed files with 31 additions and 6 deletions

View File

@ -1,5 +1,5 @@
#Tue, 09 Apr 2013 22:12:33 -0400 #Tue, 09 Apr 2013 22:30:34 -0400
program.VERSION=2.13 program.VERSION=2.13
program.BUILDNUM=155 program.BUILDNUM=157
program.BUILDDATE=04/09/2013 10\:12 PM program.BUILDDATE=04/09/2013 10\:30 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Tue Apr 09 22:12:33 EDT 2013 #Tue Apr 09 22:30:34 EDT 2013
build.number=156 build.number=158

View File

@ -14,6 +14,7 @@ import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandMap; import org.bukkit.command.CommandMap;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginIdentifiableCommand; import org.bukkit.command.PluginIdentifiableCommand;
@ -206,7 +207,31 @@ public class TFM_CommandLoader
@Override @Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) public boolean execute(CommandSender sender, String commandLabel, String[] args)
{ {
return getPlugin().onCommand(sender, this, commandLabel, args); boolean success = false;
if (!getPlugin().isEnabled())
{
return false;
}
try
{
success = getPlugin().onCommand(sender, this, commandLabel, args);
}
catch (Throwable ex)
{
throw new CommandException("Unhandled exception executing command '" + commandLabel + "' in plugin " + getPlugin().getDescription().getFullName(), ex);
}
if (!success && getUsage().length() > 0)
{
for (String line : getUsage().replace("<command>", commandLabel).split("\n"))
{
sender.sendMessage(line);
}
}
return success;
} }
@Override @Override