コード例 #1
0
ファイル: XScoreboard.java プロジェクト: Shawckz/iPractice
 public void updateLabel(XLabel label) {
   resetScores(label);
   if (label.isVisible()) {
     if (label.getValue().equals("")) {
       return;
     }
     if (label.getValue().equals("§a ")) {
       // Is a spacer label, no need to make a team and shit for it as teams
       // don't seem to like the name only being a space and color
       scoreboard
           .getObjective(DisplaySlot.SIDEBAR)
           .getScore(label.getValue())
           .setScore(label.getScore());
     } else {
       int split = Math.round(label.getValue().length() / 2);
       final String key = label.getValue().substring(0, split);
       if (key.equals("")) {
         return;
       }
       final String value = label.getValue().substring(split, label.getValue().length());
       scoreboard.getObjective(DisplaySlot.SIDEBAR).getScore(key).setScore(label.getScore());
       if (scoreboard.getEntries().toArray().length != 0) {
         Team team = this.scoreboard.getTeam(key);
         if (team == null) {
           team = this.scoreboard.registerNewTeam(key);
           team.addPlayer(new FakeOfflinePlayer(key));
         }
         team.setSuffix(value);
       }
     }
   }
   scores.put(label.getScore(), label);
   label.setUpdated(true);
 }
コード例 #2
0
ファイル: User.java プロジェクト: cblacks26/McClasses
 public void switchClass(SkillClass skillClass) {
   DatabaseUtil.saveClass(id, getUserSkillClass());
   setUserSkillClass(DatabaseUtil.loadUserClass(id, skillClass));
   if (board.getObjective(ChatColor.AQUA + userSkillClass.getSkillClass().getName()) != null) {
     boardClass = board.getObjective(ChatColor.AQUA + userSkillClass.getSkillClass().getName());
   } else {
     boardClass =
         board.registerNewObjective(
             ChatColor.AQUA + userSkillClass.getSkillClass().getName(), "dummy");
   }
   scoreboard();
 }
コード例 #3
0
  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);
    }
  }
コード例 #4
0
ファイル: Dummy.java プロジェクト: SzesciennyGlob/FunnyGuilds
 @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());
   }
 }
コード例 #5
0
  public static boolean rankedSidebarDisplay(
      Collection<Player> players,
      String title,
      HashMap<String, Integer> elements,
      Scoreboard board) {
    try {
      title = cutRankedTitle(title);
      elements = cutRanked(elements);

      String objName = "COLLAB-SB-WINTER";

      if (board == null) board = Bukkit.getScoreboardManager().getNewScoreboard();

      for (Player player : players)
        if (player.getScoreboard() != board) player.setScoreboard(board);

      if (board.getObjective(objName) == null) {
        board.registerNewObjective(objName, "dummy");
        board.getObjective(objName).setDisplaySlot(DisplaySlot.SIDEBAR);
      }

      board.getObjective(DisplaySlot.SIDEBAR).setDisplayName(title);

      for (String string : elements.keySet())
        if (board.getObjective(DisplaySlot.SIDEBAR).getScore(string).getScore()
            != elements.get(string))
          board.getObjective(DisplaySlot.SIDEBAR).getScore(string).setScore(elements.get(string));

      for (String string : new ArrayList<>(board.getEntries()))
        if (!elements.keySet().contains(string)) board.resetScores(string);

      return true;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  }
コード例 #6
0
ファイル: Dummy.java プロジェクト: SzesciennyGlob/FunnyGuilds
 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());
   }
 }
コード例 #7
0
  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;
  }
コード例 #8
0
  public static boolean unrankedSidebarDisplay(
      Collection<Player> players, String[] elements, Scoreboard board) {
    try {
      String objName = "COLLAB-SB-WINTER";

      if (board == null) board = Bukkit.getScoreboardManager().getNewScoreboard();

      elements = cutUnranked(elements);

      for (Player player : players)
        if (player.getScoreboard() != board) player.setScoreboard(board);

      if (board.getObjective(objName) == null) {
        board.registerNewObjective(objName, "dummy");
        board.getObjective(objName).setDisplaySlot(DisplaySlot.SIDEBAR);
      }

      board.getObjective(DisplaySlot.SIDEBAR).setDisplayName(elements[0]);

      for (int i = 1; i < elements.length; i++)
        if (elements[i] != null
            && board.getObjective(DisplaySlot.SIDEBAR).getScore(elements[i]).getScore() != 16 - i) {
          board.getObjective(DisplaySlot.SIDEBAR).getScore(elements[i]).setScore(16 - i);
          for (String string : board.getEntries())
            if (board.getObjective(objName).getScore(string).getScore() == 16 - i)
              if (!string.equals(elements[i])) board.resetScores(string);
        }

      for (String entry : board.getEntries()) {
        boolean toErase = true;
        for (String element : elements) {
          if (element != null
              && element.equals(entry)
              && board.getObjective(objName).getScore(entry).getScore()
                  == 16 - Arrays.asList(elements).indexOf(element)) {
            toErase = false;
            break;
          }
        }

        if (toErase) board.resetScores(entry);
      }

      return true;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  }
コード例 #9
0
ファイル: CombatTag.java プロジェクト: CodeMyAss/Hardcore-2.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);
      }
    }
  }
コード例 #10
0
 public static void updateGameScoreboard(int counter) {
   gameBoard
       .getObjective(DisplaySlot.SIDEBAR)
       .setDisplayName(
           "§3MasterBuilders §8| §a" + String.format("%02d:%02d", counter / 60, counter % 60));
 }
コード例 #11
0
 public static void hideBuilderVotingScoreboard(String exBuilder) {
   votingBoard.resetScores("§a" + exBuilder);
   votingBoard.getObjective(DisplaySlot.SIDEBAR).getScore("§a*****").setScore(3);
 }
コード例 #12
0
ファイル: XScoreboard.java プロジェクト: Shawckz/iPractice
 public void updateTitle() {
   if (!this.title.equalsIgnoreCase(
       scoreboard.getObjective(DisplaySlot.SIDEBAR).getDisplayName())) {
     scoreboard.getObjective(DisplaySlot.SIDEBAR).setDisplayName(title);
   }
 }