mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-19 13:51:24 +01:00
Cleanup in CompositeCommand
Removed onlyConsole Removed "showHelp" implementation Removed deprecated setParameters
This commit is contained in:
parent
353c87cf6d
commit
9d04aa376b
@ -46,11 +46,6 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
*/
|
||||
private boolean onlyPlayer = false;
|
||||
|
||||
/**
|
||||
* True if the command is only for the console to use
|
||||
*/
|
||||
private boolean onlyConsole = false;
|
||||
|
||||
/**
|
||||
* True if command is a configurable rank
|
||||
*/
|
||||
@ -256,13 +251,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
return false;
|
||||
}
|
||||
// Execute and trim args
|
||||
if (!cmd.execute(user, (cmd.subCommandLevel > 0) ? args[cmd.subCommandLevel-1] : label, Arrays.asList(args).subList(cmd.subCommandLevel, args.length))) {
|
||||
// If it returned false, then show help for this command
|
||||
// showHelp(cmd, user);
|
||||
return false; // And return false (it basically does nothing, but let's be compliant with Bukkit's javadoc)
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return cmd.execute(user, (cmd.subCommandLevel > 0) ? args[cmd.subCommandLevel-1] : label, Arrays.asList(args).subList(cmd.subCommandLevel, args.length));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -524,39 +513,6 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets locale reference to this command's parameters.
|
||||
* It is used to display the help of this command.
|
||||
*
|
||||
* <br/><br/>
|
||||
*
|
||||
* A default value is provided when instantiating this CompositeCommand:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code "commands." + getLabel() + ".parameters"} if this is a top-level command;</li>
|
||||
* <li>{@code "commands." + getParent.getLabel() + getLabel() + ".parameters"} if this is a sub-command.
|
||||
* <br/>
|
||||
* Note that it can have up to 20 parent commands' labels being inserted before this sub-command's label.
|
||||
* Here are a few examples :
|
||||
* <ul>
|
||||
* <li>/bentobox info : {@code "commands.bentobox.info.parameters"};</li>
|
||||
* <li>/bsbadmin range set : {@code "commands.bsbadmin.range.set.parameters"};</li>
|
||||
* <li>/mycommand sub1 sub2 sub3 [...] sub22 : {@code "commands.sub3.[...].sub20.sub21.sub22.parameters"}.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* This method should therefore only be used in case you want to provide a different value than the default one.
|
||||
*
|
||||
* @param parameters The locale command's paramaters reference to set.
|
||||
* @deprecated This method has been deprecated to avoid upcoming ambiguity as we will be using Mojang's Brigadier library.
|
||||
* Use {@link #setParametersHelp(String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setParameters(String parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets locale reference to this command's parameters.
|
||||
* It is used to display the help of this command.
|
||||
@ -625,7 +581,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
// Get command object based on args entered so far
|
||||
CompositeCommand cmd = getCommandFromArgs(args);
|
||||
// Check for console and permissions
|
||||
if ((cmd.onlyPlayer && !(sender instanceof Player)) || (cmd.onlyConsole && sender instanceof Player)) {
|
||||
if ((cmd.onlyPlayer && !(sender instanceof Player))) {
|
||||
return options;
|
||||
}
|
||||
if (!cmd.getPermission().isEmpty() && !sender.hasPermission(cmd.getPermission()) && !sender.isOp()) {
|
||||
@ -792,7 +748,6 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
public BukkitTask getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -827,20 +782,6 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the onlyConsole
|
||||
*/
|
||||
public boolean isOnlyConsole() {
|
||||
return onlyConsole;
|
||||
}
|
||||
|
||||
/**
|
||||
* This command is only for console use
|
||||
*/
|
||||
public void setOnlyConsole() {
|
||||
this.onlyConsole = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the configurableRankCommand
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user