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 + "\".");
    }
  }
Exemple #2
0
  /* Powerups that are a single use only (like Nuke) do not need a time or the initiate variable */
  public void start(Player p) {
    name = Powers.NUKE.getName();

    api.broadcastMessage(
        ChatColor.GREEN
            + p.getDisplayName()
            + ChatColor.DARK_RED
            + " has used"
            + ChatColor.GREEN
            + " Nuke"
            + ChatColor.DARK_RED
            + "!");

    for (Entity e : p.getWorld().getEntities()) {
      if (!(e instanceof Player)) {
        if (e.isValid()) {
          e.remove();
          e.getWorld().playEffect(e.getLocation(), Effect.EXPLOSION_HUGE, 0);
          e.getWorld().playSound(e.getLocation(), Sound.EXPLODE, 10, 1);
          mobs++;
        }
      }
    }
    p.sendMessage(
        Main.tag
            + ChatColor.DARK_RED
            + "You killed "
            + ChatColor.GREEN
            + mobs
            + ChatColor.DARK_RED
            + " mobs!");
  }
Exemple #3
0
 @EventHandler
 public void onland(ProjectileHitEvent e) {
   if (!Api.allowsPVP(e.getEntity())) return;
   if (Arrow.containsKey(e.getEntity())) {
     Entity arrow = e.getEntity();
     if (Enchant.get(arrow).equalsIgnoreCase("Boom")) {
       if (Api.isEnchantmentEnabled("Boom")) {
         if (Api.randomPicker(6 - Api.getPower(Arrow.get(arrow) + "", Api.getEnchName("Boom")))) {
           TNTPrimed tnt = arrow.getWorld().spawn(arrow.getLocation(), TNTPrimed.class);
           tnt.setFuseTicks(0);
           tnt.getWorld().playEffect(tnt.getLocation(), Effect.EXPLOSION_LARGE, 1);
           Explode.add(tnt);
           arrow.remove();
         }
       }
       Arrow.remove(arrow);
     }
     if (Enchant.get(arrow).equalsIgnoreCase("Lightning")) {
       if (Api.isEnchantmentEnabled("Lightning")) {
         Location loc = arrow.getLocation();
         if (Api.randomPicker(5)) {
           loc.getWorld().strikeLightning(loc);
         }
       }
     }
   }
 }
 public void clearNearbyItems() {
   if (item == null) {
     return;
   }
   List<Entity> nearbyEntities = item.getNearbyEntities(7, 7, 7);
   for (Entity entity : nearbyEntities) {
     if (entity instanceof Item) {
       Item nearbyItem = (Item) entity;
       boolean display = false;
       for (MetadataValue cmeta : nearbyItem.getMetadata("HyperConomy")) {
         if (cmeta.asString().equalsIgnoreCase("item_display")) {
           display = true;
           break;
         }
       }
       if (!nearbyItem.equals(item) && !display) {
         if (nearbyItem.getItemStack().getType() == item.getItemStack().getType()) {
           HyperItemStack near = new HyperItemStack(nearbyItem.getItemStack());
           HyperItemStack displayItem = new HyperItemStack(item.getItemStack());
           if (near.getDamageValue() == displayItem.getDamageValue()) {
             entity.remove();
           }
         }
       }
     }
   }
 }
 /** Remove all the old shop items who aren't deleted for some reason */
 public void removeDupedItems() {
   Chunk c = getBlock().getChunk();
   for (Entity e : c.getEntities()) {
     if (e.getLocation().getBlock().equals(getBlock()) && e instanceof Item && !e.equals(item)) {
       e.remove();
     }
     if (e.getLocation()
             .getBlock()
             .equals(
                 getWorld()
                     .getBlockAt(getBlock().getX(), getBlock().getY() + 1, getBlock().getZ()))
         && e instanceof Item
         && !e.equals(item)) {
       e.remove();
     }
   }
 }
 @Override
 public void run() {
   for (final Entity entity : this.war.mainWorld.getEntities()) {
     if (entity instanceof Arrow) {
       entity.remove();
     }
   }
 }
 @Override
 public void finish(CastContext context) {
   super.finish(context);
   if (entity != null) {
     entity.remove();
     entity = null;
   }
 }
