Exemple #1
0
  @Override
  public void execute(Sender sender, String[] args) throws CommandException {
    Player player = (Player) sender;

    if (args[0].equals("-k")) {
      int i = 0;
      Iterator<Entity> it = new ArrayList<>(BukkitLocation.getWorld().getEntities()).iterator();

      while (it.hasNext()) {
        Entity entity = it.next();

        if (entity instanceof ArmorStand
            && this.matchLocation(entity.getLocation(), player.getLocation())) {
          entity.remove();
          i++;
        }
      }

      if (i == 0) {
        player.sendError("Brak hologramów w tej lokalizacji.");
      } else {
        player.sendSuccess("Usunieto " + i + " hologramów.");
      }
    } else {
      String value = Color.translate(StringUtils.join(args, ' ')) + Color.RESET;

      Hologram hologram = Holograms.create((player).getLocation());
      hologram.setHologram(value);
      hologram.update();

      player.sendSuccess("Stworzono hologram \"" + value + Color.GREEN + "\".");
    }
  }
  @EventHandler
  public void onPlayerRespawn(PlayerRespawnEvent e) {
    final Player player = Arcade.getServer().getPlayer(e.getPlayer().getUniqueId());
    List<Spawn> spawns = this.getSpawnLocations(player);
    Spawn spawn = spawns.get(this.random.nextInt(spawns.size()));

    PlayerRespawnMatchEvent event = new PlayerRespawnMatchEvent(player, spawn);
    Event.callEvent(event);

    e.setRespawnLocation(BukkitLocation.valueOf(event.getSpawn()));

    if (!event.isCancel()) {
      Bukkit.getScheduler()
          .runTaskLater(
              ArcadeBukkitPlugin.getPlugin(),
              new Runnable() {
                @Override
                public void run() {
                  if (player == null) {
                    return;
                  } else if (player.isObserver()) {
                    Arcade.getPlayerManagement().setAsObserver(player, true, true, true);
                  } else {
                    Arcade.getPlayerManagement()
                        .setAsPlayer(player, KitType.RESPAWN, false, false, false);
                  }
                }
              },
              1L);
    }
  }