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();
|
parser.nextValue();
|
||||||
double multiplier = parser.getValueAsDouble();
|
double multiplier = parser.getValueAsDouble();
|
||||||
|
|
||||||
jsonToken = parser.nextToken();
|
return Optional.of(new Booster(boosterUUID, activatorName, boosterType, startingTime, duration, multiplier));
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<Booster> error(String error) {
|
private Optional<Booster> error(String error) {
|
||||||
|
|
@ -160,7 +153,6 @@ public class BoosterFileStorage {
|
||||||
generator.writeNumberField("startingTime", booster.getStartingTime().toEpochMilli());
|
generator.writeNumberField("startingTime", booster.getStartingTime().toEpochMilli());
|
||||||
generator.writeNumberField("duration", booster.getDuration().toMillis());
|
generator.writeNumberField("duration", booster.getDuration().toMillis());
|
||||||
generator.writeNumberField("multiplier", booster.getMultiplier());
|
generator.writeNumberField("multiplier", booster.getMultiplier());
|
||||||
generator.writeBooleanField("running", booster.getRunning());
|
|
||||||
|
|
||||||
generator.writeEndObject();
|
generator.writeEndObject();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ public class Booster implements Comparable<Booster> {
|
||||||
private Duration duration;
|
private Duration duration;
|
||||||
private final BoosterType boosterType;
|
private final BoosterType boosterType;
|
||||||
private final Double multiplier;
|
private final Double multiplier;
|
||||||
private Boolean running;
|
|
||||||
|
|
||||||
public Booster(UUID boosterUUID, BoosterType boosterType, String reason, Duration duration, double multiplier) {
|
public Booster(UUID boosterUUID, BoosterType boosterType, String reason, Duration duration, double multiplier) {
|
||||||
this.boosterUUID = boosterUUID;
|
this.boosterUUID = boosterUUID;
|
||||||
|
|
@ -23,7 +22,6 @@ public class Booster implements Comparable<Booster> {
|
||||||
this.activatorName = reason;
|
this.activatorName = reason;
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
this.multiplier = multiplier;
|
this.multiplier = multiplier;
|
||||||
this.running = false;
|
|
||||||
this.startingTime = Instant.now();
|
this.startingTime = Instant.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,14 +30,13 @@ public class Booster implements Comparable<Booster> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Booster(UUID boosterUUID, String activatorName, BoosterType boosterType, Instant startingTime,
|
public Booster(UUID boosterUUID, String activatorName, BoosterType boosterType, Instant startingTime,
|
||||||
Duration duration, double multiplier, boolean running) {
|
Duration duration, double multiplier) {
|
||||||
this.boosterUUID = boosterUUID;
|
this.boosterUUID = boosterUUID;
|
||||||
this.activatorName = activatorName;
|
this.activatorName = activatorName;
|
||||||
this.boosterType = boosterType;
|
this.boosterType = boosterType;
|
||||||
this.startingTime = startingTime;
|
this.startingTime = startingTime;
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
this.multiplier = multiplier;
|
this.multiplier = multiplier;
|
||||||
this.running = running;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateDuration() {
|
public void updateDuration() {
|
||||||
|
|
@ -76,10 +73,6 @@ public class Booster implements Comparable<Booster> {
|
||||||
return multiplier;
|
return multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getRunning() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o)
|
if (this == o)
|
||||||
|
|
@ -114,7 +107,6 @@ public class Booster implements Comparable<Booster> {
|
||||||
", duration=" + duration +
|
", duration=" + duration +
|
||||||
", boosterType=" + boosterType +
|
", boosterType=" + boosterType +
|
||||||
", multiplier=" + multiplier +
|
", multiplier=" + multiplier +
|
||||||
", running=" + running +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,14 @@ public class BoosterCache {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LinkedList<Booster> list = boosters.get(boosterType);
|
LinkedList<Booster> list = boosters.get(boosterType);
|
||||||
|
Booster oldActive = null;
|
||||||
|
if (list.size() > 1) {
|
||||||
|
oldActive = list.get(0);
|
||||||
|
}
|
||||||
list.sort(Booster::compareTo);
|
list.sort(Booster::compareTo);
|
||||||
|
if (oldActive != null && !list.get(0).getBoosterUUID().equals(oldActive.getBoosterUUID())) {
|
||||||
|
oldActive.updateDuration();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Optional<Booster> getActiveBooster(BoosterType boosterType) {
|
public synchronized Optional<Booster> getActiveBooster(BoosterType boosterType) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user