Improve the PS deserialization logic so it understands LazyLocation from older versions of Factions.
This commit is contained in:
parent
cb02cc3ee9
commit
9b0845f2c3
@ -32,7 +32,7 @@ public class VersionCommand extends MCommand
|
|||||||
{
|
{
|
||||||
this.addRequirements(ReqHasPerm.get(permissionName));
|
this.addRequirements(ReqHasPerm.get(permissionName));
|
||||||
}
|
}
|
||||||
this.setDesc("display the plugin version");
|
this.setDesc("display plugin version");
|
||||||
|
|
||||||
this.addAliases(aliases);
|
this.addAliases(aliases);
|
||||||
}
|
}
|
||||||
|
@ -343,57 +343,94 @@ public final class PS implements Cloneable, Serializable, Comparable<PS>
|
|||||||
|
|
||||||
final JsonObject jsonObject = jsonElement.getAsJsonObject();
|
final JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||||
final PSBuilder builder = new PSBuilder();
|
final PSBuilder builder = new PSBuilder();
|
||||||
for (Entry<String, JsonElement> entry : jsonObject.entrySet())
|
|
||||||
{
|
|
||||||
final String key = entry.getKey();
|
|
||||||
final JsonElement value = entry.getValue();
|
|
||||||
|
|
||||||
switch(key)
|
if (jsonObject.has("world") && jsonObject.has("yaw"))
|
||||||
|
{
|
||||||
|
// Old Faction LazyLocation
|
||||||
|
for (Entry<String, JsonElement> entry : jsonObject.entrySet())
|
||||||
{
|
{
|
||||||
case NAME_SERIALIZED_WORLD:
|
final String key = entry.getKey();
|
||||||
builder.world(value.getAsString());
|
final JsonElement value = entry.getValue();
|
||||||
break;
|
|
||||||
case NAME_SERIALIZED_BLOCKX:
|
switch(key)
|
||||||
builder.blockX(value.getAsInt());
|
{
|
||||||
break;
|
case "world":
|
||||||
case NAME_SERIALIZED_BLOCKY:
|
builder.world(value.getAsString());
|
||||||
builder.blockY(value.getAsInt());
|
break;
|
||||||
break;
|
case "x":
|
||||||
case NAME_SERIALIZED_BLOCKZ:
|
builder.locationX(value.getAsDouble());
|
||||||
builder.blockZ(value.getAsInt());
|
break;
|
||||||
break;
|
case "y":
|
||||||
case NAME_SERIALIZED_LOCATIONX:
|
builder.locationY(value.getAsDouble());
|
||||||
builder.locationX(value.getAsDouble());
|
break;
|
||||||
break;
|
case "z":
|
||||||
case NAME_SERIALIZED_LOCATIONY:
|
builder.locationZ(value.getAsDouble());
|
||||||
builder.locationY(value.getAsDouble());
|
break;
|
||||||
break;
|
case "pitch":
|
||||||
case NAME_SERIALIZED_LOCATIONZ:
|
builder.pitch(value.getAsFloat());
|
||||||
builder.locationZ(value.getAsDouble());
|
break;
|
||||||
break;
|
case "yaw":
|
||||||
case NAME_SERIALIZED_CHUNKX:
|
builder.yaw(value.getAsFloat());
|
||||||
builder.chunkX(value.getAsInt());
|
break;
|
||||||
break;
|
}
|
||||||
case NAME_SERIALIZED_CHUNKZ:
|
|
||||||
builder.chunkZ(value.getAsInt());
|
|
||||||
break;
|
|
||||||
case NAME_SERIALIZED_PITCH:
|
|
||||||
builder.pitch(value.getAsFloat());
|
|
||||||
break;
|
|
||||||
case NAME_SERIALIZED_YAW:
|
|
||||||
builder.yaw(value.getAsFloat());
|
|
||||||
break;
|
|
||||||
case NAME_SERIALIZED_VELOCITYX:
|
|
||||||
builder.velocityX(value.getAsDouble());
|
|
||||||
break;
|
|
||||||
case NAME_SERIALIZED_VELOCITYY:
|
|
||||||
builder.velocityY(value.getAsDouble());
|
|
||||||
break;
|
|
||||||
case NAME_SERIALIZED_VELOCITYZ:
|
|
||||||
builder.velocityZ(value.getAsDouble());
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The Standard Format
|
||||||
|
for (Entry<String, JsonElement> entry : jsonObject.entrySet())
|
||||||
|
{
|
||||||
|
final String key = entry.getKey();
|
||||||
|
final JsonElement value = entry.getValue();
|
||||||
|
|
||||||
|
switch(key)
|
||||||
|
{
|
||||||
|
case NAME_SERIALIZED_WORLD:
|
||||||
|
builder.world(value.getAsString());
|
||||||
|
break;
|
||||||
|
case NAME_SERIALIZED_BLOCKX:
|
||||||
|
builder.blockX(value.getAsInt());
|
||||||
|
break;
|
||||||
|
case NAME_SERIALIZED_BLOCKY:
|
||||||
|
builder.blockY(value.getAsInt());
|
||||||
|
break;
|
||||||
|
case NAME_SERIALIZED_BLOCKZ:
|
||||||
|
builder.blockZ(value.getAsInt());
|
||||||
|
break;
|
||||||
|
case NAME_SERIALIZED_LOCATIONX:
|
||||||
|
builder.locationX(value.getAsDouble());
|
||||||
|
break;
|
||||||
|
case NAME_SERIALIZED_LOCATIONY:
|
||||||
|
builder.locationY(value.getAsDouble());
|
||||||
|
break;
|
||||||
|
case NAME_SERIALIZED_LOCATIONZ:
|
||||||
|
builder.locationZ(value.getAsDouble());
|
||||||
|
break;
|
||||||
|
case NAME_SERIALIZED_CHUNKX:
|
||||||
|
builder.chunkX(value.getAsInt());
|
||||||
|
break;
|
||||||
|
case NAME_SERIALIZED_CHUNKZ:
|
||||||
|
builder.chunkZ(value.getAsInt());
|
||||||
|
break;
|
||||||
|
case NAME_SERIALIZED_PITCH:
|
||||||
|
builder.pitch(value.getAsFloat());
|
||||||
|
break;
|
||||||
|
case NAME_SERIALIZED_YAW:
|
||||||
|
builder.yaw(value.getAsFloat());
|
||||||
|
break;
|
||||||
|
case NAME_SERIALIZED_VELOCITYX:
|
||||||
|
builder.velocityX(value.getAsDouble());
|
||||||
|
break;
|
||||||
|
case NAME_SERIALIZED_VELOCITYY:
|
||||||
|
builder.velocityY(value.getAsDouble());
|
||||||
|
break;
|
||||||
|
case NAME_SERIALIZED_VELOCITYZ:
|
||||||
|
builder.velocityZ(value.getAsDouble());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user