Exemple #8
0
 /** Disable * */
 public void onDisable() {
   /** Remove entities * */
   for (World w : Bukkit.getWorlds()) {
     for (Entity e : w.getEntities()) {
       e.remove();
     }
   }
 }
 public static boolean RemoveVillager(World world, String name) {
   if (EpicSystem.useCitizens()) return false;
   Entity entity = GetEntity(world, name);
   if (entity != null) {
     entityList.remove(entity);
     entity.remove();
     return true;
   }
   return false;
 }
 /* (non-Javadoc)
  * @see java.lang.Runnable#run()
  */
 @Override
 public void run() {
   List<Entity> entites;
   entites = world.getEntities();
   for (Entity e : entites) {
     if (e instanceof Animals) {
       e.remove();
     }
   }
 }
Exemple #11
0
 public void prepareWorld() {
   game.getArena().getWorld().setTime(0);
   game.getArena().fillChests();
   for (Entity e : game.getArena().getWorld().getEntities()) {
     if (e instanceof Monster || e instanceof Slime) {
       Bukkit.getPluginManager()
           .callEvent(new EntityDeathEvent((LivingEntity) e, Collections.<ItemStack>emptyList()));
       e.remove();
     }
   }
 }
 public void clearEnt() {
   for (Entity e : getCorn().getWorld().getEntities()) {
     if (e.getType() == EntityType.DROPPED_ITEM
         || e.getType() == EntityType.CREEPER
         || e.getType() == EntityType.SKELETON
         || e.getType() == EntityType.SPIDER
         || e.getType() == EntityType.ENDERMAN
         || e.getType() == EntityType.ZOMBIE) {
       e.remove();
     }
   }
 }
  private int removeEntities(Chunk chunk) {
    int entityCount = 0;

    for (Entity entity : chunk.getEntities()) {
      if (entity instanceof Player || entity instanceof Hanging || entity instanceof NPC) {
        continue;
      }
      entity.remove();
      entityCount++;
    }

    return entityCount;
  }
  @EventHandler(ignoreCancelled = true)
  public void onEntityExplode(EntityExplodeEvent event) {

    Entity entity = event.getEntity();
    int quantity = StackUtils.getStackSize(entity);

    // Only bother with entities that are actually stacked.
    if (quantity < 2) {
      return;
    }

    if (!plugin.getConfig().getBoolean("exploding-creeper-kills-stack")) {

      // If we're not killing the full stack, peel off the rest.
      entity = plugin.getStackUtils().peelOffStack(entity);

      // Set 1 tick of no damage to prevent resulting explosion harming the new stack.
      if (entity instanceof LivingEntity) {
        ((LivingEntity) entity).setNoDamageTicks(1);
      }

      return;
    }

    // Amplify explosions if configured to do so.
    if (plugin.getConfig().getBoolean("magnify-stack-explosion.enable")) {

      /*
       * Charged creepers have a power of 6, TNT has a power of 4, normal creepers have a
       * power of 3. For everything else, 1 is probably a safe default. Really, it's a minimum
       * of 2 as that's how many mobs must be in the stack to reach this point.
       */
      float power =
          quantity + (entity instanceof Creeper ? ((Creeper) entity).isPowered() ? 5 : 2 : 0);

      // Cap explosion power to configured maximum.
      quantity =
          Math.max(
              1,
              Math.min(
                  quantity,
                  plugin.getConfig().getInt("magnify-stack-explosion.max-creeper-explosion-size")));

      // Remove the entity - exploding entities don't fly off dying, they vanish with the explosion.
      entity.remove();

      // Create the explosion.
      event.getLocation().getWorld().createExplosion(event.getLocation(), power);
    }
  }
  public boolean collect() {

    boolean collected = false;

    for (Entity entity : LocationUtil.getNearbyEntities(centre, radius)) {
      if (entity.isValid() && entity instanceof Item) {
        if (LocationUtil.isWithinRadius(centre, entity.getLocation(), radius)) {

          stackCheck:
          {
            ItemStack stack = ((Item) entity).getItemStack();

            if (!ItemUtil.isStackValid(stack)) return false;

            for (ItemStack filter : filters) {

              if (!ItemUtil.isStackValid(filter)) continue;

              if (include && !ItemUtil.areItemsIdentical(filter, stack)) break stackCheck;
              else if (!include && ItemUtil.areItemsIdentical(filter, stack)) break stackCheck;
            }

            BlockFace back = SignUtil.getBack(BukkitUtil.toSign(getSign()).getBlock());
            Block pipe = getBackBlock().getRelative(back);

            Pipes pipes = Pipes.Factory.setupPipes(pipe, getBackBlock(), stack);

            if (pipes != null && pipes.getItems().isEmpty()) return true;

            // Add the items to a container, and destroy them.
            List<ItemStack> leftovers =
                InventoryUtil.addItemsToInventory((InventoryHolder) chest.getState(), stack);
            if (leftovers.isEmpty()) {
              entity.remove();
              return true;
            } else {
              if (ItemUtil.areItemsIdentical(leftovers.get(0), stack)
                  && leftovers.get(0).getAmount() != stack.getAmount()) {
                ((Item) entity).setItemStack(leftovers.get(0));
                return true;
              }
            }
          }
        }
      }
    }

    return collected;
  }
