Exemple #1
0
 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);
 }
 public void addGuild(Guild to) {
   if (to == null) return;
   Scoreboard scoreboard = getUser().getScoreboard();
   Guild guild = getUser().getGuild();
   if (guild != null) {
     if (guild.equals(to)) {
       initialize();
       return;
     }
     Team team = scoreboard.getTeam(to.getTag());
     if (team == null) team = scoreboard.registerNewTeam(to.getTag());
     for (User u : to.getMembers()) {
       OfflineUser player = new OfflineUser(u.getName());
       if (!team.hasPlayer(player)) team.addPlayer(player);
     }
     String prefix = Settings.getInstance().prefixOther;
     if (guild.getAllies().contains(to)) prefix = Settings.getInstance().prefixAllies;
     if (guild.getEnemies().contains(to)) prefix = Settings.getInstance().prefixEnemies;
     prefix = prefix.replace("{TAG}", to.getTag());
     if (prefix.length() > 16) prefix = prefix.substring(0, 16);
     team.setPrefix(prefix);
   } else {
     Team team = scoreboard.getTeam(to.getTag());
     if (team == null) team = scoreboard.registerNewTeam(to.getTag());
     for (User u : to.getMembers()) {
       OfflineUser player = new OfflineUser(u.getName());
       if (!team.hasPlayer(player)) team.addPlayer(player);
     }
     team.setPrefix(replace(Settings.getInstance().prefixOther, "{TAG}", to.getTag()));
   }
 }
  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);
    }
  }
Exemple #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;
 }
  @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());
   }
 }
Exemple #7
0
 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();
 }
Exemple #8
0
 @Override
 public void display0() {
   Scoreboard board = getPlayer().getEntity().getScoreboard();
   if (board == null) {
     board = Bukkit.getScoreboardManager().getNewScoreboard();
     getPlayer().getEntity().setScoreboard(board);
   }
   if (o == null) {
     this.o = board.registerNewObjective(getPlayer().getPlugin().getName() + "-primary", "dummy");
     this.buffer =
         board.registerNewObjective(getPlayer().getPlugin().getName() + "-buffer", "dummy");
   }
   this.o.setDisplaySlot(DisplaySlot.SIDEBAR);
 }
Exemple #9
0
 private void resetScores(XLabel label) {
   for (XRemoveLabel remove : label.getToRemove()) {
     scoreboard.resetScores(remove.getLastValue());
     scoreboard.resetScores(remove.getValue());
     if (remove.getLastValue() != null
         && remove.getValue().length() > remove.getLastValue().length()) {
       int split = Math.round(remove.getValue().length() / 2) - 1;
       final String key = remove.getValue().substring(0, split);
       final String value = remove.getValue().substring(split, remove.getValue().length());
       scoreboard.resetScores(key);
       scoreboard.resetScores(value);
     } else if (remove.getLastValue() != null
         && remove.getValue().length() < remove.getLastValue().length()) {
       int split = Math.round(remove.getValue().length() / 2) + 1;
       final String key = remove.getValue().substring(0, split);
       final String value = remove.getValue().substring(split, remove.getValue().length());
       scoreboard.resetScores(key);
       scoreboard.resetScores(value);
     } else {
       int split = Math.round(remove.getValue().length() / 2);
       final String key = remove.getValue().substring(0, split);
       final String value = remove.getValue().substring(split, remove.getValue().length());
       scoreboard.resetScores(key);
       scoreboard.resetScores(value);
     }
   }
   label.getToRemove().clear();
 }
Exemple #10
0
 public void removeLabel(XLabel label) {
   resetScores(label);
   if (scores.containsKey(label.getScore())) {
     scores.remove(label.getScore());
   }
   int split = Math.round(label.getValue().length() / 2);
   final String key = label.getValue().substring(0, split);
   final String value = label.getValue().substring(split, label.getValue().length());
   scoreboard.resetScores(key);
   scoreboard.resetScores(value);
   Team team = scoreboard.getTeam(key);
   if (team != null) {
     team.unregister();
   }
 }
Exemple #11
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 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;
  }
