TF-PlotSquared/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java

137 lines
5.1 KiB
Java
Raw Normal View History

2014-11-08 20:27:09 +01:00
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
2014-09-22 13:02:14 +02:00
package com.intellectualcrafters.plot.commands;
2014-11-16 10:48:18 +01:00
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.util.PlayerFunctions;
2014-11-08 20:27:09 +01:00
import org.bukkit.entity.Player;
2014-09-22 13:02:14 +02:00
/**
* SubCommand class
*
2014-09-22 13:02:14 +02:00
* @author Citymonstret
*/
2014-11-09 12:51:17 +01:00
@SuppressWarnings({"deprecation", "unused", "javadoc"})
2014-09-22 13:02:14 +02:00
public abstract class SubCommand {
2014-11-08 20:27:09 +01:00
public boolean isPlayer;
2014-11-05 14:42:08 +11:00
/**
* Command
*/
2014-11-08 20:27:09 +01:00
public String cmd;
2014-11-05 14:42:08 +11:00
/**
* Permission node
*/
public CommandPermission permission;
/**
* Simple description
*/
2014-11-08 20:27:09 +01:00
public String description;
2014-11-05 14:42:08 +11:00
/**
* Alias
*/
2014-11-08 20:27:09 +01:00
public String alias;
2014-09-22 13:02:14 +02:00
2014-11-05 14:42:08 +11:00
/**
* Command usage
*/
2014-11-08 20:27:09 +01:00
public String usage;
2014-09-22 13:02:14 +02:00
2014-11-08 20:27:09 +01:00
public CommandCategory category;
2014-09-22 13:02:14 +02:00
2014-11-05 14:42:08 +11:00
/**
2014-11-08 20:27:09 +01:00
* @param cmd Command /plot {cmd} <-- That!
* @param permission Permission Node
* @param description Simple description
* @param usage Usage description: /plot command {args...}
* @param alias Command alias
* @param category CommandCategory. Pick whichever closests to what you want.
2014-11-05 14:42:08 +11:00
*/
public SubCommand(final String cmd, final String permission, final String description, final String usage, final String alias, final CommandCategory category, final boolean isPlayer) {
this.cmd = cmd;
this.permission = new CommandPermission(permission);
this.description = description;
this.alias = alias;
this.usage = usage;
this.category = category;
this.isPlayer = isPlayer;
}
2014-09-22 13:02:14 +02:00
2014-11-05 14:42:08 +11:00
/**
2014-11-08 20:27:09 +01:00
* @param command Command /plot {cmd} <-- That!
* @param description Simple description
* @param usage Usage description: /plot command {args...}
* @param category CommandCategory. Pick whichever closests to what you want.
2014-11-05 14:42:08 +11:00
*/
public SubCommand(final Command command, final String description, final String usage, final CommandCategory category, final boolean isPlayer) {
this.cmd = command.getCommand();
this.permission = command.getPermission();
this.alias = command.getAlias();
this.description = description;
this.usage = usage;
this.category = category;
this.isPlayer = isPlayer;
}
2014-09-22 13:02:14 +02:00
2014-11-05 14:42:08 +11:00
/**
* Execute.
*
2014-11-08 20:27:09 +01:00
* @param plr executor
* @param args arguments
2014-11-05 14:42:08 +11:00
* @return true on success, false on failure
*/
public abstract boolean execute(final Player plr, final String... args);
2014-11-05 14:42:08 +11:00
public void executeConsole(final String... args) {
this.execute(null, args);
}
2014-09-22 13:02:14 +02:00
2014-11-05 14:42:08 +11:00
/**
* Send a message
*
* @param plr
* @param c
* @param args
*/
2014-11-08 20:27:09 +01:00
public boolean sendMessage(final Player plr, final C c, final String... args) {
2014-11-05 14:42:08 +11:00
PlayerFunctions.sendMessage(plr, c, args);
2014-11-08 20:27:09 +01:00
return true;
2014-11-05 14:42:08 +11:00
}
2014-09-22 13:02:14 +02:00
2014-11-05 14:42:08 +11:00
public enum CommandCategory {
CLAIMING("Claiming"),
TELEPORT("Teleportation"),
ACTIONS("Actions"),
INFO("Information"),
DEBUG("Debug");
private String name;
2014-11-05 14:42:08 +11:00
CommandCategory(final String name) {
this.name = name;
}
2014-11-05 14:42:08 +11:00
@Override
public String toString() {
return this.name;
}
}
2014-09-22 13:02:14 +02:00
}