public void updateScoreboard() { List<String> second = Arrays.asList(toStringArray(getPartyMembers().toArray())); Iterator<String> players = getPartyMembers().iterator(); while (players.hasNext()) { String pn = players.next(); if (Bukkit.getPlayer(pn) == null) continue; Player p = Bukkit.getPlayer(pn); Objective o = ScoreboardMechanics.getBoard(p).getObjective(DisplaySlot.SIDEBAR); if (o == null) { o = ScoreboardMechanics.getBoard(p).registerNewObjective("player_data", "dummy"); o.setDisplayName(ChatColor.RED.toString() + ChatColor.BOLD.toString() + "Party"); o.setDisplaySlot(DisplaySlot.SIDEBAR); } for (String tn : second) { if (Bukkit.getPlayer(tn) == null) { ScoreboardMechanics.getBoard(p).resetScores(Bukkit.getOfflinePlayer(tn)); continue; } Player t = Bukkit.getPlayer(tn); String name = getPlayerName(t); if (name.length() > 16) name = name.substring(0, 16); o.getScore(Bukkit.getOfflinePlayer(name)) .setScore(HealthMechanics.getPlayerHP(t.getName())); } } }
private void resetNameTagsAuto() { Iterator<String> iter = safeTimes.keySet().iterator(); final Objective displaySafeTime = scoreboard.getBoard().getObjective("displaySafeTime"); while (iter.hasNext()) { String s = iter.next(); Player player = getServer().getPlayer(s); if (player == null) { OfflinePlayer p = getServer().getOfflinePlayer(s); clearFromBoard(p); iter.remove(); } else if (isSafe(s)) { iter.remove(); player.sendMessage("§cYou are now safe."); clearFromBoard(player); fixFlying(player); refresh(player); } else { if (safeTimeObjective) { long currTime = System.currentTimeMillis(); long safeTime = safeTimes.get(s); displaySafeTime.getScore(player).setScore((int) (safeTime / 1000 - currTime / 1000)); } } } }
@EventHandler public void onJoin(PlayerJoinEvent e) { Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); Objective objective = scoreboard.registerNewObjective("timers", "dummy"); objective.setDisplayName("§6Timers"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); e.getPlayer().setScoreboard(scoreboard); }
@SuppressWarnings("deprecation") public void updateScore(User user) { if (!Settings.getInstance().dummyEnable) return; Scoreboard scoreboard = this.user.getScoreboard(); Objective objective = scoreboard.getObjective(NAME); if (objective == null || !objective.getName().equals(NAME)) initialize(); else { OfflineUser offline = user.getOfflineUser(); objective.getScore(offline).setScore(user.getRank().getPoints()); } }
public void swapBuffer() { // Simply change the slot, the scoreboard will now // push all updating packets to the player // Thus wasting not a single ms on executing this at // a later time buffer.setDisplaySlot(o.getDisplaySlot()); buffer.setDisplayName(o.getDisplayName()); // Simply changing references for naming convenience t = o; o = buffer; buffer = t; }
public void scoreboard() { boardClass.setDisplaySlot(DisplaySlot.SIDEBAR); Score rank = boardClass.getScore(ChatColor.GREEN + "Rank:"); Score power = boardClass.getScore(ChatColor.GOLD + "Power:"); rank.setScore(userSkillClass.getRank()); power.setScore(userSkillClass.getPower()); Score[] score = new Score[userSkillClass.getSkillClass().getSkills().size()]; for (int i = 0; i < userSkillClass.getSkillClass().getSkills().size(); i++) { Skill skill = userSkillClass.getSkillClass().getSkills().get(i); score[i] = boardClass.getScore(ChatColor.GREEN + skill.getScoreboardName() + ":"); score[i].setScore(userSkillClass.getLevel(skill)); } player.setScoreboard(board); }
private void initialize() { if (!Settings.getInstance().dummyEnable) return; Scoreboard scoreboard = this.user.getScoreboard(); Objective objective = scoreboard.getObjective(NAME); if (objective == null || !objective.getName().equals(NAME)) { objective = scoreboard.registerNewObjective(NAME, "dummy"); objective.setDisplaySlot(DisplaySlot.BELOW_NAME); objective.setDisplayName(Settings.getInstance().dummySuffix); } for (Player player : Bukkit.getOnlinePlayers()) { User user = User.get(player); @SuppressWarnings("deprecation") Score score = objective.getScore(user.getOfflineUser()); score.setScore(user.getRank().getPoints()); } }
public static Scoreboard createMainScoreboard() { ScoreboardManager sm = plugin.getServer().getScoreboardManager(); Scoreboard sb = sm.getMainScoreboard(); if (sb.getObjective(DisplaySlot.SIDEBAR) != null) { return sb; } Objective main = sb.registerNewObjective("main", "dummy"); main.setDisplayName("§3MasterBuilders"); main.setDisplaySlot(DisplaySlot.SIDEBAR); main.getScore("§6Werbung").setScore(0); return sb; }
public Scoreboard Initialize(Player p) throws IllegalStateException, IllegalArgumentException { ScoreboardManager manager = Bukkit.getScoreboardManager(); Scoreboard board = manager.getNewScoreboard(); Objective objective = board.registerNewObjective("test", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName( ChatColor.GOLD + "" + ChatColor.BOLD + " _Esti" + ChatColor.DARK_AQUA + "" + ChatColor.BOLD + "Net_ "); Score score2 = objective.getScore(ChatColor.DARK_BLUE + "Online:"); // Get a fake offline player score2.setScore(4); Score score3 = objective.getScore( ChatColor.BOLD + "" + Integer.toString( Bukkit.getServer().getOnlinePlayers().size())); // Get a fake offline player score3.setScore(3); Score score = objective.getScore( ChatColor.AQUA + "Time before game starts:"); // Get a fake offline player score.setScore(2); Score score5 = objective.getScore( ChatColor.BOLD + "" + Basic.countdown + " "); // Get a fake offline player score5.setScore(1); return board; }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (sender instanceof Player) { Player player = (Player) sender; if (args.length > 0) { switch (args[0]) { case "join": player.teleport(plugin.getActiveArena().getTeleportLocation()); break; case "start": if (player.hasPermission("hexigames.admin")) { if (Objects.equals(plugin.getActiveArena(), plugin.getLobby())) { plugin.getLobby().startNextGame(); } } break; case "stop": if (player.hasPermission("hexigames.admin")) { plugin.returnToLobby(); } break; case "reload": if (player.hasPermission("hexigames.admin")) { plugin.reload(); } break; case "poo": Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); Objective objective = scoreboard.registerNewObjective("tester", "dummy"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); objective.setDisplayName("narnar"); player.setScoreboard(scoreboard); break; default: break; } } } return true; }
private void prepareScoreboard() { Objective objective = this.scoreboard.registerNewObjective("queue", "dummy"); objective.setDisplayName(FortressSiege.msgPrefix); objective.setDisplaySlot(DisplaySlot.SIDEBAR); Score players = objective.getScore("Spieler: "); players.setScore(0); Score timeleft = objective.getScore("Restzeit: "); timeleft.setScore(0); Objective score = this.scoreboard.registerNewObjective("score", "dummy"); score.setDisplaySlot(DisplaySlot.PLAYER_LIST); score.setDisplayName("Score"); }
public void scoreboard() { this.objective.setDisplayName(ChatColor.GOLD + "Objectives"); this.objective.setDisplaySlot(DisplaySlot.SIDEBAR); int score = 1; for (SporkTeam team : getTeams()) { if (hasModule(ScoredObjective.class)) { this.objective.setDisplayName(ChatColor.GOLD + "Score"); for (ObjectiveModule objective : team.getObjectives()) { if (objective.getClass() == ScoredObjective.class) { ScoredObjective scored = (ScoredObjective) objective; scored.setScore(1, 0); } } } else { if (score != 1) { String spaces = " "; String space = spaces; while (ScoreAPI.isSet(this.objective.getScore(space))) { spaces += " "; space = spaces; } this.objective.getScore(space).setScore(score + 1); this.objective.getScore(space).setScore(score); score++; } // Log.info(team.getName() + ": " + team.getObjectives().size() + " Objectives"); List<ObjectiveModule> objectives = team.getObjectives(); // Log.info(team.getName() + ": " + objectives); for (ObjectiveModule objective : objectives) { // Log.info("Setting score of " + ChatColor.stripColor(objective.getPlayer().getName()) + // " to " + score); // Log.info(ChatColor.stripColor(objective.getPlayer().getName()) + ": " + objective); if (objective.getPlayer() != null) { this.objective.getScore(objective.getPlayer()).setScore(score); score++; } } objective.getScore(team.getPlayer()).setScore(score); score++; } } }
public static void setGameScoreboard(int counter) { Objective layer = gameBoard.getObjective("game"); if (layer == null) { layer = gameBoard.registerNewObjective("game", "dummy"); } layer.setDisplaySlot(DisplaySlot.SIDEBAR); layer.setDisplayName( "§3MasterBuilders §8| §a§b" + String.format("%02d:%02d", counter / 60, counter % 60)); layer.getScore("§6------------").setScore(6); layer.getScore("§b ").setScore(5); layer.getScore("§6Thema:").setScore(4); layer.getScore("§a" + GameUtils.word).setScore(3); layer.getScore("§a ").setScore(2); layer.getScore("§c§6------------").setScore(1); for (Player p : Bukkit.getOnlinePlayers()) { p.setScoreboard(gameBoard); } }
public void addPlayer(Player player) { player.setScoreboard(this.scoreboard); Objective score = this.scoreboard.getObjective("score"); score.getScore(player.getName()).setScore(PlayerScore.getPlayer(player).getScore()); }
public void updateBoard() { for (Player p : playerBoards.keySet()) { if (p == null || !p.isOnline()) { return; } if (GameManager.seekers.contains(p.getName())) { Objective ob = playerBoards.get(p).getObjective("seekerboard"); if (ob == null) { ob = playerBoards.get(p).registerNewObjective("seekerboard", "dummy"); } Score score = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + plugin.ST.seeker_Translate + ":")); score.setScore(GameManager.seekers.size()); Score score1 = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.AQUA + plugin.ST.hider_Translate + ":")); score1.setScore(GameManager.hiders.size()); Score score2 = ob.getScore( Bukkit.getOfflinePlayer(ChatColor.WHITE + plugin.ST.time_Left_Translate + ":")); score2.setScore(GameManager.timeleft); } if (GameManager.hiders.contains(p.getName())) { Objective ob = playerBoards.get(p).getObjective("hiderboard"); if (ob == null) { ob = playerBoards.get(p).registerNewObjective("hiderboard", "dummy"); } if (PropHunt.dc.isDisguised(p)) { ob.setDisplayName( ChatColor.AQUA + DisguiseManager.parseDisguiseToName(PropHunt.dc.getDisguise(p))); } Score score = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + plugin.ST.seeker_Translate + ":")); score.setScore(GameManager.seekers.size()); Score score1 = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.AQUA + plugin.ST.hider_Translate + ":")); score1.setScore(GameManager.hiders.size()); Score score2 = ob.getScore( Bukkit.getOfflinePlayer(ChatColor.WHITE + plugin.ST.time_Left_Translate + ":")); score2.setScore(GameManager.timeleft); if (GameManager.usingSolidBlock) { Score score3 = ob.getScore( Bukkit.getOfflinePlayer( ChatColor.GREEN + "" + ChatColor.ITALIC + plugin.ST.solid_Time_Translate + ":")); if (SolidBlockTracker.solidBlocks.containsKey(p.getName())) { p.getScoreboard() .resetScores( Bukkit.getOfflinePlayer( ChatColor.GREEN + "" + ChatColor.ITALIC + plugin.ST.solid_Time_Translate + ":")); Score newscore = ob.getScore( Bukkit.getOfflinePlayer( ChatColor.GOLD + "" + ChatColor.BOLD + plugin.ST.solid_Translate + "")); newscore.setScore(1); } else { p.getScoreboard() .resetScores( Bukkit.getOfflinePlayer( ChatColor.GOLD + "" + ChatColor.BOLD + plugin.ST.solid_Translate + "")); score3.setScore( GameManager.solidBlockTime - SolidBlockTracker.movementTracker.get(p.getName())); } } } if (GameManager.playersWaiting.contains(p.getName())) { Objective ob = playerBoards.get(p).getObjective("lobbyboard"); if (ob == null) { ob = playerBoards.get(p).registerNewObjective("lobbyboard", "dummy"); } if (!GameManager.gameStatus) { Score scorey = ob.getScore( Bukkit.getOfflinePlayer(ChatColor.GREEN + plugin.ST.starting_In_Translate + "")); scorey.setScore(GameManager.currentLobbyTime); } else { p.getScoreboard() .resetScores( Bukkit.getOfflinePlayer(ChatColor.GREEN + plugin.ST.starting_In_Translate + "")); } Score score = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + plugin.ST.seeker_Translate + ":")); score.setScore(GameManager.seekers.size()); Score score1 = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.AQUA + plugin.ST.hider_Translate + ":")); score1.setScore(GameManager.hiders.size()); Score score2 = ob.getScore( Bukkit.getOfflinePlayer(ChatColor.WHITE + plugin.ST.time_Left_Translate + ":")); score2.setScore(GameManager.timeleft); Score score3 = ob.getScore( Bukkit.getOfflinePlayer(ChatColor.YELLOW + plugin.ST.player_Translate + ":")); score3.setScore(GameManager.playersWaiting.size()); Score score4 = ob.getScore( Bukkit.getOfflinePlayer(ChatColor.GRAY + plugin.ST.spectator_Translate + ":")); score4.setScore(GameManager.spectators.size()); } if (GameManager.spectators.contains(p.getName())) { Objective ob = playerBoards.get(p).getObjective("lobbyboard"); if (ob == null) { ob = playerBoards.get(p).registerNewObjective("lobbyboard", "dummy"); } Score score = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + plugin.ST.seeker_Translate + ":")); score.setScore(GameManager.seekers.size()); Score score1 = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.AQUA + plugin.ST.hider_Translate + ":")); score1.setScore(GameManager.hiders.size()); Score score2 = ob.getScore( Bukkit.getOfflinePlayer(ChatColor.WHITE + plugin.ST.time_Left_Translate + ":")); score2.setScore(GameManager.timeleft); Score score3 = ob.getScore( Bukkit.getOfflinePlayer(ChatColor.YELLOW + plugin.ST.player_Translate + ":")); score3.setScore(GameManager.playersWaiting.size()); Score score4 = ob.getScore( Bukkit.getOfflinePlayer(ChatColor.GRAY + plugin.ST.spectator_Translate + ":")); score4.setScore(GameManager.spectators.size()); } } }
public void addPlayerToGame(PropHunt plugin, Player p) { if (p == null || !p.isOnline()) { return; } if (GameManager.seekers.contains(p.getName())) { Scoreboard sb = plugin.getServer().getScoreboardManager().getNewScoreboard(); Objective ob = sb.registerNewObjective("seekerboard", "dummy"); ob.setDisplaySlot(DisplaySlot.SIDEBAR); ob.setDisplayName(ChatColor.GOLD + "PropHunt Stats"); Score score = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + plugin.ST.seeker_Translate + ":")); score.setScore(GameManager.seekers.size()); Score score1 = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.AQUA + plugin.ST.hider_Translate + ":")); score1.setScore(GameManager.hiders.size()); Score score2 = ob.getScore( Bukkit.getOfflinePlayer(ChatColor.WHITE + plugin.ST.time_Left_Translate + ":")); score2.setScore(GameManager.timeleft); p.setScoreboard(sb); playerBoards.put(p, sb); } if (GameManager.hiders.contains(p.getName())) { Scoreboard sb = plugin.getServer().getScoreboardManager().getNewScoreboard(); Objective ob = sb.registerNewObjective("hiderboard", "dummy"); ob.setDisplaySlot(DisplaySlot.SIDEBAR); ob.setDisplayName( ChatColor.AQUA + DisguiseManager.parseDisguiseToName(PropHunt.dc.getDisguise(p))); Score score = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + plugin.ST.seeker_Translate + ":")); score.setScore(GameManager.seekers.size()); Score score1 = ob.getScore(Bukkit.getOfflinePlayer(ChatColor.AQUA + plugin.ST.hider_Translate + ":")); score1.setScore(GameManager.hiders.size()); Score score2 = ob.getScore( Bukkit.getOfflinePlayer(ChatColor.WHITE + plugin.ST.time_Left_Translate + ":")); score2.setScore(GameManager.timeleft); p.setScoreboard(sb); playerBoards.put(p, sb); } }
public void updateTimeleft() { Objective objective = this.scoreboard.getObjective("queue"); Score timeleft = objective.getScore("Restzeit: "); timeleft.setScore(FortressSiege.queueTask.getRemaining()); }
public void updatePlayers() { Objective objective = this.scoreboard.getObjective("queue"); Score timeleft = objective.getScore("Spieler: "); timeleft.setScore(FortressSiege.gameHandler.queueList.size()); }
@Override public void cleanup() { super.cleanup(); o.unregister(); t.unregister(); }
public void removePlayer(Player p) { for (String tn : getPartyMembers()) { if (Bukkit.getPlayer(tn) == null) { continue; } Player t = Bukkit.getPlayer(tn); String name = getPlayerName(p); if (name.length() > 16) name = name.substring(0, 16); ScoreboardMechanics.getBoard(t).resetScores(Bukkit.getOfflinePlayer(name)); } Objective o = ScoreboardMechanics.getBoard(p).getObjective(DisplaySlot.SIDEBAR); if (o != null) o.unregister(); players.remove(p.getName()); PartyMechanics.party_map.remove(p.getName()); PartyMechanics.party_only.remove(p.getName()); KarmaMechanics.sendAlignColor(p, p); if (ScoreboardMechanics.getBoard(p) != null && ScoreboardMechanics.getBoard(p).getObjective(DisplaySlot.SIDEBAR) != null) { ScoreboardMechanics.getBoard(p).getObjective(DisplaySlot.SIDEBAR).unregister(); } InstanceMechanics.teleport_on_load.remove(p.getName()); if (InstanceMechanics.saved_location_instance.containsKey(p.getName())) { // Inside an instance. p.teleport(InstanceMechanics.saved_location_instance.get(p.getName())); InstanceMechanics.saved_location_instance.remove(p.getName()); } InstanceMechanics.removeFromInstanceParty(p.getName()); if (p.getName().equalsIgnoreCase(leader.getName()) && getPartyMembers().size() > 0) { String new_leader = ""; int size_mod = 1; if (getPartyMembers().size() <= 1) { size_mod = 0; } int party_index = new Random().nextInt(getPartyMembers().size() - size_mod); List<String> remaining_members = new ArrayList<String>(); for (String s : getPartyMembers()) { if (s.equalsIgnoreCase(p.getName())) { continue; } remaining_members.add(s); } leader = Bukkit.getPlayer(remaining_members.get(party_index)); for (String x : getPartyMembers()) { if (Bukkit.getPlayer(x) == null) continue; ScoreboardMechanics.getBoard(Bukkit.getPlayer(x)).resetScores(leader); } // TODO MOVES THIS for (String s : remaining_members) { if (Bukkit.getPlayer(s) != null) { Player pty_mem = Bukkit.getPlayer(s); if (!(pty_mem.getScoreboard().getPlayers().contains(Bukkit.getOfflinePlayer(s)))) { pty_mem.setScoreboard(Bukkit.getPlayer(s).getScoreboard()); } /* * if(!new_ui.hasPlayerAdded(pty_mem)){ * new_ui.showToPlayer(pty_mem); } */ pty_mem.sendMessage( ChatColor.LIGHT_PURPLE.toString() + "<" + ChatColor.BOLD + "P" + ChatColor.LIGHT_PURPLE + ">" + ChatColor.GRAY + " " + p.getName() + ChatColor.GRAY.toString() + " has " + ChatColor.LIGHT_PURPLE + ChatColor.UNDERLINE + "left" + ChatColor.GRAY.toString() + " your party."); pty_mem.sendMessage( ChatColor.LIGHT_PURPLE.toString() + "<" + ChatColor.BOLD + "P" + ChatColor.LIGHT_PURPLE + "> " + ChatColor.GRAY + ChatColor.LIGHT_PURPLE.toString() + new_leader + ChatColor.GRAY.toString() + " has been promoted to " + ChatColor.UNDERLINE + "Party Leader"); } } } else { for (String s : getPartyMembers()) { if (Bukkit.getPlayer(s) != null && s != p.getName()) { Player pty_mem = Bukkit.getPlayer(s); pty_mem.sendMessage( ChatColor.LIGHT_PURPLE.toString() + "<" + ChatColor.BOLD + "P" + ChatColor.LIGHT_PURPLE + ">" + ChatColor.GRAY + " " + p.getName() + ChatColor.GRAY.toString() + " has " + ChatColor.RED + ChatColor.UNDERLINE + "left" + ChatColor.GRAY.toString() + " your party."); } } } if (!Hive.pending_upload.contains(p.getName())) { HealthMechanics.setOverheadHP(p, HealthMechanics.getPlayerHP(p.getName())); } }
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onDamage(EntityDamageByEntityEvent e) { if (e.isCancelled()) { System.out.println("Event is cancelled. Ignoring..."); return; } if (e.getEntity() instanceof Player && e.getDamager() instanceof Player) { final Player damaged = (Player) e.getEntity(); final Player damager = (Player) e.getDamager(); if (!inCombat.containsKey(damaged.getName())) { damaged.sendMessage(ChatColor.RED + "You are now in combat!"); final Scoreboard scoreboard = damaged.getScoreboard(); Objective objective = scoreboard.getObjective("timers") == null ? scoreboard.registerNewObjective("timers", "dummy") : scoreboard.getObjective("timers"); objective.setDisplayName("§6Timers"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); final Score combatTag = objective.getScore("§aCombat Tag"); combatTag.setScore(60); // damaged.setScoreboard(scoreboard); inCombatTag.put( damaged.getName(), new BukkitRunnable() { @Override public void run() { if (inCombat.get(damaged.getName()) != null) { if (inCombat.get(damaged.getName()) > 0) { inCombat.put(damaged.getName(), inCombat.get(damaged.getName()) - 1); combatTag.setScore(inCombat.get(damaged.getName())); } else { inCombat.remove(damaged.getName()); damaged.sendMessage(ChatColor.GREEN + "You are no longer in combat."); scoreboard.resetScores("§aCombat Tag"); this.cancel(); inCombatTag.remove(damager.getName()); } } } }); inCombatTag .get(damaged.getName()) .runTaskTimerAsynchronously(Hardcore.getPlugin(Hardcore.class), 20L, 20L); } if (!inCombat.containsKey(damager.getName())) { damager.sendMessage(ChatColor.RED + "You are now in combat!"); final Scoreboard scoreboard2 = damager.getScoreboard(); Objective objective2 = scoreboard2.getObjective("timers") == null ? scoreboard2.registerNewObjective("timers", "dummy") : scoreboard2.getObjective("timers"); objective2.setDisplayName("§6Timers"); objective2.setDisplaySlot(DisplaySlot.SIDEBAR); final Score combatTag2 = objective2.getScore("§aCombat Tag"); combatTag2.setScore(60); // damager.setScoreboard(scoreboard2); inCombatTag.put( damager.getName(), new BukkitRunnable() { @Override public void run() { if (inCombat.get(damager.getName()) != null) { if (inCombat.get(damager.getName()) > 0) { inCombat.put(damager.getName(), inCombat.get(damager.getName()) - 1); combatTag2.setScore(inCombat.get(damager.getName())); } else { inCombat.remove(damager.getName()); damager.sendMessage(ChatColor.GREEN + "You are no longer in combat."); scoreboard2.resetScores("§aCombat Tag"); this.cancel(); inCombatTag.remove(damager.getName()); } } } }); inCombatTag .get(damager.getName()) .runTaskTimerAsynchronously(Hardcore.getPlugin(Hardcore.class), 20L, 20L); } inCombat.put(damaged.getName(), 60); inCombat.put(damager.getName(), 60); } if (e.getEntity() instanceof Player && e.getDamager() instanceof Projectile) { final Player damaged = (Player) e.getEntity(); Projectile projectile = (Projectile) e.getDamager(); if (projectile.getShooter() instanceof Player) { final Player damager = (Player) projectile.getShooter(); if (damager.equals(damaged)) { return; } if (!inCombat.containsKey(damaged.getName())) { damaged.sendMessage(ChatColor.RED + "You are now in combat!"); final Scoreboard scoreboard = damaged.getScoreboard(); Objective objective = scoreboard.getObjective("ct") == null ? scoreboard.registerNewObjective("ct", "dummy") : scoreboard.getObjective("ct"); objective.setDisplayName("§6Timers"); objective.setDisplaySlot(DisplaySlot.SIDEBAR); final Score combatTag = objective.getScore("§aCombat Tag"); combatTag.setScore(60); // damaged.setScoreboard(scoreboard); inCombatTag.put( damaged.getName(), new BukkitRunnable() { @Override public void run() { if (inCombat.get(damaged.getName()) != null) { if (inCombat.get(damaged.getName()) > 0) { inCombat.put(damaged.getName(), inCombat.get(damaged.getName()) - 1); combatTag.setScore(inCombat.get(damaged.getName())); } else { inCombat.remove(damaged.getName()); damaged.sendMessage(ChatColor.GREEN + "You are no longer in combat."); scoreboard.resetScores("§aCombat Tag"); this.cancel(); inCombatTag.remove(damager.getName()); } } } }); inCombatTag .get(damaged.getName()) .runTaskTimerAsynchronously(Hardcore.getPlugin(Hardcore.class), 20L, 20L); } if (!inCombat.containsKey(damager.getName())) { damager.sendMessage(ChatColor.RED + "You are now in combat!"); final Scoreboard scoreboard2 = damager.getScoreboard(); Objective objective2 = scoreboard2.getObjective("ct") == null ? scoreboard2.registerNewObjective("ct", "dummy") : scoreboard2.getObjective("ct"); objective2.setDisplayName("§6Timers"); objective2.setDisplaySlot(DisplaySlot.SIDEBAR); final Score combatTag2 = objective2.getScore("§aCombat Tag"); combatTag2.setScore(60); // damager.setScoreboard(scoreboard2); inCombatTag.put( damager.getName(), new BukkitRunnable() { @Override public void run() { if (inCombat.get(damager.getName()) != null) { if (inCombat.get(damager.getName()) > 0) { inCombat.put(damager.getName(), inCombat.get(damager.getName()) - 1); combatTag2.setScore(inCombat.get(damager.getName())); } else { inCombat.remove(damager.getName()); damager.sendMessage(ChatColor.GREEN + "You are no longer in combat."); scoreboard2.resetScores("§aCombat Tag"); this.cancel(); inCombatTag.remove(damager.getName()); } } } }); inCombatTag .get(damager.getName()) .runTaskTimerAsynchronously(Hardcore.getPlugin(Hardcore.class), 20L, 20L); } inCombat.put(damaged.getName(), 60); inCombat.put(damager.getName(), 60); } } }
public void addTo(Objective obj) { obj.getScore(name).setScore(score); }