Editor getUsedSettings

This commit is contained in:
Olof Larsson 2016-02-02 15:21:28 +01:00
parent f133149321
commit 9a50457b3d
2 changed files with 23 additions and 15 deletions

View File

@ -11,7 +11,7 @@ public class CommandEditUsed<O> extends CommandEditSimple<CommandSender, O>
public CommandEditUsed(EditSettings<O> settings) public CommandEditUsed(EditSettings<O> settings)
{ {
// Super // Super
super(settings.createUsedSettings(), settings.getUsedProperty()); super(settings.getUsedSettings(), settings.getUsedProperty());
// Aliases // Aliases
this.setAliases("used", "selected"); this.setAliases("used", "selected");

View File

@ -26,6 +26,28 @@ public class EditSettings<O>
public Property<CommandSender, O> getUsedProperty() { return this.usedProperty; } public Property<CommandSender, O> getUsedProperty() { return this.usedProperty; }
public void setUsedProperty(Property<CommandSender, O> usedProperty) { this.usedProperty = usedProperty; } public void setUsedProperty(Property<CommandSender, O> usedProperty) { this.usedProperty = usedProperty; }
// The Internal EditSettings<CommandSender> for setting the used.
protected EditSettings<CommandSender> usedSettings = null;
public EditSettings<CommandSender> getUsedSettings()
{
if (this.usedSettings == null)
{
this.usedSettings = this.createUsedSettings();
}
return this.usedSettings;
}
protected EditSettings<CommandSender> createUsedSettings()
{
final EditSettings<O> main = this;
return new EditSettings<CommandSender>(TypeSender.get(), new PropertyThis<CommandSender>(TypeSender.get())) {
@Override
public Permission getPropertyPermission(Property<CommandSender,?> property)
{
return main.getUsedPermission();
}
};
}
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
@ -41,20 +63,6 @@ public class EditSettings<O>
this(objectType, null); this(objectType, null);
} }
public EditSettings<CommandSender> createUsedSettings()
{
final EditSettings<O> main = this;
return new EditSettings<CommandSender>(TypeSender.get(), new PropertyThis<CommandSender>(TypeSender.get())) {
@Override
public Permission getPropertyPermission(Property<CommandSender,?> property)
{
return main.getUsedPermission();
};
};
}
// -------------------------------------------- // // -------------------------------------------- //
// OBJECT // OBJECT
// -------------------------------------------- // // -------------------------------------------- //