Upload via Git Manager GUI - StatsManager.java
This commit is contained in:
@@ -1,35 +1,35 @@
|
|||||||
package net.viper.status.stats;
|
package net.viper.status.stats;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class StatsManager {
|
public class StatsManager {
|
||||||
private final ConcurrentHashMap<UUID, PlayerStats> map = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<UUID, PlayerStats> map = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public PlayerStats get(UUID uuid, String name) {
|
public PlayerStats get(UUID uuid, String name) {
|
||||||
return map.compute(uuid, (k, v) -> {
|
return map.compute(uuid, (k, v) -> {
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
return new PlayerStats(uuid, name != null ? name : "");
|
return new PlayerStats(uuid, name != null ? name : "");
|
||||||
} else {
|
} else {
|
||||||
if (name != null && !name.isEmpty()) v.name = name;
|
if (name != null && !name.isEmpty()) v.name = name;
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerStats getIfPresent(UUID uuid) {
|
public PlayerStats getIfPresent(UUID uuid) {
|
||||||
return map.get(uuid);
|
return map.get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<PlayerStats> all() {
|
public Iterable<PlayerStats> all() {
|
||||||
return map.values();
|
return map.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void put(PlayerStats ps) {
|
public void put(PlayerStats ps) {
|
||||||
map.put(ps.uuid, ps);
|
map.put(ps.uuid, ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(UUID uuid) {
|
public void remove(UUID uuid) {
|
||||||
map.remove(uuid);
|
map.remove(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user