mirror of
https://github.com/SunNetservers/MiniGames.git
synced 2024-12-05 00:43:15 +01:00
Fixes a bug causing duplicate records to be stored
This commit is contained in:
parent
b95cc294ab
commit
cd7d8eded0
@ -77,7 +77,10 @@ public class DropperArenaRecordsRegistry implements ConfigurationSerializable {
|
||||
* @return <p>The result explaining what type of record was achieved</p>
|
||||
*/
|
||||
public @NotNull RecordResult registerDeathRecord(@NotNull UUID playerId, int deaths) {
|
||||
Consumer<Integer> consumer = (value) -> leastDeaths.add(new IntegerRecord(playerId, value));
|
||||
Consumer<Integer> consumer = (value) -> {
|
||||
leastDeaths.removeIf((item) -> item.getUserId().equals(playerId));
|
||||
leastDeaths.add(new IntegerRecord(playerId, value));
|
||||
};
|
||||
Set<ArenaRecord<Integer>> asInt = new HashSet<>(leastDeaths);
|
||||
return registerRecord(asInt, consumer, playerId, deaths);
|
||||
}
|
||||
@ -90,7 +93,10 @@ public class DropperArenaRecordsRegistry implements ConfigurationSerializable {
|
||||
* @return <p>The result explaining what type of record was achieved</p>
|
||||
*/
|
||||
public @NotNull RecordResult registerTimeRecord(@NotNull UUID playerId, long milliseconds) {
|
||||
Consumer<Long> consumer = (value) -> shortestTimeMilliSeconds.add(new LongRecord(playerId, value));
|
||||
Consumer<Long> consumer = (value) -> {
|
||||
shortestTimeMilliSeconds.removeIf((item) -> item.getUserId().equals(playerId));
|
||||
shortestTimeMilliSeconds.add(new LongRecord(playerId, value));
|
||||
};
|
||||
Set<ArenaRecord<Long>> asLong = new HashSet<>(shortestTimeMilliSeconds);
|
||||
return registerRecord(asLong, consumer, playerId, milliseconds);
|
||||
}
|
||||
|
@ -24,6 +24,11 @@ public class IntegerRecord extends SummableArenaRecord<Integer> {
|
||||
return new IntegerRecord(this.getUserId(), this.getRecord() + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other instanceof IntegerRecord && this.getUserId().equals(((IntegerRecord) other).getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes the saved arena record
|
||||
*
|
||||
|
@ -19,6 +19,11 @@ public class LongRecord extends SummableArenaRecord<Long> {
|
||||
super(userId, record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other instanceof LongRecord && this.getUserId().equals(((LongRecord) other).getUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SummableArenaRecord<Long> sum(Long value) {
|
||||
return new LongRecord(this.getUserId(), this.getRecord() + value);
|
||||
|
Loading…
Reference in New Issue
Block a user