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");
  }
Example #2
0
  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 static void setVotingScoreboard(int counter) {

    Objective layer = votingBoard.getObjective("voting");
    if (layer == null) {
      layer = votingBoard.registerNewObjective("voting", "dummy");
    }
    layer.setDisplaySlot(DisplaySlot.SIDEBAR);
    layer.setDisplayName(
        "§3MasterBuilders §8| §a" + String.format("%02d:%02d", counter / 60, counter % 60));

    layer.getScore("§6--------------").setScore(9);

    layer.getScore("§c ").setScore(8);

    layer.getScore("§6Thema:").setScore(7);
    layer.getScore("§a" + GameUtils.word).setScore(6);

    layer.getScore("§b ").setScore(5);

    layer.getScore("§6Erbauer:").setScore(4);
    layer.getScore("§a*****").setScore(3);

    layer.getScore("§a ").setScore(2);

    layer.getScore("§c§6--------------").setScore(1);

    for (Player p : Bukkit.getOnlinePlayers()) {
      p.setScoreboard(votingBoard);
    }
  }
Example #4
0
 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;
 }
Example #5
0
 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()));
     }
   }
 }
Example #6
0
  @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);
  }
Example #7
0
 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;
 }
Example #8
0
 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;
  }
 @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;
 }
Example #11
0
  @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);
      }
    }
  }
Example #12
0
  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());
      }
    }
  }