Exemple #13
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());
   }
 }
 private void uncolorPlayer(Player player) {
   Team team = scoreboard.getTeam(player.getName());
   if (team != null) {
     team.unregister();
   }
   player.setDisplayName(player.getName());
 }
Exemple #15
0
 public User(UUID id) {
   this.player = Bukkit.getPlayer(id);
   this.id = id;
   loadData();
   boardClass =
       board.registerNewObjective(
           ChatColor.AQUA + userSkillClass.getSkillClass().getName(), "dummy");
 }
 protected void addPlayer(OfflinePlayer player) {
   if (player == null) return;
   User user = User.get(player);
   if (!user.hasGuild()) return;
   Scoreboard scoreboard = this.getUser().getScoreboard();
   Team team = scoreboard.getPlayerTeam(player);
   if (team != null) team.removePlayer(player);
   team = scoreboard.getTeam(user.getGuild().getTag());
   if (team == null) {
     addGuild(user.getGuild());
     team = scoreboard.getTeam(user.getGuild().getTag());
   }
   if (this.getUser().hasGuild())
     if (this.getUser().equals(user) || this.getUser().getGuild().getMembers().contains(user))
       team.setPrefix(
           replace(Settings.getInstance().prefixOur, "{TAG}", user.getGuild().getTag()));
   team.addPlayer(player);
 }
Exemple #17
0
 public void updateTab(Player p) {
   p.setScoreboard(this.scoreboard);
   for (String configstring : assignedTeams.keySet()) {
     if (p.hasPermission("rank.assign." + configstring)) {
       String toStringTeam = assignedTeams.get(configstring);
       Team team =
           scoreboard.getTeam("player" + getConfig().getString("rank." + toStringTeam + ".order"));
       team.addPlayer(p.getPlayer());
       break;
     }
   }
 }
Exemple #18
0
 public void cutConfig() {
   blacklistedworlds.clear();
   this.whileloop = false;
   for (Team t : scoreboard.getTeams()) {
     for (OfflinePlayer p : t.getPlayers()) {
       t.removePlayer(p);
     }
     t.unregister();
   }
   Bukkit.getScheduler().cancelAllTasks();
   scoreboard = null;
 }
 @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;
 }
Exemple #20
0
  @EventHandler
  public void onPlayerJoin(PlayerJoinEvent e) {
    FileConfiguration locationsFile =
        YamlConfiguration.loadConfiguration(Main.getInstance().locations);

    Player p = e.getPlayer();
    SPlayer player = new SPlayer(p);

    int blue = Team.BLUE.getPlayers().size();
    int red = Team.RED.getPlayers().size();

    p.teleport(locationUtil.deserializeLoc(locationsFile.getString("arena.lobby")));
    gameManager.setCarrying(p, 0);

    Scoreboard sb = Bukkit.getScoreboardManager().getNewScoreboard();
    org.bukkit.scoreboard.Team r = sb.registerNewTeam("red");
    r.setPrefix(Color.np("&c"));
    org.bukkit.scoreboard.Team b = sb.registerNewTeam("blue");
    b.setPrefix(Color.np("&b"));
    for (Player online : Bukkit.getOnlinePlayers()) {
      Team team = teamManager.getTeam(online);
      if (team == Team.BLUE) {
        b.addEntry(online.getName());
      } else {
        r.addEntry(online.getName());
      }
    }

    p.setScoreboard(sb);

    e.setJoinMessage(null);

    if (blue <= red) {
      player.setTeam(Team.BLUE);
    } else {
      player.setTeam(Team.RED);
    }
  }
  private void colorPlayer(Player player, ChatColor color) {
    uncolorPlayer(player);

    playerColors.put(player.getUniqueId(), color);

    player.setDisplayName(color + player.getName() + ChatColor.RESET);

    Team team = scoreboard.registerNewTeam(player.getName());
    team.setDisplayName(player.getName());
    team.setPrefix(color.toString());
    team.setSuffix(ChatColor.RESET.toString());
    team.addEntry(player.getName());
    player.setScoreboard(scoreboard);
  }
 private void initialize() {
   if (getUser() == null) return;
   List<Guild> guilds = GuildUtils.getGuilds();
   Scoreboard scoreboard = getUser().getScoreboard();
   Guild guild = getUser().getGuild();
   if (guild != null) {
     guilds.remove(guild);
     Settings config = Settings.getInstance();
     String our = config.prefixOur;
     String ally = config.prefixAllies;
     String enemy = config.prefixEnemies;
     String other = config.prefixOther;
     Team team = scoreboard.getTeam(guild.getTag());
     if (team == null) team = scoreboard.registerNewTeam(guild.getTag());
     for (User u : guild.getMembers()) {
       if (u.getName() == null) continue;
       OfflineUser player = new OfflineUser(u.getName());
       if (!team.hasPlayer(player)) team.addPlayer(player);
     }
     team.setPrefix(replace(our, "{TAG}", guild.getTag()));
     for (Guild one : guilds) {
       if (one == null || one.getTag() == null) continue;
       team = scoreboard.getTeam(one.getTag());
       if (team == null) team = scoreboard.registerNewTeam(one.getTag());
       for (User u : one.getMembers()) {
         if (u.getName() == null) continue;
         OfflineUser player = new OfflineUser(u.getName());
         if (!team.hasPlayer(player)) team.addPlayer(player);
       }
       if (guild.getAllies().contains(one)) team.setPrefix(replace(ally, "{TAG}", one.getTag()));
       else if (guild.getEnemies().contains(one))
         team.setPrefix(replace(enemy, "{TAG}", one.getTag()));
       else team.setPrefix(replace(other, "{TAG}", one.getTag()));
     }
   } else {
     String other = Settings.getInstance().prefixOther;
     for (Guild one : guilds) {
       if (one == null || one.getTag() == null) continue;
       Team team = scoreboard.getTeam(one.getTag());
       if (team == null) team = scoreboard.registerNewTeam(one.getTag());
       for (User u : one.getMembers()) {
         if (u.getName() == null) continue;
         OfflineUser player = new OfflineUser(u.getName());
         if (!team.hasPlayer(player)) team.addPlayer(player);
       }
       team.setPrefix(replace(other, "{TAG}", one.getTag()));
     }
   }
 }
