Removed active boolean for booster since we don't use it
This commit is contained in:
parent
36a7b0cf68
commit
75aa05cdf5
|
|
@ -123,14 +123,7 @@ public class BoosterFileStorage {
|
|||
parser.nextValue();
|
||||
double multiplier = parser.getValueAsDouble();
|
||||
|
||||
jsonToken = parser.nextToken();
|
||||
if (jsonToken != JsonToken.FIELD_NAME || !"running".equals(parser.getCurrentName()))
|
||||
return error("Didn't find running at expected location");
|
||||
parser.nextValue();
|
||||
boolean running = parser.getValueAsBoolean();
|
||||
parser.nextValue();
|
||||
|
||||
return Optional.of(new Booster(boosterUUID, activatorName, boosterType, startingTime, duration, multiplier, running));
|
||||
return Optional.of(new Booster(boosterUUID, activatorName, boosterType, startingTime, duration, multiplier));
|
||||
}
|
||||
|
||||
private Optional<Booster> error(String error) {
|
||||
|
|
@ -160,7 +153,6 @@ public class BoosterFileStorage {
|
|||
generator.writeNumberField("startingTime", booster.getStartingTime().toEpochMilli());
|
||||
generator.writeNumberField("duration", booster.getDuration().toMillis());
|
||||
generator.writeNumberField("multiplier", booster.getMultiplier());
|
||||
generator.writeBooleanField("running", booster.getRunning());
|
||||
|
||||
generator.writeEndObject();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ public class Booster implements Comparable<Booster> {
|
|||
private Duration duration;
|
||||
private final BoosterType boosterType;
|
||||
private final Double multiplier;
|
||||
private Boolean running;
|
||||
|
||||
public Booster(UUID boosterUUID, BoosterType boosterType, String reason, Duration duration, double multiplier) {
|
||||
this.boosterUUID = boosterUUID;
|
||||
|
|
@ -23,7 +22,6 @@ public class Booster implements Comparable<Booster> {
|
|||
this.activatorName = reason;
|
||||
this.duration = duration;
|
||||
this.multiplier = multiplier;
|
||||
this.running = false;
|
||||
this.startingTime = Instant.now();
|
||||
}
|
||||
|
||||
|
|
@ -32,14 +30,13 @@ public class Booster implements Comparable<Booster> {
|
|||
}
|
||||
|
||||
public Booster(UUID boosterUUID, String activatorName, BoosterType boosterType, Instant startingTime,
|
||||
Duration duration, double multiplier, boolean running) {
|
||||
Duration duration, double multiplier) {
|
||||
this.boosterUUID = boosterUUID;
|
||||
this.activatorName = activatorName;
|
||||
this.boosterType = boosterType;
|
||||
this.startingTime = startingTime;
|
||||
this.duration = duration;
|
||||
this.multiplier = multiplier;
|
||||
this.running = running;
|
||||
}
|
||||
|
||||
public void updateDuration() {
|
||||
|
|
@ -76,10 +73,6 @@ public class Booster implements Comparable<Booster> {
|
|||
return multiplier;
|
||||
}
|
||||
|
||||
public Boolean getRunning() {
|
||||
return running;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
|
|
@ -114,7 +107,6 @@ public class Booster implements Comparable<Booster> {
|
|||
", duration=" + duration +
|
||||
", boosterType=" + boosterType +
|
||||
", multiplier=" + multiplier +
|
||||
", running=" + running +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,14 @@ public class BoosterCache {
|
|||
return;
|
||||
}
|
||||
LinkedList<Booster> list = boosters.get(boosterType);
|
||||
Booster oldActive = null;
|
||||
if (list.size() > 1) {
|
||||
oldActive = list.get(0);
|
||||
}
|
||||
list.sort(Booster::compareTo);
|
||||
if (oldActive != null && !list.get(0).getBoosterUUID().equals(oldActive.getBoosterUUID())) {
|
||||
oldActive.updateDuration();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized Optional<Booster> getActiveBooster(BoosterType boosterType) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user