Esempio n. 1
0
 static void unsitPlayer(Player player, Block block) {
   occupiedChairs.remove(player);
   Bukkit.getScheduler().cancelTask(chairTask.get(player));
   chairTask.remove(player);
   chairTimer.remove(player);
   for (Entity entity : player.getWorld().getChunkAt(player.getLocation()).getEntities()) {
     if (Methods.convertBlock(entity.getLocation().getBlock(), false)
         .matches(Methods.convertBlock(block, false))) {
       entity.eject();
       entity.remove();
     }
   }
   if (Slots.isSitting(player)) Slots.setAvailable(player, block);
   if (TicTacToe.isSitting(player)) TicTacToe.removeOccupied(player);
 }
Esempio n. 2
0
 public MG10_Remove() {
   GameData data = Main.getMain().getGameData();
   ArrayList<UUID> players = new ArrayList<>();
   for (Entity e : data.getEntitys()) {
     if (!e.isEmpty()) {
       Entity p = e.getPassenger();
       if (p.getType() == EntityType.PLAYER) {
         players.add(p.getUniqueId());
         e.eject();
       }
     }
     e.remove();
   }
   data.getEntitys().clear();
   for (Player player : data.getPlayers()) {
     if (!players.contains(player.getUniqueId())) {
       data.diePlayer(player.getUniqueId());
     }
   }
 }
Esempio n. 3
0
  /**
   * Teleport a player to a location.
   *
   * @param player The player.
   * @param to The location to teleport to.
   * @param keepVehicle Whether or not to keep the vehicle.
   */
  public static void teleport(Player player, Location to, boolean keepVehicle) {
    if (to == null || player == null) return;

    if (player.isInsideVehicle()) {
      // Eject the vehicle...
      Entity vehicle = player.getVehicle();
      vehicle.eject();
      // Teleport the player...
      player.teleport(to);
      // Remove the vehicle if it's not persisting.
      if (!keepVehicle) vehicle.remove();
      else {
        // Otherwise teleport the vehicle and remount.
        vehicle.teleport(to);
        vehicle.setPassenger(player);
      }
      return;
    }

    player.teleport(to);
  }
 public boolean eject() {
   return e.eject();
 }