Esempio n. 1
0
  @Override
  protected void run(Player p, SLPlayer slp, Command cmd, String[] args) {
    p.sendMessage(
        ChatColor.DARK_GRAY
            + "[ "
            + ChatColor.GRAY
            + "============ "
            + ChatColor.DARK_AQUA
            + "Spawns"
            + ChatColor.GRAY
            + " ============"
            + ChatColor.DARK_GRAY
            + " ]");

    ModifiableFinal<Integer> current = new ModifiableFinal<>(1);
    SpleefLeague.getInstance()
        .getSpawnManager()
        .getAll()
        .forEach(
            (SpawnManager.SpawnLocation spawnLocation) -> {
              ComponentBuilder componentBuilder =
                  new ComponentBuilder("#" + current.getValue())
                      .color(ChatColor.RED.asBungee())
                      .append(" | ")
                      .color(ChatColor.DARK_GRAY.asBungee())
                      .append("CLICK TO TELEPORT")
                      .color(ChatColor.GRAY.asBungee())
                      .event(
                          new ClickEvent(
                              ClickEvent.Action.RUN_COMMAND,
                              "/tppos "
                                  + spawnLocation.getLocation().getBlockX()
                                  + " "
                                  + spawnLocation.getLocation().getBlockY()
                                  + ' '
                                  + spawnLocation.getLocation().getBlockZ()))
                      .append(" | ")
                      .color(ChatColor.DARK_GRAY.asBungee())
                      .append(spawnLocation.getPlayersInRadius() + " players")
                      .color(ChatColor.GRAY.asBungee());
              slp.spigot().sendMessage(componentBuilder.create());
              current.setValue(current.getValue() + 1);
            });

    p.sendMessage(
        ChatColor.RED
            + "All spawns were cached "
            + TimeUtil.dateToString(
                new Date(SpleefLeague.getInstance().getSpawnManager().getLastCached()), false)
            + " ago.");
  }