Exemple #16
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);
 }
  /** Check win * */
  private void checkWin() {
    for (Player p : Bukkit.getOnlinePlayers()) {
      if (points.containsKey(p.getName())) {
        if (points.get(p.getName()) == 15) {
          /** Clear inventories * */
          for (Player t : Bukkit.getOnlinePlayers()) {
            t.getInventory().clear();

            t.setLevel(0);
            p.setExp(0f);
          }

          /** Bukkit task * */
          runnable.cancel();

          /** Remove chickens * */
          for (Entity e : chickens) {
            if (!e.isDead()) e.remove();
          }

          /** Broadcast * */
          Bukkit.broadcastMessage(MTP.PREFIX + "" + p.getName() + " �at gewonnen!");

          /** Sounds * */
          for (Player tp : Bukkit.getOnlinePlayers()) {
            if (tp == p) {
              /** Points * */
              MTP.points.put(p.getName(), MTP.points.get(p.getName()) + 1);

              tp.playSound(tp.getLocation(), "win", 1, 1);
            } else tp.playSound(tp.getLocation(), "lose", 1, 1);
          }

          /** Runnable * */
          new BukkitRunnable() {
            public void run() {
              end();
            }
          }.runTaskLater(MTP.getPlugin(), 10 * 20L);

          /** Break * */
          break;
        }
      }
    }
  }
 public void play(LivingEntity entity) {
   if (entity.isInsideVehicle()) {
     Entity carrier = entity.getVehicle();
     // if(carrier instanceof Arrow) {
     // entity.leaveVehicle();
     carrier.remove();
     // }
   } else {
     Location loc = entity.getLocation();
     // loc.setY(loc.getY() - 0.5);
     // Arrow arrow = entity.getLocation().getWorld().spawnArrow(loc, new Vector(0, -1, 0), 0, 0);
     // arrow.setPassenger(entity);
     // entity.teleport(loc);
     Entity e = loc.getWorld().spawn(loc, ArmorStand.class);
     e.setPassenger(entity);
   }
 }
    public static int wipeEntities(boolean wipeExplosives, boolean wipeVehicles) {
      int removed = 0;

      Iterator<World> worlds = Bukkit.getWorlds().iterator();
      while (worlds.hasNext()) {
        Iterator<Entity> entities = worlds.next().getEntities().iterator();
        while (entities.hasNext()) {
          Entity entity = entities.next();
          if (canWipe(entity, wipeExplosives, wipeVehicles)) {
            entity.remove();
            removed++;
          }
        }
      }

      return removed;
    }
Exemple #20
0
  @EventHandler
  public void onProjectileHit(ProjectileHitEvent e) {
    final Entity entity = e.getEntity();
    if (removeArrows.contains(entity.getEntityId())) {
      entity.remove();
      removeArrows.remove(entity.getEntityId());
    } else if (rpgProjectiles.contains(entity.getEntityId())) {
      RPGItem item = ItemManager.getItemById(rpgProjectiles.get(entity.getEntityId()));
      new BukkitRunnable() {

        public void run() {
          rpgProjectiles.remove(entity.getEntityId());
        }
      }.runTask(Plugin.plugin);
      if (item == null) return;
      item.projectileHit((Player) ((Projectile) entity).getShooter(), (Projectile) entity);
    }
  }
