1.0h Pages in editor show

This commit is contained in:
BuildTools 2016-03-15 19:10:26 +01:00 committed by Olof Larsson
parent 0a297211bf
commit 9c55b4836e
5 changed files with 43 additions and 15 deletions

View File

@ -16,6 +16,7 @@ import com.massivecraft.massivecore.command.type.Type;
import com.massivecraft.massivecore.event.EventMassiveCoreEditorEdit;
import com.massivecraft.massivecore.mson.Mson;
import com.massivecraft.massivecore.util.PermUtil;
import com.massivecraft.massivecore.util.Txt;
public class CommandEditAbstract<O, V> extends MassiveCommand
{
@ -297,18 +298,36 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
return alias;
}
public void show(CommandSender sender)
public void show(int page)
{
Mson descProperty = this.getProperty().getDisplayNameMson();
Mson descObject = this.getObjectVisual();
Mson descValue = this.getInheritedVisual();
message(mson(
descProperty,
" for ",
descObject,
": ",
descValue
).color(ChatColor.GRAY));
// For things with line breaks.
if (descValue.contains("\n"))
{
Mson title = mson(
this.getProperty().getDisplayNameMson(),
" for ",
this.getObjectVisual()
);
List<Mson> lines = descValue.split(Txt.PATTERN_NEWLINE);
message(Txt.getPage(lines, page, title, this));
}
// Others
else
{
Mson descProperty = this.getProperty().getDisplayNameMson();
Mson descObject = this.getObjectVisual();
message(mson(
descProperty,
" for ",
descObject,
": ",
descValue
).color(ChatColor.GRAY));
}
}
public void requireNullable() throws MassiveException

View File

@ -1,6 +1,7 @@
package com.massivecraft.massivecore.command.editor;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.Parameter;
public class CommandEditShow<O, V> extends CommandEditAbstract<O, V>
{
@ -17,6 +18,9 @@ public class CommandEditShow<O, V> extends CommandEditAbstract<O, V>
String alias = this.createCommandAlias();
this.setAliases(alias);
// Parameters
this.addParameter(Parameter.getPage());
// Desc
this.setDesc(alias + " " + this.getPropertyName());
}
@ -28,7 +32,8 @@ public class CommandEditShow<O, V> extends CommandEditAbstract<O, V>
@Override
public void perform() throws MassiveException
{
this.show(sender);
int page = this.readArg();
this.show(page);
}
}

View File

@ -32,7 +32,7 @@ public class CommandEditSimple<O, V> extends CommandEditAbstract<O, V>
// Show
if ( ! this.argIsSet(0))
{
this.show(sender);
this.show(0);
return;
}

View File

@ -67,7 +67,7 @@ public abstract class TypeContainer<C extends Object, E> extends TypeAbstract<C>
index++;
Mson part = Mson.mson(
Mson.mson(String.valueOf(index)).color(ChatColor.WHITE),
" ",
Mson.SPACE,
innerType.getVisualMson(element, sender)
);
parts.add(part);

View File

@ -1040,7 +1040,7 @@ public class Mson implements Serializable
// Implode simple
public static Mson implode(final Object[] list, final Mson glue, final Mson format)
{
{
List<Mson> parts = new MassiveList<>();
for (int i = 0; i < list.length; i++)
{
@ -1057,6 +1057,7 @@ public class Mson implements Serializable
}
parts.add(part);
}
return Mson.mson(parts);
}
@ -1144,7 +1145,10 @@ public class Mson implements Serializable
if (msons.size() == 1) parts.add(msons.get(0));
if (suffix != null) parts.add(suffix);
ret.add(implode(parts, SPACE));
if ( ! parts.isEmpty())
{
ret.add(implode(parts, SPACE));
}
if (msons.size() != 1)
{