Fixes #724
Fixes flag remove for non list based flags when player lacks permission.
This commit is contained in:
Jesse Boyd 2015-11-18 10:39:44 +11:00
parent a8140f8cb0
commit 452efc4b08
4 changed files with 20 additions and 10 deletions

View File

@ -158,6 +158,10 @@ public class FlagCmd extends SubCommand {
}
final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase());
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) {
if (args.length != 2) {
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
return false;
}
for (final String entry : args[2].split(",")) {
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) {
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + entry);

View File

@ -59,6 +59,12 @@ public class Set extends SubCommand {
public Set() {
component = new SetCommand() {
@Override
public String getCommand() {
return "set.component";
}
@Override
public boolean set(PlotPlayer plr, final Plot plot, String value) {
final String world = plr.getLocation().getWorld();
@ -171,7 +177,7 @@ public class Set extends SubCommand {
// components
HashSet<String> components = new HashSet<String>(Arrays.asList(plot.getManager().getPlotComponents(plot.getWorld(), plot.id)));
if (components.contains(args[0].toLowerCase())) {
return component.set(plr, plot, StringMan.join(args, " "));
return component.onCommand(plr, Arrays.copyOfRange(args, 1, args.length));
}
// flag
{

View File

@ -70,11 +70,11 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
this.requiredType = requiredType;
}
final public RequiredType getRequiredType() {
public RequiredType getRequiredType() {
return this.requiredType;
}
final public void create() {
public void create() {
final Annotation annotation = getClass().getAnnotation(CommandDeclaration.class);
if (annotation == null) {
throw new RuntimeException("Command does not have a CommandDeclaration");
@ -91,13 +91,13 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
}
@Override
final public String toString() {
public String toString() {
return this.command;
}
public abstract boolean onCommand(final E plr, final String[] arguments);
final public int handle(final E plr, final String[] args) {
public int handle(final E plr, final String[] args) {
if (args.length == 0) {
return super.handle(plr, "");
}
@ -109,7 +109,7 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
return super.handle(plr, s);
}
final public String getCommand() {
public String getCommand() {
return this.command;
}
@ -120,7 +120,7 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
return this.usage;
}
final public String getPermission() {
public String getPermission() {
if ((this.permission == null) || (this.permission.length() == 0)) {
this.permission = "plots." + command.toLowerCase();
}
@ -131,18 +131,18 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
return this.description;
}
final public Set<String> getAliases() {
public Set<String> getAliases() {
return this.aliases;
}
final public Argument<?>[] getRequiredArguments() {
public Argument<?>[] getRequiredArguments() {
if (this.requiredArguments == null) {
return new Argument<?>[0];
}
return this.requiredArguments;
}
final public CommandCategory getCategory() {
public CommandCategory getCategory() {
if (category == null) {
return CommandCategory.DEBUG;
}

Binary file not shown.