TCheckpoint
This commit is contained in:
parent
aa415c443e
commit
00faf1f2fd
16 changed files with 38 additions and 7 deletions
|
|
@ -65,10 +65,16 @@ public class PlayerStats {
|
|||
return;
|
||||
}
|
||||
if (type == PersistentDataType.INTEGER) {
|
||||
int currentStat = dataContainer.getOrDefault(new NamespacedKey(plugin, stat), PersistentDataType.INTEGER, 0);
|
||||
Integer currentStat = dataContainer.get(new NamespacedKey(plugin, stat), PersistentDataType.INTEGER);
|
||||
if (currentStat == null) {
|
||||
currentStat = 0;
|
||||
}
|
||||
dataContainer.set(new NamespacedKey(plugin, stat), PersistentDataType.INTEGER, currentStat + amount);
|
||||
} else if (type == PersistentDataType.DOUBLE) {
|
||||
double currentStat = dataContainer.getOrDefault(new NamespacedKey(plugin, stat), PersistentDataType.DOUBLE, 0.0);
|
||||
Double currentStat = dataContainer.get(new NamespacedKey(plugin, stat), PersistentDataType.DOUBLE);
|
||||
if (currentStat == null) {
|
||||
currentStat = 0.0;
|
||||
}
|
||||
dataContainer.set(new NamespacedKey(plugin, stat), PersistentDataType.DOUBLE, currentStat + amount);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,10 +88,10 @@ public class ServerStats {
|
|||
return;
|
||||
}
|
||||
if (type == Integer.class) {
|
||||
int currentStat = stats.getOrDefault(stat, 0) instanceof Number ? ((Number) stats.get(stat)).intValue() : 0;
|
||||
int currentStat = stats.get(stat) instanceof Number ? ((Number) stats.get(stat)).intValue() : 0;
|
||||
stats.put(stat, currentStat + amount);
|
||||
} else if (type == Double.class) {
|
||||
double currentStat = stats.getOrDefault(stat, 0.0) instanceof Number ? ((Number) stats.get(stat)).doubleValue() : 0.0;
|
||||
double currentStat = stats.get(stat) instanceof Number ? ((Number) stats.get(stat)).doubleValue() : 0.0;
|
||||
stats.put(stat, currentStat + amount);
|
||||
}
|
||||
saveStats();
|
||||
|
|
|
|||
|
|
@ -63,11 +63,23 @@ public class WorldStats {
|
|||
return;
|
||||
}
|
||||
if (type == PersistentDataType.INTEGER) {
|
||||
int currentStat = dataContainer.getOrDefault(new NamespacedKey(plugin, stat), PersistentDataType.INTEGER, 0);
|
||||
Integer currentStat = dataContainer.get(new NamespacedKey(plugin, stat), PersistentDataType.INTEGER);
|
||||
if (currentStat == null) {
|
||||
currentStat = 0;
|
||||
}
|
||||
dataContainer.set(new NamespacedKey(plugin, stat), PersistentDataType.INTEGER, currentStat + amount);
|
||||
} else if (type == PersistentDataType.DOUBLE) {
|
||||
double currentStat = dataContainer.getOrDefault(new NamespacedKey(plugin, stat), PersistentDataType.DOUBLE, 0.0);
|
||||
Double currentStat = dataContainer.get(new NamespacedKey(plugin, stat), PersistentDataType.DOUBLE);
|
||||
if (currentStat == null) {
|
||||
currentStat = 0.0;
|
||||
}
|
||||
dataContainer.set(new NamespacedKey(plugin, stat), PersistentDataType.DOUBLE, currentStat + amount);
|
||||
} else if (type == PersistentDataType.LONG) {
|
||||
Long currentStat = dataContainer.get(new NamespacedKey(plugin, stat), PersistentDataType.LONG);
|
||||
if (currentStat == null) {
|
||||
currentStat = 0L;
|
||||
}
|
||||
dataContainer.set(new NamespacedKey(plugin, stat), PersistentDataType.LONG, currentStat + amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue