9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2025-12-28 11:19:24 +00:00

fix: %rpgregions_region_timed% showing incorrect percentage, fix: time incrementing standing still

This commit is contained in:
SamB440
2022-06-06 17:18:27 +01:00
parent 2be1fe3cb8
commit e9dfa07a73
4 changed files with 44 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
package net.islandearth.rpgregions.managers.data.account;
import net.islandearth.rpgregions.managers.data.region.Discovery;
import net.islandearth.rpgregions.utils.TimeEntry;
import java.util.ArrayList;
import java.util.HashMap;
@@ -14,7 +15,7 @@ public class RPGRegionsAccount {
private final UUID uuid;
private final Map<String, Discovery> discoveredRegions;
private final List<AccountCooldown> cooldowns;
private final Map<String, Long> secondsInRegion;
private final Map<String, TimeEntry> secondsInRegion;
public RPGRegionsAccount(UUID uuid, Map<String, Discovery> discoveredRegions) {
this.uuid = uuid;
@@ -39,12 +40,12 @@ public class RPGRegionsAccount {
return cooldowns;
}
public Optional<Long> getStartTimeInRegion(String region) {
public Optional<TimeEntry> getTimeEntryInRegion(String region) {
return Optional.ofNullable(secondsInRegion.getOrDefault(region, null));
}
public void addStartTimeInRegion(String region, long time) {
secondsInRegion.put(region, time);
public void addTimeEntryInRegion(String region, long time) {
secondsInRegion.put(region, new TimeEntry(time));
}
public void removeStartTimeInRegion(String region) {

View File

@@ -0,0 +1,27 @@
package net.islandearth.rpgregions.utils;
public class TimeEntry {
private long start, latestEntry;
public TimeEntry(long start) {
this.start = start;
this.latestEntry = start;
}
public long getStart() {
return start;
}
public long getLatestEntry() {
return latestEntry;
}
public void setStart(long start) {
this.start = start;
}
public void setLatestEntry(long latestEntry) {
this.latestEntry = latestEntry;
}
}