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 @Override
public boolean onCommand(PlotPlayer player, String... args) { 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.object.RunnableVal3;
import com.intellectualcrafters.plot.util.CmdConfirm; import com.intellectualcrafters.plot.util.CmdConfirm;
import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.Command; import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
@ -46,7 +45,8 @@ import java.util.Arrays;
public class MainCommand extends Command { public class MainCommand extends Command {
private static MainCommand instance; private static MainCommand instance;
private Help help; public Help help;
public Toggle toggle;
private MainCommand() { private MainCommand() {
super(null, true); super(null, true);
@ -75,7 +75,6 @@ public class MainCommand extends Command {
new Auto(); new Auto();
new Visit(); new Visit();
new Set(); new Set();
new Toggle();
new Clear(); new Clear();
new Delete(); new Delete();
new Trust(); new Trust();
@ -86,7 +85,6 @@ public class MainCommand extends Command {
new Undeny(); new Undeny();
new Info(); new Info();
new ListCmd(); new ListCmd();
instance.help = new Help(instance);
new Debug(); new Debug();
new SchematicCmd(); new SchematicCmd();
new PluginCmd(); new PluginCmd();
@ -120,13 +118,16 @@ public class MainCommand extends Command {
new BO3(); new BO3();
new Middle(); new Middle();
new Grant(); new Grant();
// set commands // Set commands
new Owner(); new Owner();
new Desc(); new Desc();
new Biome(); new Biome();
new Alias(); new Alias();
new SetHome(); new SetHome();
new Cluster(); new Cluster();
// Referenced commands
instance.toggle = new Toggle();
instance.help = new Help(instance);
} }
return instance; return instance;
} }
@ -155,16 +156,6 @@ public class MainCommand extends Command {
args = tmp; 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>() { getInstance().execute(player, args, new RunnableVal3<Command, Runnable, Runnable>() {
@Override @Override
public void run(final Command cmd, final Runnable success, final Runnable failure) { public void run(final Command cmd, final Runnable success, final Runnable failure) {
@ -214,7 +205,6 @@ public class MainCommand extends Command {
// Clear perm caching // // Clear perm caching //
player.deleteMeta("perm"); player.deleteMeta("perm");
// Optional command scope // // Optional command scope //
String category = null;
Location loc = null; Location loc = null;
Plot plot = null; Plot plot = null;
boolean tp = false; boolean tp = false;

View File

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

View File

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

View File

@ -36,7 +36,8 @@ public class WE_Anywhere extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer player, String[] arguments) { 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.PS;
import com.intellectualcrafters.plot.commands.CommandCategory; import com.intellectualcrafters.plot.commands.CommandCategory;
import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.commands.RequiredType; import com.intellectualcrafters.plot.commands.RequiredType;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotMessage; 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.RunnableVal2;
import com.intellectualcrafters.plot.object.RunnableVal3; import com.intellectualcrafters.plot.object.RunnableVal3;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.StringMan; 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) { public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command,Runnable,Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
if (args.length == 0 || args[0] == null) { 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; return;
} }
if (allCommands == null || allCommands.size() == 0) { if (allCommands == null || allCommands.size() == 0) {
@ -280,12 +286,21 @@ public abstract class Command {
C.COMMAND_SYNTAX.send(player, getUsage()); C.COMMAND_SYNTAX.send(player, getUsage());
return; 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 // Command recommendation
MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND); MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
{ {
List<Command> cmds = getCommands(player); List<Command> cmds = getCommands(player);
if (cmds.isEmpty()) { if (cmds.isEmpty()) {
MainUtil.sendMessage(player, C.DID_YOU_MEAN, "/plot help"); MainUtil.sendMessage(player, C.DID_YOU_MEAN, MainCommand.getInstance().help.getUsage());
return; return;
} }
HashSet<String> setargs = new HashSet<>(args.length); HashSet<String> setargs = new HashSet<>(args.length);