@Override public void set(String player, double amount) { map.put(player, amount); if (objective != null) { objective.getScore(PlayerNameUtils.getOfflinePlayer(player)).setScore((int) amount); } }
@EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); for (String name : invisibles.keySet()) { Player p = PlayerNameUtils.getPlayerExact(name); if (p != null && !name.equals(player.getName())) { player.hidePlayer(p); } } if (invisibles.containsKey(player.getName())) { for (Player p : Bukkit.getOnlinePlayers()) { p.hidePlayer(player); } } }
@Override public boolean modify(String player, double amount) { double value = getValue(player); double newvalue = value + amount; if (newvalue > maxValue) { newvalue = maxValue; } else if (newvalue < minValue) { newvalue = minValue; } if (value != newvalue) { map.put(player, newvalue); if (objective != null) { objective.getScore(PlayerNameUtils.getOfflinePlayer(player)).setScore((int) newvalue); } return true; } else { return false; } }