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,6 +343,41 @@ 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();
|
||||||
|
|
||||||
|
if (jsonObject.has("world") && jsonObject.has("yaw"))
|
||||||
|
{
|
||||||
|
// Old Faction LazyLocation
|
||||||
|
for (Entry<String, JsonElement> entry : jsonObject.entrySet())
|
||||||
|
{
|
||||||
|
final String key = entry.getKey();
|
||||||
|
final JsonElement value = entry.getValue();
|
||||||
|
|
||||||
|
switch(key)
|
||||||
|
{
|
||||||
|
case "world":
|
||||||
|
builder.world(value.getAsString());
|
||||||
|
break;
|
||||||
|
case "x":
|
||||||
|
builder.locationX(value.getAsDouble());
|
||||||
|
break;
|
||||||
|
case "y":
|
||||||
|
builder.locationY(value.getAsDouble());
|
||||||
|
break;
|
||||||
|
case "z":
|
||||||
|
builder.locationZ(value.getAsDouble());
|
||||||
|
break;
|
||||||
|
case "pitch":
|
||||||
|
builder.pitch(value.getAsFloat());
|
||||||
|
break;
|
||||||
|
case "yaw":
|
||||||
|
builder.yaw(value.getAsFloat());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The Standard Format
|
||||||
for (Entry<String, JsonElement> entry : jsonObject.entrySet())
|
for (Entry<String, JsonElement> entry : jsonObject.entrySet())
|
||||||
{
|
{
|
||||||
final String key = entry.getKey();
|
final String key = entry.getKey();
|
||||||
@ -394,6 +429,8 @@ public final class PS implements Cloneable, Serializable, Comparable<PS>
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user