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