health bar kinda bugged now and money sidebar better

This commit is contained in:
NK 2022-12-03 17:37:30 +00:00
parent d4d4ef75e0
commit f8d85374c9
3 changed files with 6 additions and 7 deletions

View file

@ -21,13 +21,13 @@ public class UserDataManager {
Bson updated = new Document("Bank", coins + coinsBefore); Bson updated = new Document("Bank", coins + coinsBefore);
Bson update = new Document("$set", updated); Bson update = new Document("$set", updated);
DatabaseManager.getUsersDB().updateOne(document, update); DatabaseManager.getUsersDB().updateOne(document, update);
ScoreboardListener.sideBarManager.addBank(uuid); ScoreboardListener.sideBarManager.addBank(uuid, coins);
} else { } else {
Document doc = new Document(); Document doc = new Document();
doc.put("UUID", uuid); doc.put("UUID", uuid);
doc.put("Bank", coins); doc.put("Bank", coins);
DatabaseManager.getUsersDB().insertOne(doc); DatabaseManager.getUsersDB().insertOne(doc);
ScoreboardListener.sideBarManager.addBank(uuid); ScoreboardListener.sideBarManager.addBank(uuid, coins);
} }

View file

@ -10,9 +10,9 @@ import org.bukkit.scoreboard.Scoreboard;
public class BelowNameManager { public class BelowNameManager {
public void setBelowName(Player player) { public void setBelowName(Player player) {
Scoreboard board = player.getScoreboard(); Scoreboard board = player.getScoreboard();
Objective obj = board.registerNewObjective("HealthBar", Criteria.HEALTH, ChatColor.RED + ""); Objective obj = board.registerNewObjective("HealthBar", Criteria.DUMMY, ChatColor.RED.toString());
obj.setDisplaySlot(DisplaySlot.BELOW_NAME); obj.setDisplaySlot(DisplaySlot.BELOW_NAME);
obj.setDisplayName(ChatColor.RED.toString() + player.getHealth() + "");
player.setScoreboard(board); player.setScoreboard(board);
player.setHealth(player.getHealth());
} }
} }

View file

@ -95,9 +95,8 @@ public class SideBarManager {
}, 0, 10); }, 0, 10);
} }
public void addBank(String uuid) { public void addBank(String uuid, Integer amount) {
UUID uid = UUID.fromString(uuid); UUID uid = UUID.fromString(uuid);
Bukkit.getPlayer(uid).getScoreboard().getTeam("Bank").setSuffix(ChatColor.YELLOW.toString() + UserDataManager.getUser(uuid).get("Bank")); Bukkit.getPlayer(uid).getScoreboard().getTeam("Bank").setSuffix(ChatColor.YELLOW.toString() + UserDataManager.getUser(uuid).get("Bank") + ChatColor.WHITE + "+(" + amount + ")");
} }
} }