From 9a50457b3d984190977c1bfb86efad58c5c59177 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Tue, 2 Feb 2016 15:21:28 +0100 Subject: [PATCH] Editor getUsedSettings --- .../command/editor/CommandEditUsed.java | 2 +- .../command/editor/EditSettings.java | 36 +++++++++++-------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/com/massivecraft/massivecore/command/editor/CommandEditUsed.java b/src/com/massivecraft/massivecore/command/editor/CommandEditUsed.java index 3b6d4243..1b4125d9 100644 --- a/src/com/massivecraft/massivecore/command/editor/CommandEditUsed.java +++ b/src/com/massivecraft/massivecore/command/editor/CommandEditUsed.java @@ -11,7 +11,7 @@ public class CommandEditUsed extends CommandEditSimple public CommandEditUsed(EditSettings settings) { // Super - super(settings.createUsedSettings(), settings.getUsedProperty()); + super(settings.getUsedSettings(), settings.getUsedProperty()); // Aliases this.setAliases("used", "selected"); diff --git a/src/com/massivecraft/massivecore/command/editor/EditSettings.java b/src/com/massivecraft/massivecore/command/editor/EditSettings.java index 52b3d90a..864b07a6 100644 --- a/src/com/massivecraft/massivecore/command/editor/EditSettings.java +++ b/src/com/massivecraft/massivecore/command/editor/EditSettings.java @@ -26,6 +26,28 @@ public class EditSettings public Property getUsedProperty() { return this.usedProperty; } public void setUsedProperty(Property usedProperty) { this.usedProperty = usedProperty; } + // The Internal EditSettings for setting the used. + protected EditSettings usedSettings = null; + public EditSettings getUsedSettings() + { + if (this.usedSettings == null) + { + this.usedSettings = this.createUsedSettings(); + } + return this.usedSettings; + } + protected EditSettings createUsedSettings() + { + final EditSettings main = this; + return new EditSettings(TypeSender.get(), new PropertyThis(TypeSender.get())) { + @Override + public Permission getPropertyPermission(Property property) + { + return main.getUsedPermission(); + } + }; + } + // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // @@ -41,20 +63,6 @@ public class EditSettings this(objectType, null); } - public EditSettings createUsedSettings() - { - final EditSettings main = this; - return new EditSettings(TypeSender.get(), new PropertyThis(TypeSender.get())) { - - @Override - public Permission getPropertyPermission(Property property) - { - return main.getUsedPermission(); - }; - - }; - } - // -------------------------------------------- // // OBJECT // -------------------------------------------- //