mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Fix nested command configuration
This commit is contained in:
parent
560ebf412b
commit
bbe43f782c
@ -147,7 +147,7 @@ public class MainCommand extends Command {
|
||||
if (EconHandler.manager != null) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area != null) {
|
||||
Double price = area.PRICES.get(cmd.getId());
|
||||
Double price = area.PRICES.get(cmd.getFullId());
|
||||
if (price != null && EconHandler.manager.getMoney(player) < price) {
|
||||
failure.run();
|
||||
return;
|
||||
@ -162,7 +162,7 @@ public class MainCommand extends Command {
|
||||
if (EconHandler.manager != null) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area != null) {
|
||||
Double price = area.PRICES.get(cmd.getId());
|
||||
Double price = area.PRICES.get(cmd.getFullId());
|
||||
if (price != null && EconHandler.manager.getMoney(player) < price) {
|
||||
failure.run();
|
||||
return;
|
||||
|
@ -18,15 +18,15 @@ public abstract class SetCommand extends SubCommand {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command." + getId())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command." + getId());
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command." + getFullId())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command." + getFullId());
|
||||
MainUtil.sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!plot.isOwner(plr.getUUID())) {
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command." + getId())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command." + getId());
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command." + getFullId())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command." + getFullId());
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -100,6 +100,13 @@ public abstract class Command {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getFullId() {
|
||||
if (parent != null && parent.getParent() != null) {
|
||||
return parent.getFullId() + "." + id;
|
||||
}
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public List<Command> getCommands(PlotPlayer player) {
|
||||
List<Command> commands = new ArrayList<>();
|
||||
for (Command cmd : this.allCommands) {
|
||||
@ -166,7 +173,7 @@ public abstract class Command {
|
||||
options.put("confirmation", declaration.confirmation());
|
||||
boolean set = false;
|
||||
for (Map.Entry<String, Object> entry : options.entrySet()) {
|
||||
String key = this.id + "." + entry.getKey();
|
||||
String key = this.getFullId() + "." + entry.getKey();
|
||||
if (!PS.get().commands.contains(key)) {
|
||||
PS.get().commands.set(key, entry.getValue());
|
||||
set = true;
|
||||
@ -180,10 +187,10 @@ public abstract class Command {
|
||||
|
||||
}
|
||||
}
|
||||
this.aliases = PS.get().commands.getStringList(this.id + ".aliases");
|
||||
this.description = PS.get().commands.getString(this.id + ".description");
|
||||
this.usage = PS.get().commands.getString(this.id + ".usage");
|
||||
this.confirmation = PS.get().commands.getBoolean(this.id + ".confirmation");
|
||||
this.aliases = PS.get().commands.getStringList(this.getFullId() + ".aliases");
|
||||
this.description = PS.get().commands.getString(this.getFullId() + ".description");
|
||||
this.usage = PS.get().commands.getString(this.getFullId() + ".usage");
|
||||
this.confirmation = PS.get().commands.getBoolean(this.getFullId() + ".confirmation");
|
||||
if (this.parent != null) {
|
||||
this.parent.register(this);
|
||||
}
|
||||
@ -207,10 +214,7 @@ public abstract class Command {
|
||||
if (this.parent == null) {
|
||||
return "plots.use";
|
||||
}
|
||||
if (this.parent.parent == null) {
|
||||
return "plots." + this.id;
|
||||
}
|
||||
return this.parent.getPermission() + "." + this.id;
|
||||
return "plots." + getFullId();
|
||||
}
|
||||
|
||||
public <T> void paginate(PlotPlayer player, List<T> c, int size, int page, RunnableVal3<Integer, T, PlotMessage> add, String baseCommand,
|
||||
@ -523,12 +527,12 @@ public abstract class Command {
|
||||
if (this.hashCode() != other.hashCode()) {
|
||||
return false;
|
||||
}
|
||||
return this.id.equals(other.id);
|
||||
return this.getFullId().equals(other.getFullId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.id.hashCode();
|
||||
return this.getFullId().hashCode();
|
||||
}
|
||||
|
||||
public enum CommandResult {
|
||||
|
Loading…
Reference in New Issue
Block a user