TCheckpoint
This commit is contained in:
parent
00faf1f2fd
commit
e8a4c9f75b
10 changed files with 10 additions and 8 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -15,8 +15,7 @@ public class SellItem implements CommandExecutor {
|
|||
market.sell(((Player) sender).getInventory().getItemInMainHand(), (Player) sender);
|
||||
ServerStats.getServerStats().setStat("market", market);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sender.sendMessage("This command can only be run by a player.");
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,10 @@ import org.gsdistance.grimmsServer.Stats.WorldStats;
|
|||
public class BlockBreakEvent {
|
||||
public static void Event(org.bukkit.event.block.BlockBreakEvent event) {
|
||||
if (event.getPlayer().getType() == org.bukkit.entity.EntityType.PLAYER) {
|
||||
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);
|
||||
PlayerStats.getPlayerStats(event.getPlayer()).changeStat("money", 1);
|
||||
PlayerStats.getPlayerStats(event.getPlayer()).changeStat("tPoint", 3);
|
||||
}
|
||||
// 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);
|
||||
WorldStats.getWorldStats(event.getBlock().getWorld()).changeStat("block_break_count", 1);
|
||||
WorldStats.getWorldStats(event.getBlock().getWorld()).changeStat("wPoint", 3);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,15 +47,20 @@ public class ServerStats {
|
|||
private void loadStats() {
|
||||
if (!statsFile.exists()) {
|
||||
stats = new Hashtable<>();
|
||||
stats.put("market", new Market()); // Initialize market stat
|
||||
saveStats();
|
||||
return;
|
||||
}
|
||||
try (FileReader reader = new FileReader(statsFile)) {
|
||||
Type type = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
stats = new Gson().fromJson(reader, type);
|
||||
if (!stats.containsKey("market")) {
|
||||
stats.put("market", new Market()); // Ensure market stat is initialized
|
||||
}
|
||||
} catch (IOException e) {
|
||||
GrimmsServer.logger.log(Level.WARNING, "Failed to load server stats.\n" + Arrays.toString(e.getStackTrace()));
|
||||
stats = new Hashtable<>();
|
||||
stats.put("market", new Market()); // Initialize market stat
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue