Fixed loading boosters on bukkit
This commit is contained in:
parent
c023531e85
commit
5e7897bb50
|
|
@ -26,48 +26,56 @@ public class ServerBoosterStorage extends BoosterStorage {
|
|||
|
||||
@Override
|
||||
public Booster loadBooster(JsonParser parser) throws IOException {
|
||||
JsonToken jsonToken = parser.currentToken();
|
||||
JsonToken jsonToken = parser.getCurrentToken();
|
||||
if (!jsonToken.isStructStart())
|
||||
return error("Didn't find struct start");
|
||||
|
||||
jsonToken = parser.nextToken();
|
||||
if (jsonToken != JsonToken.FIELD_NAME || !"uuid".equals(parser.getCurrentName()))
|
||||
return error("Didn't find uuid at expected location");
|
||||
parser.nextValue();
|
||||
UUID uuid = UUID.fromString(parser.getValueAsString());
|
||||
|
||||
jsonToken = parser.nextToken();
|
||||
if (jsonToken != JsonToken.FIELD_NAME || !"activator".equals(parser.getCurrentName()))
|
||||
return error("Didn't find activator at expected location");
|
||||
parser.nextValue();
|
||||
String activator = parser.getValueAsString();
|
||||
|
||||
jsonToken = parser.nextToken();
|
||||
if (jsonToken != JsonToken.FIELD_NAME || !"type".equals(parser.getCurrentName()))
|
||||
return error("Didn't find type at expected location");
|
||||
parser.nextValue();
|
||||
BoosterType boosterType = BoosterType.getByName(parser.getValueAsString());
|
||||
|
||||
jsonToken = parser.nextToken();
|
||||
if (jsonToken != JsonToken.FIELD_NAME || !"startingTime".equals(parser.getCurrentName()))
|
||||
return error("Didn't find startingTime at expected location");
|
||||
parser.nextValue();
|
||||
long startingTime = parser.getValueAsLong();
|
||||
|
||||
jsonToken = parser.nextToken();
|
||||
if (jsonToken != JsonToken.FIELD_NAME || !"duration".equals(parser.getCurrentName()))
|
||||
return error("Didn't find duration at expected location");
|
||||
parser.nextValue();
|
||||
long duration = parser.getValueAsLong();
|
||||
|
||||
jsonToken = parser.nextToken();
|
||||
if (jsonToken != JsonToken.FIELD_NAME || !"multiplier".equals(parser.getCurrentName()))
|
||||
return error("Didn't find multiplier at expected location");
|
||||
parser.nextValue();
|
||||
double multiplier = parser.getValueAsDouble();
|
||||
|
||||
jsonToken = parser.nextToken();
|
||||
if (jsonToken != JsonToken.FIELD_NAME || !"active".equals(parser.getCurrentName()))
|
||||
return error("Didn't find active at expected location");
|
||||
parser.nextValue();
|
||||
boolean active = parser.getValueAsBoolean();
|
||||
|
||||
jsonToken = parser.nextToken();
|
||||
if (jsonToken != JsonToken.FIELD_NAME || !"finished".equals(parser.getCurrentName()))
|
||||
return error("Didn't find finished at expected location");
|
||||
parser.nextValue();
|
||||
boolean finished = parser.getValueAsBoolean();
|
||||
return new com.alttd.boosters.data.Booster(uuid, activator, boosterType, startingTime, duration, multiplier, active, finished);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user