diff --git a/src/com/massivecraft/mcore/ps/PSFormatAbstract.java b/src/com/massivecraft/mcore/ps/PSFormatAbstract.java index 4f42caa1..2ed855a8 100644 --- a/src/com/massivecraft/mcore/ps/PSFormatAbstract.java +++ b/src/com/massivecraft/mcore/ps/PSFormatAbstract.java @@ -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)); diff --git a/src/com/massivecraft/mcore/ps/PSFormatDesc.java b/src/com/massivecraft/mcore/ps/PSFormatDesc.java index 7dceaad4..6924c95e 100644 --- a/src/com/massivecraft/mcore/ps/PSFormatDesc.java +++ b/src/com/massivecraft/mcore/ps/PSFormatDesc.java @@ -15,6 +15,8 @@ public class PSFormatDesc extends PSFormatAbstract super( Txt.parse("NULL"), "", + false, + true, Txt.parse("") + PS.NAME_SERIALIZED_WORLD + Txt.parse(" ") + "%s", Txt.parse("") + PS.NAME_SERIALIZED_BLOCKX + Txt.parse(" ") + "%d", Txt.parse("") + PS.NAME_SERIALIZED_BLOCKY + Txt.parse(" ") + "%d", diff --git a/src/com/massivecraft/mcore/ps/PSFormatFormal.java b/src/com/massivecraft/mcore/ps/PSFormatFormal.java index 9f2be620..b0bfd8ca 100644 --- a/src/com/massivecraft/mcore/ps/PSFormatFormal.java +++ b/src/com/massivecraft/mcore/ps/PSFormatFormal.java @@ -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", diff --git a/src/com/massivecraft/mcore/ps/PSFormatHumanComma.java b/src/com/massivecraft/mcore/ps/PSFormatHumanComma.java new file mode 100644 index 00000000..00a3d24a --- /dev/null +++ b/src/com/massivecraft/mcore/ps/PSFormatHumanComma.java @@ -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("NULL"), + Txt.parse(""), + true, + false, + Txt.parse("%s"), + Txt.parse("%d"), + Txt.parse("%d"), + Txt.parse("%d"), + Txt.parse("%.2f"), + Txt.parse("%.2f"), + Txt.parse("%.2f"), + Txt.parse("%d"), + Txt.parse("%d"), + Txt.parse("%.2f"), + Txt.parse("%.2f"), + Txt.parse("%.2f"), + Txt.parse("%.2f"), + Txt.parse("%.2f"), + Txt.parse(", "), + Txt.parse("") + ); + } +} diff --git a/src/com/massivecraft/mcore/ps/PSFormatHumanSpace.java b/src/com/massivecraft/mcore/ps/PSFormatHumanSpace.java new file mode 100644 index 00000000..d6b2d7b5 --- /dev/null +++ b/src/com/massivecraft/mcore/ps/PSFormatHumanSpace.java @@ -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("NULL"), + Txt.parse(""), + true, + false, + Txt.parse("%s"), + Txt.parse("%d"), + Txt.parse("%d"), + Txt.parse("%d"), + Txt.parse("%.2f"), + Txt.parse("%.2f"), + Txt.parse("%.2f"), + Txt.parse("%d"), + Txt.parse("%d"), + Txt.parse("%.2f"), + Txt.parse("%.2f"), + Txt.parse("%.2f"), + Txt.parse("%.2f"), + Txt.parse("%.2f"), + Txt.parse(" "), + Txt.parse("") + ); + } +} diff --git a/src/com/massivecraft/mcore/ps/PSFormatSlug.java b/src/com/massivecraft/mcore/ps/PSFormatSlug.java index c825a428..f0b72d4c 100644 --- a/src/com/massivecraft/mcore/ps/PSFormatSlug.java +++ b/src/com/massivecraft/mcore/ps/PSFormatSlug.java @@ -15,6 +15,8 @@ public class PSFormatSlug extends PSFormatAbstract super( Txt.parse("NULL"), "", + false, + true, Txt.parse("") + PS.NAME_SERIALIZED_WORLD + Txt.parse("") + "%s", Txt.parse("") + PS.NAME_SERIALIZED_BLOCKX + Txt.parse("") + "%d", Txt.parse("") + PS.NAME_SERIALIZED_BLOCKY + Txt.parse("") + "%d",