Exemple #23
0
  public void initConfig() {

    List<String> bw = getConfig().getStringList("blacklist");
    for (String s : bw) {
      bw.add(s.toLowerCase());
    }

    scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
    this.saveDefaultConfig();
    List<String> ls = getConfig().getStringList("ranks");
    for (String s : ls) {
      assignedTeams.put(getConfig().getString("rank." + s + ".permission"), s);
      Team t = scoreboard.registerNewTeam("player" + getConfig().getString("rank." + s + ".order"));
      if (getConfig().getString("rank." + s + ".prefix") != null) {
        t.setPrefix(
            ChatColor.translateAlternateColorCodes(
                '&', getConfig().getString("rank." + s + ".prefix")));
      }
      if (getConfig().getString("rank." + s + ".suffix") != null) {
        t.setSuffix(
            ChatColor.translateAlternateColorCodes(
                '&', getConfig().getString("rank." + s + ".suffix")));
      }
    }

    Bukkit.getScheduler()
        .runTaskAsynchronously(
            this,
            new Runnable() {
              public void run() {
                while (whileloop == true) {
                  for (Player p : Bukkit.getOnlinePlayers()) {
                    if (!blacklistedworlds.contains(p.getWorld().getName().toLowerCase())) {
                      p.setScoreboard(scoreboard);
                    }
                  }

                  try {
                    Thread.sleep(5000);
                  } catch (InterruptedException e) {
                    e.printStackTrace();
                  }
                }
              }
            });
  }
  @Override
  public void onEnable() {
    setup = new ConfigAccessor(this, "setup");
    toggles = new ConfigAccessor(this, "toggles");

    setup.saveDefaultConfig();
    toggles.saveDefaultConfig();

    compass = toggles.getConfig().getBoolean("compass", true);
    clock = toggles.getConfig().getBoolean("arenaclock", true);
    specchat = toggles.getConfig().getBoolean("specchat", true);
    scoreboard = toggles.getConfig().getBoolean("colouredtablist", true);
    output = toggles.getConfig().getBoolean("outputmessages", true);
    death = toggles.getConfig().getBoolean("deathspec", false);

    console = getServer().getConsoleSender();
    if (scoreboard) {
      manager = Bukkit.getScoreboardManager();
      board = manager.getNewScoreboard();
      team = board.registerNewTeam("spec");
      team.setPrefix(
          ChatColor.DARK_GRAY
              + "["
              + ChatColor.GRAY
              + "Spec"
              + ChatColor.DARK_GRAY
              + "] "
              + ChatColor.GRAY);
    }

    for (Player player : getServer().getOnlinePlayers()) {
      user.put(player.getName(), new PlayerObject());
    }
    getServer().getPluginManager().registerEvents(new SpectateListener(this), this);
    if (output) {
      console.sendMessage(
          prefix + "Version " + ChatColor.RED + "1.8" + ChatColor.GOLD + " is enabled!");
    }
    this.getCommand("spectate").setExecutor(commands);
    this.getCommand("spec").setExecutor(commands);
  }
  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;
    }
  }