Exemple #21
0
 public void crystalRegen() {
   Chunk bukkitChunk;
   for (final EndChunk c : chunks.values()) {
     if (c.containsCrystal()) {
       final World w = Bukkit.getWorld(c.getWorldName());
       bukkitChunk = w.getChunkAt(c.getX(), c.getZ());
       final Set<Location> locs = c.getCrystalLocations();
       for (final Entity e : bukkitChunk.getEntities()) {
         if (e.getType() == EntityType.ENDER_CRYSTAL) {
           e.remove();
         }
       }
       for (final Location loc : locs) {
         w.spawnEntity(loc.clone().add(0, -1, 0), EntityType.ENDER_CRYSTAL);
         loc.getBlock().getRelative(BlockFace.DOWN).setType(Material.BEDROCK);
       }
     }
   }
 }
  private int removeEntities(final Chunk chunk) {
    int _entityCount = 0;

    for (final Entity _e : chunk.getEntities()) {
      if ((_e instanceof Player) || (_e instanceof Painting)) {
        continue;
      } else {
        if (((CraftEntity) _e).getHandle() instanceof NPC) {
          if (!(((CraftEntity) _e).getHandle() instanceof EntityCreature)) {
            continue;
          }
        }
        _e.remove();
        _entityCount++;
      }
    }

    return _entityCount;
  }
Exemple #23
0
  /*
   *
   * ################################################
   *
   * 				PLAYER WIN
   *
   * ################################################
   *
   *
   */
  public void playerWin(Player p) {
    if (GameMode.DISABLED == mode) return;
    Player win = activePlayers.get(0);
    // clearInv(p);
    win.teleport(winloc);
    // restoreInv(win);
    scoreBoard.removePlayer(p);
    msgmgr.broadcastFMessage(
        PrefixType.INFO,
        "game.playerwin",
        "arena-" + gameID,
        "victim-" + p.getName(),
        "player-" + win.getName());

    mode = GameMode.FINISHING;
    LobbyManager.getInstance().updateWall(gameID);
    LobbyManager.getInstance().gameEnd(gameID, win);

    clearSpecs();
    win.setHealth(p.getMaxHealth());
    win.setFoodLevel(20);
    win.setFireTicks(0);
    win.setFallDistance(0);

    sm.playerWin(win, gameID, new Date().getTime() - startTime);
    sm.saveGame(
        gameID, win, getActivePlayers() + getInactivePlayers(), new Date().getTime() - startTime);

    activePlayers.clear();
    inactivePlayers.clear();
    spawns.clear();

    loadspawns();
    LobbyManager.getInstance().updateWall(gameID);
    MessageManager.getInstance()
        .broadcastFMessage(PrefixType.INFO, "broadcast.gameend", "arena-" + gameID);

    // Remove all entities in the world
    for (Entity entity : this.arena.getMax().getWorld().getEntities()) {
      if (entity instanceof Player) continue;
      entity.remove();
    }
  }
 @Override
 public void onEnable() {
   plugin = this;
   GameState.setState(GameState.IN_LOBBY);
   Game.setCanStart(false);
   new Thread(new StartCountdown()).start();
   registerListeners();
   for (Player p : Bukkit.getOnlinePlayers()) {
     p.kickPlayer(ChatColor.GREEN + "Reloading. Rejoin.");
   }
   for (World w : Bukkit.getServer().getWorlds()) {
     w.setTime(0);
     w.setStorm(false);
     w.setWeatherDuration(9999999);
     for (Entity e : w.getEntities()) {
       e.remove();
     }
   }
   PointSB.initializeScoreboard();
 }
Exemple #25
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());
     }
   }
 }
