Made command path automatically determined

This commit is contained in:
Norbi Peti 2016-11-03 17:11:21 +01:00
parent 90dd6d190e
commit b4f74f993b

View file

@ -1,26 +1,47 @@
package buttondevteam.lib.chat; package buttondevteam.lib.chat;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public abstract class TBMCCommandBase { public abstract class TBMCCommandBase {
public TBMCCommandBase() { public TBMCCommandBase() {
} }
public abstract String[] GetHelpText(String alias); public abstract String[] GetHelpText(String alias);
public abstract boolean OnCommand(CommandSender sender, String alias, String[] args); public abstract boolean OnCommand(CommandSender sender, String alias, String[] args);
public abstract String GetCommandPath(); /**
* The command's path, or name if top-level command.<br>
public abstract boolean GetPlayerOnly(); * For example:<br>
* "u admin updateplugin" or "u" for the top level one<br>
public abstract boolean GetModOnly(); * <br>
* <u>Note:</u> If you have a command which has subcommands (like /u admin), you need a separate command class for that as well.
Plugin plugin; // Used By TBMCChatAPI *
* @return The command path, <i>which is the command class name by default</i> (removing any "command" from it)
public Plugin getPlugin() { // Used by CommandCaller (ButtonChat) */
return plugin; public String GetCommandPath() {
} return getClass().getSimpleName().toLowerCase().replace("command", "");
} }
/**
* Determines whether the command can only be used as a player, or command blocks or the console can use it as well.
*
* @return If the command is player only
*/
public abstract boolean GetPlayerOnly();
/**
* Determines whether the command can only be used by mods or regular players can use it as well.
*
* @return If the command is mod only
*/
public abstract boolean GetModOnly();
Plugin plugin; // Used By TBMCChatAPI
public final Plugin getPlugin() { // Used by CommandCaller (ButtonChat)
return plugin;
}
}