Exemple #26
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);
      }
    }
  }
 public static void updateGameScoreboard(int counter) {
   gameBoard
       .getObjective(DisplaySlot.SIDEBAR)
       .setDisplayName(
           "§3MasterBuilders §8| §a" + String.format("%02d:%02d", counter / 60, counter % 60));
 }
 public static void hideBuilderVotingScoreboard(String exBuilder) {
   votingBoard.resetScores("§a" + exBuilder);
   votingBoard.getObjective(DisplaySlot.SIDEBAR).getScore("§a*****").setScore(3);
 }
Exemple #29
0
  public SporkMap(MapBuilder builder)
      throws MapLoadException, ModuleLoadException, InvalidRegionException, InvalidFilterException {
    this.builder = builder;
    this.document = builder.getDocument();
    this.folder = builder.getFolder();
    Element root = document.getRootElement();

    this.scoreboard = Spork.get().getServer().getScoreboardManager().getNewScoreboard();
    this.objective = scoreboard.registerNewObjective("Objectives", "dummy");

    this.teams = SporkTeamBuilder.build(this);
    this.observers = SporkTeamBuilder.observers(this);

    this.filters = FilterBuilder.build(this);
    // filters();

    this.regions = new ArrayList<>();
    if (root.element("regions") != null) {
      this.regions = RegionBuilder.parseSubRegions(root.element("regions"));
      this.regions.addAll(filtered());
      search();
    }
    // regions();

    this.visible = visible(false);

    this.kits = builder.getKits();
    this.spawns = SporkSpawnBuilder.build(this);
    for (SporkTeam team : teams) {
      if (team.getSpawns().size() == 0) {
        throw new MapLoadException("No Spawns specified for " + team.getName());
      }
    }

    this.modules = builder.getModules();
    this.timer = ((TimerModule) getModule(TimerModule.class));
    loadModules();

    this.kits = SporkKitBuilder.build(document);
    if (kits == null) {
      this.kits = new ArrayList<>();
    }

    /*
    for(SporkTeam team : teams) {
    	List<ObjectiveModule> fetched = team.getObjectives();
    	// Log.info(team.getName() + ": " + fetched + " (" + fetched.size() + ")");

    	List<ObjectiveModule> objectives = new ArrayList<>();
    	for(Module module : modules) {
    		// Log.info("Checking " + module.getClass().getSimpleName() + " to see if it is an instance of ObjectiveModule");
    		if(module instanceof ObjectiveModule) {
    			ObjectiveModule objective = (ObjectiveModule) module;
    			// Log.info("'" + objective.getName() + "' has been found (" + objective.getTeam().getName().toUpperCase() + ")");
    			if(objective.getTeam().equals(team)) {
    				// Log.info("Found '" + objective.getName() + "' for " + objective.getTeam().getName().toUpperCase());
    				objectives.add(objective);
    			}
    		}
    	}
    	// Log.info(team.getName() + ": " + objectives + " (" + objectives.size() + ")");
    }
    */
  }
Exemple #30
0
 public void updateTitle() {
   if (!this.title.equalsIgnoreCase(
       scoreboard.getObjective(DisplaySlot.SIDEBAR).getDisplayName())) {
     scoreboard.getObjective(DisplaySlot.SIDEBAR).setDisplayName(title);
   }
 }