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