diff --git a/src/com/massivecraft/massivecore/command/MassiveCommand.java b/src/com/massivecraft/massivecore/command/MassiveCommand.java index b9caee1a..2fd74f00 100644 --- a/src/com/massivecraft/massivecore/command/MassiveCommand.java +++ b/src/com/massivecraft/massivecore/command/MassiveCommand.java @@ -162,6 +162,16 @@ public class MassiveCommand return this.getChildren().size() > 0; } + public List getVisibleChildren(CommandSender watcher) + { + List ret = new MassiveList<>(); + for (MassiveCommand child : this.getChildren()) + { + if (child.isVisibleTo(watcher)) ret.add(child); + } + return ret; + } + // -------------------------------------------- // // CHILDREN > GET // -------------------------------------------- // diff --git a/src/com/massivecraft/massivecore/command/editor/CommandEditAbstract.java b/src/com/massivecraft/massivecore/command/editor/CommandEditAbstract.java index ad2f75ed..0d96469a 100644 --- a/src/com/massivecraft/massivecore/command/editor/CommandEditAbstract.java +++ b/src/com/massivecraft/massivecore/command/editor/CommandEditAbstract.java @@ -45,7 +45,8 @@ public class CommandEditAbstract extends MassiveCommand this.setAliases(this.getProperty().getNames()); // Desc - this.setDesc("edit " + this.getProperty().getName()); + String descAction = property.isEditable() ? "edit " : "show "; + this.setDesc(descAction + this.getProperty().getName()); // Requirements this.addRequirements(RequirementEditorUse.get()); @@ -66,7 +67,21 @@ public class CommandEditAbstract extends MassiveCommand { if (this.isParent()) { - super.perform(); + // If there is only one visible child, and it is a show command .... + // Note: We use the visible children because HelpCommand is always present, but often invisible. + List children = this.getVisibleChildren(this.sender); + if (children.size() == 1 && children.get(0) instanceof CommandEditShow) + { + // ... skip directly to it. + CommandEditShow cmd = (CommandEditShow) children.get(0); + List chain = this.getChain(); + chain.add(this); + cmd.execute(this.sender, this.args, chain); + } + else + { + super.perform(); + } } else { diff --git a/src/com/massivecraft/massivecore/command/editor/CommandEditContainer.java b/src/com/massivecraft/massivecore/command/editor/CommandEditContainer.java index 7cfc117e..904c6fa0 100644 --- a/src/com/massivecraft/massivecore/command/editor/CommandEditContainer.java +++ b/src/com/massivecraft/massivecore/command/editor/CommandEditContainer.java @@ -20,19 +20,22 @@ public class CommandEditContainer extends CommandEditAbstract this.addChild(new CommandEditDelete(settings, property)); } - this.addChild(new CommandEditContainerAdd(settings, property)); - this.addChild(new CommandEditContainerInsert(settings, property)); - this.addChild(new CommandEditContainerSet(settings, property)); - this.addChild(new CommandEditContainerRemove(settings, property)); - this.addChild(new CommandEditContainerRemoveIndex(settings, property)); - - if ( ! property.getValueType().isContainerSorted() && property.getValueType().getContainerComparator() == null) + if (property.isEditable()) { - this.addChild(new CommandEditContainerMove(settings, property)); - this.addChild(new CommandEditContainerSwap(settings, property)); - } + this.addChild(new CommandEditContainerAdd(settings, property)); + this.addChild(new CommandEditContainerInsert(settings, property)); + this.addChild(new CommandEditContainerSet(settings, property)); + this.addChild(new CommandEditContainerRemove(settings, property)); + this.addChild(new CommandEditContainerRemoveIndex(settings, property)); - this.addChild(new CommandEditContainerClear(settings, property)); + if ( ! property.getValueType().isContainerSorted() && property.getValueType().getContainerComparator() == null) + { + this.addChild(new CommandEditContainerMove(settings, property)); + this.addChild(new CommandEditContainerSwap(settings, property)); + } + + this.addChild(new CommandEditContainerClear(settings, property)); + } } } diff --git a/src/com/massivecraft/massivecore/command/editor/CommandEditItemStacks.java b/src/com/massivecraft/massivecore/command/editor/CommandEditItemStacks.java index ddc7f3c9..141f5293 100644 --- a/src/com/massivecraft/massivecore/command/editor/CommandEditItemStacks.java +++ b/src/com/massivecraft/massivecore/command/editor/CommandEditItemStacks.java @@ -24,7 +24,10 @@ public class CommandEditItemStacks extends CommandEditAbstract>(settings, property)); } - this.addChild(new CommandEditItemStacksOpen(settings, property)); + if (property.isEditable()) + { + this.addChild(new CommandEditItemStacksOpen(settings, property)); + } } } diff --git a/src/com/massivecraft/massivecore/command/editor/CommandEditSimple.java b/src/com/massivecraft/massivecore/command/editor/CommandEditSimple.java index a50db327..ace55295 100644 --- a/src/com/massivecraft/massivecore/command/editor/CommandEditSimple.java +++ b/src/com/massivecraft/massivecore/command/editor/CommandEditSimple.java @@ -16,7 +16,10 @@ public class CommandEditSimple extends CommandEditAbstract super(settings, property, null); // Parameters - this.addParameter(TypeNullable.get(this.getProperty().getValueType()), "set", "show", true); + if (property.isEditable()) + { + this.addParameter(TypeNullable.get(this.getProperty().getValueType()), "set", "show", true); + } } // -------------------------------------------- //