mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2025-11-24 21:46:16 +00:00
@@ -7,79 +7,155 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandArea;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandBank;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandCheck;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandClearFlags;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandCompass;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandConfirm;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandCreate;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandCurrent;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandDefault;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandGive;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandGset;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandInfo;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandKick;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandLease;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandLimits;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandList;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandListAll;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandListAllHidden;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandListHidden;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandLists;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandLset;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandMarket;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandMaterial;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandMessage;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandMirror;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandPset;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandRemove;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandRemoveAll;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandRename;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandRenameArea;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandSelect;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandServer;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandSet;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandSetOwner;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandSubList;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandSubZone;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandTool;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandTp;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandTpSet;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandUnStuck;
|
||||
import com.bekvon.bukkit.residence.commandsub.CommandVersion;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.PluginHelper.commands.HandlerSubCommand;
|
||||
|
||||
public class CommandRes extends BaseCommand {
|
||||
Residence plugin;
|
||||
|
||||
HandlerSubCommand hdsubcmd;
|
||||
|
||||
public CommandRes(Residence plugin) {
|
||||
Residence plugin;
|
||||
|
||||
public CommandRes(final Residence plugin) {
|
||||
super("res", "residence", "resadmin");
|
||||
this.plugin = plugin;
|
||||
hdsubcmd = new HandlerSubCommand(plugin);
|
||||
hdsubcmd.registerCommand(new CommandConfirm(plugin));
|
||||
hdsubcmd.registerCommand(new CommandRemove(plugin));
|
||||
hdsubcmd.registerCommand(new CommandVersion(plugin));
|
||||
hdsubcmd.registerCommand(new CommandSetOwner(plugin));
|
||||
|
||||
// Player player = null;
|
||||
// boolean resadmin = (command != null);
|
||||
// ResidenceManager rmanager = Residence.getResidenceManager();
|
||||
// Map<String, String> deleteConfirm = plugin.deleteConfirm;
|
||||
// Language language = Residence.getLanguage();
|
||||
hdsubcmd.registerCommand(new CommandArea(plugin));
|
||||
hdsubcmd.registerCommand(new CommandBank(plugin));
|
||||
hdsubcmd.registerCommand(new CommandCheck(plugin));
|
||||
hdsubcmd.registerCommand(new CommandClearFlags(plugin));
|
||||
hdsubcmd.registerCommand(new CommandCompass(plugin));
|
||||
hdsubcmd.registerCommand(new CommandConfirm(plugin));
|
||||
hdsubcmd.registerCommand(new CommandCreate(plugin));
|
||||
hdsubcmd.registerCommand(new CommandCurrent(plugin));
|
||||
hdsubcmd.registerCommand(new CommandDefault(plugin));
|
||||
hdsubcmd.registerCommand(new CommandGive(plugin));
|
||||
hdsubcmd.registerCommand(new CommandGset(plugin));
|
||||
hdsubcmd.registerCommand(new CommandInfo(plugin));
|
||||
hdsubcmd.registerCommand(new CommandKick(plugin));
|
||||
hdsubcmd.registerCommand(new CommandLease(plugin));
|
||||
hdsubcmd.registerCommand(new CommandLimits(plugin));
|
||||
hdsubcmd.registerCommand(new CommandList(plugin));
|
||||
hdsubcmd.registerCommand(new CommandListAll(plugin));
|
||||
hdsubcmd.registerCommand(new CommandListAllHidden(plugin));
|
||||
hdsubcmd.registerCommand(new CommandListHidden(plugin));
|
||||
hdsubcmd.registerCommand(new CommandLists(plugin));
|
||||
hdsubcmd.registerCommand(new CommandLset(plugin));
|
||||
hdsubcmd.registerCommand(new CommandMarket(plugin));
|
||||
hdsubcmd.registerCommand(new CommandMaterial(plugin));
|
||||
hdsubcmd.registerCommand(new CommandMessage(plugin));
|
||||
hdsubcmd.registerCommand(new CommandMirror(plugin));
|
||||
hdsubcmd.registerCommand(new CommandPset(plugin));
|
||||
hdsubcmd.registerCommand(new CommandRemove(plugin));
|
||||
hdsubcmd.registerCommand(new CommandRemoveAll(plugin));
|
||||
hdsubcmd.registerCommand(new CommandRename(plugin));
|
||||
hdsubcmd.registerCommand(new CommandRenameArea(plugin));
|
||||
hdsubcmd.registerCommand(new CommandSelect(plugin));
|
||||
hdsubcmd.registerCommand(new CommandServer(plugin));
|
||||
hdsubcmd.registerCommand(new CommandSet(plugin));
|
||||
hdsubcmd.registerCommand(new CommandSetOwner(plugin));
|
||||
hdsubcmd.registerCommand(new CommandSubList(plugin));
|
||||
hdsubcmd.registerCommand(new CommandSubZone(plugin));
|
||||
hdsubcmd.registerCommand(new CommandTool(plugin));
|
||||
hdsubcmd.registerCommand(new CommandTp(plugin));
|
||||
hdsubcmd.registerCommand(new CommandTpSet(plugin));
|
||||
hdsubcmd.registerCommand(new CommandUnStuck(plugin));
|
||||
hdsubcmd.registerCommand(new CommandVersion(plugin));
|
||||
|
||||
plugin.getCommand("residence").setTabCompleter(hdsubcmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException {
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
boolean resadmin = false;
|
||||
if (sender instanceof Player) {
|
||||
if (label.equalsIgnoreCase("resadmin"))
|
||||
if (Residence.getPermissionManager().isResidenceAdmin((Player) sender))
|
||||
if (label.equalsIgnoreCase("resadmin")) {
|
||||
if (plugin.getPermissionManager().isResidenceAdmin((Player) sender)) {
|
||||
resadmin = true;
|
||||
else
|
||||
sender.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NonAdmin"));
|
||||
} else
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("NonAdmin"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
resadmin = true;
|
||||
}
|
||||
if (args.length > 0 && args[args.length - 1].equalsIgnoreCase("?") || args.length > 1 && args[args.length - 2].equals("?")) {
|
||||
commandHelp(args, resadmin, sender);
|
||||
return;
|
||||
}
|
||||
if (Residence.getConfigManager().allowAdminsOnly())
|
||||
if (plugin.getConfigManager().allowAdminsOnly()) {
|
||||
if (!resadmin) {
|
||||
sender.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("AdminOnly"));
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("AdminOnly"));
|
||||
return;
|
||||
}
|
||||
if (args.length == 0)
|
||||
}
|
||||
if (args.length == 0) {
|
||||
return;
|
||||
}
|
||||
hdsubcmd.onCommand(sender, resadmin ? command : null, label, args);
|
||||
}
|
||||
|
||||
private boolean commandHelp(String[] args, boolean resadmin, CommandSender sender) {
|
||||
if (Residence.helppages != null) {
|
||||
private boolean commandHelp(final String[] args, final boolean resadmin, final CommandSender sender) {
|
||||
if (plugin.getHelppages() != null) {
|
||||
String helppath = "res";
|
||||
for (String arg : args) {
|
||||
if (arg.equalsIgnoreCase("?"))
|
||||
for (final String arg : args) {
|
||||
if (arg.equalsIgnoreCase("?")) {
|
||||
break;
|
||||
}
|
||||
helppath = helppath + "." + arg;
|
||||
}
|
||||
int page = 1;
|
||||
if (!args[args.length - 1].equalsIgnoreCase("?"))
|
||||
if (!args[args.length - 1].equalsIgnoreCase("?")) {
|
||||
try {
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
} catch (Exception ex) {
|
||||
sender.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("InvalidHelp"));
|
||||
} catch (final Exception ex) {
|
||||
sender.sendMessage(ChatColor.RED + plugin.getLanguage().getPhrase("InvalidHelp"));
|
||||
}
|
||||
if (Residence.helppages.containesEntry(helppath)) {
|
||||
Residence.helppages.printHelp(sender, page, helppath);
|
||||
}
|
||||
if (plugin.getHelppages().containesEntry(helppath)) {
|
||||
plugin.getHelppages().printHelp(sender, page, helppath);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user