TCheckpoint
This commit is contained in:
parent
aa415c443e
commit
00faf1f2fd
16 changed files with 38 additions and 7 deletions
|
|
@ -7,5 +7,7 @@ public class CommandRegistry {
|
|||
// Register all commands here
|
||||
GrimmsServer.instance.getCommand("logselfstats").setExecutor(new LogSelfStatsCommand());
|
||||
GrimmsServer.instance.getCommand("logworldstats").setExecutor(new LogWorldStats());
|
||||
GrimmsServer.instance.getCommand("getMarketValue").setExecutor(new GetItemStockValue());
|
||||
GrimmsServer.instance.getCommand("sellItem").setExecutor(new SellItem());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ public class BlockBreakEvent {
|
|||
PlayerStats.getPlayerStats(event.getPlayer()).setStat("money", (double) PlayerStats.getPlayerStats(event.getPlayer()).getStat("money") + 0.5D);
|
||||
PlayerStats.getPlayerStats(event.getPlayer()).setStat("tPoint", (double) PlayerStats.getPlayerStats(event.getPlayer()).getStat("tPoint") + 1D);
|
||||
}
|
||||
WorldStats.getWorldStats(event.getBlock().getWorld()).setStat("block_break_count", (long) WorldStats.getWorldStats(event.getBlock().getWorld()).getStat("block_break_count") + 1L);
|
||||
// Correctly handle block_break_count as Long
|
||||
Long blockBreakCount = (Long) WorldStats.getWorldStats(event.getBlock().getWorld()).getStat("block_break_count");
|
||||
WorldStats.getWorldStats(event.getBlock().getWorld()).setStat("block_break_count", blockBreakCount + 1L);
|
||||
WorldStats.getWorldStats(event.getBlock().getWorld()).setStat("wPoint", (double) WorldStats.getWorldStats(event.getBlock().getWorld()).getStat("wPoint") + 3.0D);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ public class EventTrigger implements Listener {
|
|||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
org.gsdistance.grimmsServer.Events.EntityDeathEvent.Event(event);
|
||||
}
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
org.gsdistance.grimmsServer.Events.BlockBreakEvent.Event(event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,3 +19,7 @@ commands:
|
|||
description: Sells the main hand for a certain amount of money.
|
||||
usage: /sellItem
|
||||
permission: grimmsserver.sellItem
|
||||
buyItem:
|
||||
description: Buys an item for a certain amount of money.
|
||||
usage: /buyItem <item> <amount>
|
||||
permission: grimmsserver.buyItem
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue