Create getShowLines utility methods in Property.

This commit is contained in:
Olof Larsson 2015-12-03 14:24:57 +01:00
parent 83920b7f45
commit 91a268e67e
2 changed files with 31 additions and 7 deletions

View File

@ -187,8 +187,7 @@ public class Parameter<T>
public static Parameter<Integer> getPage() public static Parameter<Integer> getPage()
{ {
// We can't use a singletone, because people might // We can't use a singleton because people might want to set a description.
// want to set a description.
return new Parameter<Integer>(1, TypeInteger.get(), "page", "1"); return new Parameter<Integer>(1, TypeInteger.get(), "page", "1");
} }

View File

@ -146,11 +146,6 @@ public abstract class Property<O, V> implements Named
return this.getValueType().createEditCommand(settings, this); return this.getValueType().createEditCommand(settings, this);
} }
public String getDisplayName()
{
return ChatColor.AQUA.toString() + this.getName();
}
public String getInheritedVisual(O object, O source, V value, CommandSender sender) public String getInheritedVisual(O object, O source, V value, CommandSender sender)
{ {
String string = this.getValueType().getVisual(value, sender); String string = this.getValueType().getVisual(value, sender);
@ -181,4 +176,34 @@ public abstract class Property<O, V> implements Named
return this.getInheritedVisual(object, source, value, sender); return this.getInheritedVisual(object, source, value, sender);
} }
// -------------------------------------------- //
// VISUAL
// -------------------------------------------- //
public String getDisplayName()
{
return ChatColor.AQUA.toString() + this.getName();
}
public List<String> getShowLines(O object, CommandSender sender)
{
String ret = Txt.parse("<aqua>%s<silver>: <pink>%s", this.getDisplayName(), this.getInheritedVisual(object, sender));
return new MassiveList<String>(Txt.PATTERN_NEWLINE.split(ret));
}
public static <O> List<String> getShowLines(O object, CommandSender sender, Collection<? extends Property<O, ?>> properties)
{
// Create
List<String> ret = new MassiveList<String>();
// Fill
for (Property<O, ?> property : properties)
{
ret.addAll(property.getShowLines(object, sender));
}
// Return
return ret;
}
} }