forgot to push this

This commit is contained in:
Jesse Boyd 2016-03-26 16:44:38 +11:00
parent 1252e004a0
commit 6a7cf0d56f
6 changed files with 28 additions and 22 deletions

View File

@ -14,6 +14,7 @@ public class Chat extends SubCommand {
@Override
public boolean onCommand(PlotPlayer player, String... args) {
return MainCommand.onCommand(player, "toggle", "chat");
MainCommand.getInstance().toggle.chat(this, player, new String[0], null, null);
return true;
}
}

View File

@ -31,7 +31,6 @@ import com.intellectualcrafters.plot.object.RunnableVal2;
import com.intellectualcrafters.plot.object.RunnableVal3;
import com.intellectualcrafters.plot.util.CmdConfirm;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandDeclaration;
@ -46,7 +45,8 @@ import java.util.Arrays;
public class MainCommand extends Command {
private static MainCommand instance;
private Help help;
public Help help;
public Toggle toggle;
private MainCommand() {
super(null, true);
@ -75,7 +75,6 @@ public class MainCommand extends Command {
new Auto();
new Visit();
new Set();
new Toggle();
new Clear();
new Delete();
new Trust();
@ -86,7 +85,6 @@ public class MainCommand extends Command {
new Undeny();
new Info();
new ListCmd();
instance.help = new Help(instance);
new Debug();
new SchematicCmd();
new PluginCmd();
@ -120,13 +118,16 @@ public class MainCommand extends Command {
new BO3();
new Middle();
new Grant();
// set commands
// Set commands
new Owner();
new Desc();
new Biome();
new Alias();
new SetHome();
new Cluster();
// Referenced commands
instance.toggle = new Toggle();
instance.help = new Help(instance);
}
return instance;
}
@ -155,16 +156,6 @@ public class MainCommand extends Command {
args = tmp;
}
}
{
try {
if (args.length == 0 || MathMan.isInteger(args[0]) || CommandCategory.valueOf(args[0].toUpperCase()) != null) {
// This will default certain syntax to the help command
// e.g. /plot, /plot 1, /plot claiming
getInstance().help.execute(player, args, null, null);
return true;
}
} catch (IllegalArgumentException e) {}
}
getInstance().execute(player, args, new RunnableVal3<Command, Runnable, Runnable>() {
@Override
public void run(final Command cmd, final Runnable success, final Runnable failure) {
@ -214,7 +205,6 @@ public class MainCommand extends Command {
// Clear perm caching //
player.deleteMeta("perm");
// Optional command scope //
String category = null;
Location loc = null;
Plot plot = null;
boolean tp = false;

View File

@ -33,7 +33,6 @@ import com.plotsquared.general.commands.CommandDeclaration;
aliases = {"attribute"},
permission = "plots.use",
description = "Toggle per user settings",
usage = "/plot toggle <setting>",
requiredType = RequiredType.NONE,
category = CommandCategory.SETTINGS)
public class Toggle extends Command {

View File

@ -43,7 +43,7 @@ import java.util.UUID;
permission = "plots.visit",
description = "Visit someones plot",
usage = "/plot visit [player|alias|world|id] [#]",
aliases = {"v", "tp", "teleport", "goto", "home"},
aliases = {"v", "tp", "teleport", "goto", "home", "h"},
requiredType = RequiredType.NONE,
category = CommandCategory.TELEPORT)
public class Visit extends SubCommand {

View File

@ -36,7 +36,8 @@ public class WE_Anywhere extends SubCommand {
@Override
public boolean onCommand(PlotPlayer player, String[] arguments) {
return MainCommand.onCommand(player, "plot", "toggle", "worldedit");
MainCommand.getInstance().toggle.worldedit(this, player, new String[0], null, null);
return true;
}
}

View File

@ -2,6 +2,7 @@ package com.plotsquared.general.commands;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.commands.CommandCategory;
import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.commands.RequiredType;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotMessage;
@ -9,6 +10,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal2;
import com.intellectualcrafters.plot.object.RunnableVal3;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.StringMan;
@ -267,7 +269,11 @@ public abstract class Command {
*/
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command,Runnable,Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
if (args.length == 0 || args[0] == null) {
C.COMMAND_SYNTAX.send(player, getUsage());
if (parent == null) {
MainCommand.getInstance().help.displayHelp(player, null, 0);
} else {
C.COMMAND_SYNTAX.send(player, getUsage());
}
return;
}
if (allCommands == null || allCommands.size() == 0) {
@ -280,12 +286,21 @@ public abstract class Command {
C.COMMAND_SYNTAX.send(player, getUsage());
return;
}
// Help command
try {
if (args.length == 0 || MathMan.isInteger(args[0]) || CommandCategory.valueOf(args[0].toUpperCase()) != null) {
// This will default certain syntax to the help command
// e.g. /plot, /plot 1, /plot claiming
MainCommand.getInstance().help.execute(player, args, null, null);
return;
}
} catch (IllegalArgumentException e) {}
// Command recommendation
MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
{
List<Command> cmds = getCommands(player);
if (cmds.isEmpty()) {
MainUtil.sendMessage(player, C.DID_YOU_MEAN, "/plot help");
MainUtil.sendMessage(player, C.DID_YOU_MEAN, MainCommand.getInstance().help.getUsage());
return;
}
HashSet<String> setargs = new HashSet<>(args.length);