diff --git a/api/src/main/java/com/alttd/boosterapi/config/BoosterFileStorage.java b/api/src/main/java/com/alttd/boosterapi/config/BoosterFileStorage.java index 4679ec4..98f53c2 100644 --- a/api/src/main/java/com/alttd/boosterapi/config/BoosterFileStorage.java +++ b/api/src/main/java/com/alttd/boosterapi/config/BoosterFileStorage.java @@ -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 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(); } diff --git a/api/src/main/java/com/alttd/boosterapi/data/Booster.java b/api/src/main/java/com/alttd/boosterapi/data/Booster.java index 889b336..96dffa4 100644 --- a/api/src/main/java/com/alttd/boosterapi/data/Booster.java +++ b/api/src/main/java/com/alttd/boosterapi/data/Booster.java @@ -15,7 +15,6 @@ public class Booster implements Comparable { 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 { 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 { } 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 { 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 { ", duration=" + duration + ", boosterType=" + boosterType + ", multiplier=" + multiplier + - ", running=" + running + '}'; } } diff --git a/api/src/main/java/com/alttd/boosterapi/data/BoosterCache.java b/api/src/main/java/com/alttd/boosterapi/data/BoosterCache.java index b789d9e..f4656ad 100644 --- a/api/src/main/java/com/alttd/boosterapi/data/BoosterCache.java +++ b/api/src/main/java/com/alttd/boosterapi/data/BoosterCache.java @@ -41,7 +41,14 @@ public class BoosterCache { return; } LinkedList 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 getActiveBooster(BoosterType boosterType) {