Exemple #26
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 onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {

    // Determine if the sender is a player (and an op), or the console.
    boolean isPlayer = (sender instanceof Player);

    // Cast the sender to Player if possible.
    Player p = (isPlayer) ? (Player) sender : null;

    // ---------------
    // Remove vehicles
    // ----------------
    if (cmd.getName().equalsIgnoreCase("removevehicles")) {
      int removedVehicles = 0;

      if (p.hasPermission("minecartremover.removevehicles")) {
        for (World world : getServer().getWorlds()) {
          for (Entity entity : world.getEntities()) {
            if ((entity instanceof Vehicle)) {
              if (((Vehicle) entity).isEmpty()) {
                entity.remove();
                ++removedVehicles;
              }
            }
          }
        }

        sender.sendMessage(
            ChatColor.GREEN
                + "[VehicleRemover] "
                + removedVehicles
                + " empty Vehicles have been removed.");

        return true;
      }
      sender.sendMessage(ChatColor.RED + "You dont have permissions to do this!");
      return true;
    }

    return false;
  }
 /** Checks the creeper is there and spawns in a new one if not. */
 private void checkCreepers() {
   ResultSetTardis rs = new ResultSetTardis(plugin, null, "", true);
   if (rs.resultSet()) {
     ArrayList<HashMap<String, String>> data = rs.getData();
     for (HashMap<String, String> map : data) {
       // only if there is a saved creeper location
       if (!map.get("creeper").isEmpty()) {
         // only if the TARDIS has been initialised
         if (map.get("tardis_init").equals("1")) {
           String[] creeperData = map.get("creeper").split(":");
           World w = plugin.getServer().getWorld(creeperData[0]);
           if (w != null) {
             float cx = 0, cy = 0, cz = 0;
             try {
               cx = plugin.utils.parseFloat(creeperData[1]);
               cy = plugin.utils.parseFloat(creeperData[2]) + 1;
               cz = plugin.utils.parseFloat(creeperData[3]);
             } catch (NumberFormatException nfe) {
               plugin.debug("Couldn't convert to a float! " + nfe.getMessage());
             }
             Location l = new Location(w, cx, cy, cz);
             plugin.myspawn = true;
             Entity e = w.spawnEntity(l, EntityType.CREEPER);
             // if there is a creeper there already get rid of it!
             for (Entity k : e.getNearbyEntities(1d, 1d, 1d)) {
               if (k.getType().equals(EntityType.CREEPER)) {
                 e.remove();
                 break;
               }
             }
             Creeper c = (Creeper) e;
             c.setPowered(true);
           }
         }
       }
     }
   }
 }
  /**
   * Remove creatures from chunk at and around the given location.
   *
   * @param l
   */
  public void removeCreatures(Location l) {
    if (!this.settings.getRemoveCreaturesByTeleport() || l == null) {
      return;
    }

    int px = l.getBlockX();
    int py = l.getBlockY();
    int pz = l.getBlockZ();
    for (int x = -1; x <= 1; x++) {
      for (int z = -1; z <= 1; z++) {
        Chunk c = l.getWorld().getChunkAt(new Location(l.getWorld(), px + x * 16, py, pz + z * 16));
        for (Entity e : c.getEntities()) {
          if (e.getType() == EntityType.SPIDER
              || e.getType() == EntityType.CREEPER
              || e.getType() == EntityType.ENDERMAN
              || e.getType() == EntityType.SKELETON
              || e.getType() == EntityType.ZOMBIE) {
            e.remove();
          }
        }
      }
    }
  }
  /** Replace naturally spawned monsters in the affected world with creepers. */
  @EventHandler(ignoreCancelled = true)
  public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (!CONFIG.isAffectedWorld(event)
        || event.getSpawnReason() != SpawnReason.NATURAL
        || !isEligibleHostileMob(event.getEntityType())) {
      return;
    }

    Entity originalMob = event.getEntity();
    Creeper creeper;
    if (event.getEntityType() == EntityType.CREEPER) {
      creeper = (Creeper) originalMob;
    } else {
      Location loc = originalMob.getLocation();
      creeper = (Creeper) loc.getWorld().spawnEntity(loc, EntityType.CREEPER);
      originalMob.remove();
    }
    creeper.setMetadata(SPECIAL_KEY, SPECIAL_META);

    if (Math.random() < CONFIG.CHARGED_CHANCE) {
      creeper.setPowered(true);
    }
  } // onCreatureSpawn