Adding some PS format

This commit is contained in:
Olof Larsson 2013-04-26 20:07:25 +02:00
parent 9b3a87c0da
commit c34c2354bd
6 changed files with 106 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package com.massivecraft.mcore.ps;
import java.util.ArrayList;
import java.util.List;
import com.massivecraft.mcore.mixin.Mixin;
import com.massivecraft.mcore.util.Txt;
public class PSFormatAbstract implements PSFormat
@ -14,6 +15,9 @@ public class PSFormatAbstract implements PSFormat
private final String strNull;
private final String strStart;
private final boolean useWorldDisplayname;
private final boolean useWorldAlias;
private final String formatWorld;
private final String formatBlockX;
private final String formatBlockY;
@ -36,10 +40,12 @@ public class PSFormatAbstract implements PSFormat
// CONSTRUCT
// -------------------------------------------- //
public PSFormatAbstract(String strNull, String strStart, String formatWorld, String formatBlockX, String formatBlockY, String formatBlockZ, String formatLocationX, String formatLocationY, String formatLocationZ, String formatChunkX, String formatChunkZ, String formatPitch, String formatYaw, String formatVelocityX, String formatVelocityY, String formatVelocityZ, String strGlue, String strStop)
public PSFormatAbstract(String strNull, String strStart, boolean useWorldDisplayname, boolean useWorldAlias, String formatWorld, String formatBlockX, String formatBlockY, String formatBlockZ, String formatLocationX, String formatLocationY, String formatLocationZ, String formatChunkX, String formatChunkZ, String formatPitch, String formatYaw, String formatVelocityX, String formatVelocityY, String formatVelocityZ, String strGlue, String strStop)
{
this.strNull = strNull;
this.strStart = strStart;
this.useWorldDisplayname = useWorldDisplayname;
this.useWorldAlias = useWorldAlias;
this.formatWorld = formatWorld;
this.formatBlockX = formatBlockX;
this.formatBlockY = formatBlockY;
@ -82,8 +88,23 @@ public class PSFormatAbstract implements PSFormat
Object val = null;
val = ps.getWorld();
if (val != null) ret.add(String.format(this.formatWorld, val));
if (this.useWorldDisplayname)
{
val = ps.getWorld();
val = Mixin.getWorldDisplayName(val.toString());
if (val != null) ret.add(String.format(this.formatWorld, val));
}
else if (this.useWorldAlias)
{
val = ps.getWorld();
val = Mixin.getWorldAliasOrId(val.toString());
if (val != null) ret.add(String.format(this.formatWorld, val));
}
else
{
val = ps.getWorld();
if (val != null) ret.add(String.format(this.formatWorld, val));
}
val = ps.getBlockX();
if (val != null) ret.add(String.format(this.formatBlockX, val));

View File

@ -15,6 +15,8 @@ public class PSFormatDesc extends PSFormatAbstract
super(
Txt.parse("<silver><em>NULL"),
"",
false,
true,
Txt.parse("<k>") + PS.NAME_SERIALIZED_WORLD + Txt.parse(" <v>") + "%s",
Txt.parse("<k>") + PS.NAME_SERIALIZED_BLOCKX + Txt.parse(" <v>") + "%d",
Txt.parse("<k>") + PS.NAME_SERIALIZED_BLOCKY + Txt.parse(" <v>") + "%d",

View File

@ -13,6 +13,8 @@ public class PSFormatFormal extends PSFormatAbstract
super(
"PS{NULL}",
"PS{",
false,
false,
PS.NAME_SERIALIZED_WORLD + ": %s",
PS.NAME_SERIALIZED_BLOCKX + ": %d",
PS.NAME_SERIALIZED_BLOCKY + ": %d",

View File

@ -0,0 +1,38 @@
package com.massivecraft.mcore.ps;
import com.massivecraft.mcore.util.Txt;
public class PSFormatHumanComma extends PSFormatAbstract
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static PSFormatHumanComma i = new PSFormatHumanComma();
public static PSFormatHumanComma get() { return i; }
private PSFormatHumanComma()
{
super(
Txt.parse("<silver><em>NULL"),
Txt.parse(""),
true,
false,
Txt.parse("<v>%s"),
Txt.parse("<v>%d"),
Txt.parse("<v>%d"),
Txt.parse("<v>%d"),
Txt.parse("<v>%.2f"),
Txt.parse("<v>%.2f"),
Txt.parse("<v>%.2f"),
Txt.parse("<v>%d"),
Txt.parse("<v>%d"),
Txt.parse("<v>%.2f"),
Txt.parse("<v>%.2f"),
Txt.parse("<v>%.2f"),
Txt.parse("<v>%.2f"),
Txt.parse("<v>%.2f"),
Txt.parse("<i>, "),
Txt.parse("")
);
}
}

View File

@ -0,0 +1,38 @@
package com.massivecraft.mcore.ps;
import com.massivecraft.mcore.util.Txt;
public class PSFormatHumanSpace extends PSFormatAbstract
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static PSFormatHumanSpace i = new PSFormatHumanSpace();
public static PSFormatHumanSpace get() { return i; }
private PSFormatHumanSpace()
{
super(
Txt.parse("<silver><em>NULL"),
Txt.parse(""),
true,
false,
Txt.parse("<v>%s"),
Txt.parse("<v>%d"),
Txt.parse("<v>%d"),
Txt.parse("<v>%d"),
Txt.parse("<v>%.2f"),
Txt.parse("<v>%.2f"),
Txt.parse("<v>%.2f"),
Txt.parse("<v>%d"),
Txt.parse("<v>%d"),
Txt.parse("<v>%.2f"),
Txt.parse("<v>%.2f"),
Txt.parse("<v>%.2f"),
Txt.parse("<v>%.2f"),
Txt.parse("<v>%.2f"),
Txt.parse(" "),
Txt.parse("")
);
}
}

View File

@ -15,6 +15,8 @@ public class PSFormatSlug extends PSFormatAbstract
super(
Txt.parse("<silver><em>NULL"),
"",
false,
true,
Txt.parse("<k>") + PS.NAME_SERIALIZED_WORLD + Txt.parse("<v>") + "%s",
Txt.parse("<k>") + PS.NAME_SERIALIZED_BLOCKX + Txt.parse("<v>") + "%d",
Txt.parse("<k>") + PS.NAME_SERIALIZED_BLOCKY + Txt.parse("<v>") + "%d",