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.event.EventMassiveCoreEditorEdit;
import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.mson.Mson;
import com.massivecraft.massivecore.util.PermUtil; import com.massivecraft.massivecore.util.PermUtil;
import com.massivecraft.massivecore.util.Txt;
public class CommandEditAbstract<O, V> extends MassiveCommand public class CommandEditAbstract<O, V> extends MassiveCommand
{ {
@ -297,11 +298,28 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
return alias; return alias;
} }
public void show(CommandSender sender) public void show(int page)
{
Mson descValue = this.getInheritedVisual();
// 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 descProperty = this.getProperty().getDisplayNameMson();
Mson descObject = this.getObjectVisual(); Mson descObject = this.getObjectVisual();
Mson descValue = this.getInheritedVisual();
message(mson( message(mson(
descProperty, descProperty,
" for ", " for ",
@ -310,6 +328,7 @@ public class CommandEditAbstract<O, V> extends MassiveCommand
descValue descValue
).color(ChatColor.GRAY)); ).color(ChatColor.GRAY));
} }
}
public void requireNullable() throws MassiveException public void requireNullable() throws MassiveException
{ {

View File

@ -1,6 +1,7 @@
package com.massivecraft.massivecore.command.editor; package com.massivecraft.massivecore.command.editor;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.Parameter;
public class CommandEditShow<O, V> extends CommandEditAbstract<O, V> 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(); String alias = this.createCommandAlias();
this.setAliases(alias); this.setAliases(alias);
// Parameters
this.addParameter(Parameter.getPage());
// Desc // Desc
this.setDesc(alias + " " + this.getPropertyName()); this.setDesc(alias + " " + this.getPropertyName());
} }
@ -28,7 +32,8 @@ public class CommandEditShow<O, V> extends CommandEditAbstract<O, V>
@Override @Override
public void perform() throws MassiveException 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 // Show
if ( ! this.argIsSet(0)) if ( ! this.argIsSet(0))
{ {
this.show(sender); this.show(0);
return; return;
} }

View File

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

View File

@ -1057,6 +1057,7 @@ public class Mson implements Serializable
} }
parts.add(part); parts.add(part);
} }
return Mson.mson(parts); return Mson.mson(parts);
} }
@ -1144,7 +1145,10 @@ public class Mson implements Serializable
if (msons.size() == 1) parts.add(msons.get(0)); if (msons.size() == 1) parts.add(msons.get(0));
if (suffix != null) parts.add(suffix); if (suffix != null) parts.add(suffix);
if ( ! parts.isEmpty())
{
ret.add(implode(parts, SPACE)); ret.add(implode(parts, SPACE));
}
if (msons.size() != 1) if (msons.size() != 1)
{ {