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;
|
|
|
|
|
2015-02-21 05:27:01 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
2015-01-13 17:38:15 +01:00
|
|
|
import com.intellectualcrafters.plot.config.C;
|
2015-02-20 11:53:18 +01:00
|
|
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
2015-02-21 06:48:49 +01:00
|
|
|
import com.intellectualcrafters.plot.util.MainUtil;
|
2015-01-13 17:38:15 +01:00
|
|
|
|
2014-09-22 13:02:14 +02:00
|
|
|
/**
|
|
|
|
* SubCommand class
|
2014-10-11 09:33:10 +02:00
|
|
|
*
|
2014-09-22 13:02:14 +02:00
|
|
|
* @author Citymonstret
|
|
|
|
*/
|
2015-02-20 07:34:19 +01:00
|
|
|
@SuppressWarnings({ "deprecation", "unused" })
|
|
|
|
public abstract class SubCommand {
|
2014-11-05 04:42:08 +01:00
|
|
|
/**
|
|
|
|
* Command
|
|
|
|
*/
|
2014-12-18 03:15:11 +01:00
|
|
|
public final String cmd;
|
2014-11-05 04:42:08 +01:00
|
|
|
/**
|
|
|
|
* Permission node
|
|
|
|
*/
|
2014-11-20 00:00:38 +01:00
|
|
|
public final CommandPermission permission;
|
2014-11-05 04:42:08 +01:00
|
|
|
/**
|
|
|
|
* Simple description
|
|
|
|
*/
|
2014-12-18 03:15:11 +01:00
|
|
|
public final String description;
|
2014-11-05 04:42:08 +01:00
|
|
|
/**
|
2014-12-15 02:33:53 +01:00
|
|
|
* Aliases
|
2014-11-05 04:42:08 +01:00
|
|
|
*/
|
2014-12-15 02:33:53 +01:00
|
|
|
public final ArrayList<String> alias;
|
2014-11-05 04:42:08 +01:00
|
|
|
/**
|
|
|
|
* Command usage
|
|
|
|
*/
|
2014-12-18 03:15:11 +01:00
|
|
|
public final String usage;
|
2014-11-20 00:00:38 +01:00
|
|
|
/**
|
|
|
|
* The category
|
|
|
|
*/
|
2014-12-18 03:15:11 +01:00
|
|
|
public final CommandCategory category;
|
2014-11-20 00:00:38 +01:00
|
|
|
/**
|
|
|
|
* Is this a player-online command?
|
|
|
|
*/
|
2014-12-18 03:15:11 +01:00
|
|
|
public final boolean isPlayer;
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2014-11-05 04:42:08 +01:00
|
|
|
/**
|
2014-12-18 03:15:11 +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 is closest to what you want.
|
2014-11-05 04:42:08 +01: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;
|
2014-12-15 02:33:53 +01:00
|
|
|
this.alias = new ArrayList<String>();
|
|
|
|
this.alias.add(alias);
|
|
|
|
this.usage = usage;
|
|
|
|
this.category = category;
|
|
|
|
this.isPlayer = isPlayer;
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2014-12-15 02:33:53 +01:00
|
|
|
/**
|
2014-12-18 03:15:11 +01:00
|
|
|
* @param cmd Command /plot {cmd} <-- That!
|
|
|
|
* @param permission Permission Node
|
|
|
|
* @param description Simple description
|
|
|
|
* @param usage Usage description: /plot command {args...}
|
|
|
|
* @param aliases Command aliases
|
|
|
|
* @param category CommandCategory. Pick whichever is closest to what you want.
|
2014-12-15 02:33:53 +01:00
|
|
|
*/
|
|
|
|
public SubCommand(final String cmd, final String permission, final String description, final String usage, final CommandCategory category, final boolean isPlayer, final String... aliases) {
|
|
|
|
this.cmd = cmd;
|
|
|
|
this.permission = new CommandPermission(permission);
|
|
|
|
this.description = description;
|
|
|
|
this.alias = new ArrayList<String>();
|
|
|
|
this.alias.addAll(Arrays.asList(aliases));
|
2014-11-05 04:42:08 +01:00
|
|
|
this.usage = usage;
|
|
|
|
this.category = category;
|
|
|
|
this.isPlayer = isPlayer;
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2014-11-05 04:42:08 +01:00
|
|
|
/**
|
2014-12-18 03:15:11 +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 04:42:08 +01: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();
|
2014-12-15 02:33:53 +01:00
|
|
|
this.alias = new ArrayList<String>();
|
|
|
|
this.alias.add(command.getAlias());
|
2014-11-05 04:42:08 +01:00
|
|
|
this.description = description;
|
|
|
|
this.usage = usage;
|
|
|
|
this.category = category;
|
|
|
|
this.isPlayer = isPlayer;
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2014-11-05 04:42:08 +01:00
|
|
|
/**
|
|
|
|
* Execute.
|
|
|
|
*
|
2014-12-18 03:15:11 +01:00
|
|
|
* @param plr executor
|
|
|
|
* @param args arguments
|
|
|
|
*
|
2014-11-05 04:42:08 +01:00
|
|
|
* @return true on success, false on failure
|
|
|
|
*/
|
2015-02-20 11:53:18 +01:00
|
|
|
public abstract boolean execute(final PlotPlayer plr, final String... args);
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2014-11-20 00:00:38 +01:00
|
|
|
/**
|
|
|
|
* Execute the command as console
|
|
|
|
*
|
2014-12-18 03:15:11 +01:00
|
|
|
* @param args Arguments
|
2014-11-20 00:00:38 +01:00
|
|
|
*/
|
2014-11-05 04:42:08 +01:00
|
|
|
public void executeConsole(final String... args) {
|
|
|
|
this.execute(null, args);
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2014-11-05 04:42:08 +01:00
|
|
|
/**
|
|
|
|
* Send a message
|
|
|
|
*
|
2014-12-18 03:15:11 +01:00
|
|
|
* @param plr Player who will receive the mssage
|
|
|
|
* @param c Caption
|
|
|
|
* @param args Arguments (%s's)
|
|
|
|
*
|
2015-03-13 08:02:48 +01:00
|
|
|
* @see com.intellectualcrafters.plot.util.MainUtil#sendMessage(PlotPlayer, C, String...)
|
2014-11-05 04:42:08 +01:00
|
|
|
*/
|
2015-02-20 11:53:18 +01:00
|
|
|
public boolean sendMessage(final PlotPlayer plr, final C c, final String... args) {
|
2015-02-21 06:48:49 +01:00
|
|
|
MainUtil.sendMessage(plr, c, args);
|
2014-11-08 20:27:09 +01:00
|
|
|
return true;
|
2014-11-05 04:42:08 +01:00
|
|
|
}
|
2015-06-24 16:32:27 +02:00
|
|
|
|
2014-11-20 00:00:38 +01:00
|
|
|
/**
|
|
|
|
* CommandCategory
|
|
|
|
*
|
|
|
|
* @author Citymonstret
|
|
|
|
* @author Empire92
|
|
|
|
*/
|
2014-11-05 04:42:08 +01:00
|
|
|
public enum CommandCategory {
|
2014-11-20 00:00:38 +01:00
|
|
|
/**
|
|
|
|
* Claiming Commands
|
2015-03-13 08:05:06 +01:00
|
|
|
*
|
2014-11-20 00:00:38 +01:00
|
|
|
* Such as: /plot claim
|
|
|
|
*/
|
2014-11-05 04:42:08 +01:00
|
|
|
CLAIMING("Claiming"),
|
2014-11-20 00:00:38 +01:00
|
|
|
/**
|
|
|
|
* Teleportation Commands
|
2015-03-13 08:05:06 +01:00
|
|
|
*
|
2014-11-20 00:00:38 +01:00
|
|
|
* Such as: /plot visit
|
|
|
|
*/
|
2014-11-05 04:42:08 +01:00
|
|
|
TELEPORT("Teleportation"),
|
2014-11-20 00:00:38 +01:00
|
|
|
/**
|
|
|
|
* Action Commands
|
2015-03-13 08:05:06 +01:00
|
|
|
*
|
2014-11-20 00:00:38 +01:00
|
|
|
* Such as: /plot clear
|
|
|
|
*/
|
2014-11-05 04:42:08 +01:00
|
|
|
ACTIONS("Actions"),
|
2014-11-20 00:00:38 +01:00
|
|
|
/**
|
|
|
|
* Information Commands
|
2015-03-13 08:05:06 +01:00
|
|
|
*
|
2014-11-20 00:00:38 +01:00
|
|
|
* Such as: /plot info
|
|
|
|
*/
|
2014-11-05 04:42:08 +01:00
|
|
|
INFO("Information"),
|
2014-11-20 00:00:38 +01:00
|
|
|
/**
|
|
|
|
* Debug Commands
|
2015-03-13 08:05:06 +01:00
|
|
|
*
|
2014-11-20 00:00:38 +01:00
|
|
|
* Such as: /plot debug
|
|
|
|
*/
|
2014-11-05 04:42:08 +01:00
|
|
|
DEBUG("Debug");
|
2014-11-20 00:00:38 +01:00
|
|
|
/**
|
|
|
|
* The category name (Readable)
|
|
|
|
*/
|
|
|
|
private final String name;
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2014-11-20 00:00:38 +01:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
2014-12-18 03:15:11 +01:00
|
|
|
* @param name readable name
|
2014-11-20 00:00:38 +01:00
|
|
|
*/
|
2014-11-05 04:42:08 +01:00
|
|
|
CommandCategory(final String name) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2014-11-05 04:42:08 +01:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return this.name;
|
|
|
|
}
|
|
|
|
}
|
2014-12-16 06:03:20 +01:00
|
|
|
}
|