Example #1
0
  @Override
  public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    if (event.isCancelled()
        || plugin
            .getConfigManager()
            .getProperties()
            .disabledWorlds
            .contains(event.getPlayer().getWorld().getName())) return;

    final Hero hero = plugin.getHeroManager().getHero(event.getPlayer());
    if (hero.hasEffectType(EffectType.DISARM)
        && Util.isWeapon(event.getItem().getItemStack().getType())) {
      event.setCancelled(true);
      return;
    }

    plugin
        .getServer()
        .getScheduler()
        .scheduleSyncDelayedTask(
            plugin,
            new Runnable() {
              @Override
              public void run() {
                hero.checkInventory();
              }
            });

    if (!hero.hasParty()) return;
    HeroParty party = hero.getParty();
    if (!party.updateMapDisplay()
        && event.getItem().getItemStack().getType().toString().equalsIgnoreCase("MAP")) {
      party.setUpdateMapDisplay(true);
    }
  }
  /**
   * Called when a player attempts to pickup an item
   *
   * @param event Relevant event details
   */
  @Override
  public void onPlayerPickupItem(PlayerPickupItemEvent event) {

    if (event.isCancelled()) {
      return;
    }

    GlobalConfiguration cfg = plugin.getGlobalConfiguration();
    WorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName());

    if (wcfg.getBlacklist() != null) {
      Item ci = event.getItem();

      if (!wcfg.getBlacklist()
          .check(
              new ItemAcquireBlacklistEvent(
                  BukkitPlayer.wrapPlayer(plugin, event.getPlayer()),
                  toVector(ci.getLocation()),
                  ci.getItemStack().getTypeId()),
              false,
              false)) {
        event.setCancelled(true);
        return;
      }
    }
  }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerPickupItemEvent(PlayerPickupItemEvent event) {
    if (event.isCancelled()) return;

    final Player player = event.getPlayer();
    final Item item = event.getItem();

    if (player.getWorld() != plugin.getIslandWorld()) return;
    if (player.isOp()) return;
    if (player.hasPermission("islandworld.bypass.island")) return;

    if (item != null
        && !(plugin.getConfig().getBoolean("flags.item-pickup", false)
            || plugin.canBuildOnLocation(player, item.getLocation()))) event.setCancelled(true);

    plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled());
  }
Example #4
0
  public void a_(EntityHuman entityhuman) {
    if (!this.world.isStatic) {
      // CraftBukkit start
      ItemStack itemstack = new ItemStack(Item.ARROW, 1);
      if (this.inGround
          && this.fromPlayer
          && this.shake <= 0
          && entityhuman.inventory.canHold(itemstack) > 0) {
        net.minecraft.server.EntityItem item =
            new net.minecraft.server.EntityItem(
                this.world, this.locX, this.locY, this.locZ, itemstack);

        PlayerPickupItemEvent event =
            new PlayerPickupItemEvent(
                (org.bukkit.entity.Player) entityhuman.getBukkitEntity(),
                new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), item),
                0);
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
          return;
        }
      }
      // CraftBukkit end

      if (this.inGround
          && this.fromPlayer
          && this.shake <= 0
          && entityhuman.inventory.pickup(new ItemStack(Item.ARROW, 1))) {
        this.world.makeSound(
            this,
            "random.pop",
            0.2F,
            ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
        entityhuman.receive(this, 1);
        this.die();
      }
    }
  }
Example #5
0
  public void c_(EntityHuman entityhuman) {
    if (!this.world.isStatic && this.inGround && this.shake <= 0) {
      // CraftBukkit start
      ItemStack itemstack = new ItemStack(Item.ARROW);
      if (this.fromPlayer == 1 && entityhuman.inventory.canHold(itemstack) > 0) {
        EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);

        PlayerPickupItemEvent event =
            new PlayerPickupItemEvent(
                (org.bukkit.entity.Player) entityhuman.getBukkitEntity(),
                new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item),
                0);
        event.setCancelled(!entityhuman.canPickUpLoot);
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
          return;
        }
      }
      // CraftBukkit end

      boolean flag =
          this.fromPlayer == 1 || this.fromPlayer == 2 && entityhuman.abilities.canInstantlyBuild;

      if (this.fromPlayer == 1 && !entityhuman.inventory.pickup(new ItemStack(Item.ARROW, 1))) {
        flag = false;
      }

      if (flag) {
        this.makeSound(
            "random.pop",
            0.2F,
            ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
        entityhuman.receive(this, 1);
        this.die();
      }
    }
  }