コード例 #1
0
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onItemDrop(PlayerDropItemEvent event) {
    if (!isInDropOffArea(event.getPlayer().getLocation())) return;

    ItemStack stack = event.getItemDrop().getItemStack();
    if (!isAllowedToDrop(stack.getType())) {
      event.setCancelled(true);
      return;
    }
    if (!isScoringItemType(stack.getType())) return;

    FarmTeamInfo team = (FarmTeamInfo) getTeam(event.getPlayer());
    int teamNum = indexOfTeam(team);
    long dropScore = 0;

    for (int i = 0; i < stack.getAmount(); i++)
      dropScore += getScoreForItem(stack.getType(), teamNum);

    event.getPlayer().sendMessage(stack.getType().name() + ": score +" + dropScore);
    team.addScore(dropScore);

    event
        .getItemDrop()
        .remove(); // don't actually DROP the item ... should we schedule a brief delay here?
  }
コード例 #2
0
 @EventHandler
 public void onSoulboundDrop(PlayerDropItemEvent e) {
   if (isSoulbound(e.getItemDrop().getItemStack())) {
     Player p = e.getPlayer();
     SoundManager.playSoundForPlayer(p, Sound.BLAZE_HIT, 1F, 0.25F, 0.5F);
     e.getItemDrop().remove();
   }
 }
コード例 #3
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerDropItem(PlayerDropItemEvent event) {

    ItemStack item = event.getItemDrop().getItemStack();
    if (!isItemInfoBook(item)) {
      return;
    }

    event.getItemDrop().remove();
  }
コード例 #4
0
 /**
  * Cancel players from dropping the hat in their inventory.
  *
  * @param event
  */
 @EventHandler
 public void cancelHatDropping(PlayerDropItemEvent event) {
   ItemStack item = event.getItemDrop().getItemStack().clone();
   if (item != null
       && item.hasItemMeta()
       && item.getItemMeta().hasDisplayName()
       && item.getItemMeta().getDisplayName().equals("§8§oHat")) {
     event.getItemDrop().remove();
     event.getPlayer().closeInventory();
     event.getPlayer().updateInventory();
   }
 }
コード例 #5
0
ファイル: BTest.java プロジェクト: Rayzr522/Quake
  @Override
  public void call(Event event) {

    PlayerDropItemEvent e = (PlayerDropItemEvent) event;

    if (e.getItemDrop().getItemStack().getType() == Material.SULPHUR) {

      Item item = e.getItemDrop();

      item.getWorld().createExplosion(item.getLocation(), 10f, false);
    }
  }
コード例 #6
0
  /**
   * Called when a player attempts to drop an item
   *
   * @param event Relevant event details
   */
  @Override
  public void onPlayerDropItem(PlayerDropItemEvent event) {

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

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

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

      if (!wcfg.getBlacklist()
          .check(
              new ItemDropBlacklistEvent(
                  BukkitPlayer.wrapPlayer(plugin, event.getPlayer()),
                  toVector(ci.getLocation()),
                  ci.getItemStack().getTypeId()),
              false,
              false)) {
        event.setCancelled(true);
        return;
      }
    }
  }
コード例 #7
0
ファイル: FillyHandler.java プロジェクト: alkarinv/PPPoPP3
 @EventHandler
 public void onDrop(PlayerDropItemEvent event) {
   if (isFilly(event.getPlayer())) {
     ItemStack is = event.getItemDrop().getItemStack();
     if (is.getType() == Material.WRITTEN_BOOK) {
       BookMeta bm = (BookMeta) is.getItemMeta();
       if ((bm.hasAuthor() && bm.getAuthor().equals("TheQueenOfPink"))
           && (bm.hasTitle() && bm.getTitle().equals("MineLittlePony.se Handbook"))) {
         event.getItemDrop().remove();
       }
       if (PonyManager.getGroup(event.getPlayer()).equals("filly")) {
         event.getPlayer().getInventory().addItem(getFillyHandbook());
       }
     }
   }
 }
コード例 #8
0
ファイル: playerListener.java プロジェクト: BigJeyEm/MCMEPVP
 @EventHandler(priority = EventPriority.HIGH)
 public void dropItem(PlayerDropItemEvent event) {
   if (PVPGT.equals("RBR") && (ringBearers.size() > 0)) {
     if (event.getItemDrop().getItemStack().getType().equals(Material.GLOWSTONE)) {
       event.setCancelled(true);
     }
   }
 }
コード例 #9
0
 @EventHandler(priority = EventPriority.NORMAL)
 public void onPlayerDropItem(PlayerDropItemEvent event) {
   if (TFM_ConfigEntry.AUTO_ENTITY_WIPE.getBoolean()) {
     if (event.getPlayer().getWorld().getEntities().size() > 750) {
       event.setCancelled(true);
     } else {
       event.getItemDrop().remove();
     }
   }
 }
コード例 #10
0
 @EventHandler(priority = EventPriority.NORMAL)
 public void onPlayerDropItem(PlayerDropItemEvent event) {
   if (TotalFreedomMod.autoEntityWipe) {
     if (event.getPlayer().getWorld().getEntities().size() > 750) {
       event.setCancelled(true);
     } else {
       event.getItemDrop().remove();
     }
   }
 }
コード例 #11
0
ファイル: Gadget.java プロジェクト: VenaCzPlay/UltraCosmetics
 @EventHandler
 protected void onItemDrop(PlayerDropItemEvent event) {
   if (event.getItemDrop().getItemStack().getType() == type.getMaterial()) {
     if (event.getItemDrop().getItemStack().getData().getData() == type.getData()) {
       if (event.getItemDrop().getItemStack().getItemMeta().hasDisplayName()) {
         if (event
             .getItemDrop()
             .getItemStack()
             .getItemMeta()
             .getDisplayName()
             .endsWith(getName())) {
           if (SettingsManager.getConfig().getBoolean("Remove-Gadget-With-Drop")) {
             Core.getCustomPlayer(getPlayer()).removeGadget();
             event.getItemDrop().remove();
             return;
           }
           event.setCancelled(true);
         }
       }
     }
   }
 }
コード例 #12
0
 @EventHandler(priority = EventPriority.MONITOR)
 public void onDropEvent(PlayerDropItemEvent event) {
   Player player = event.getPlayer();
   if (!plugin.isSkyWorld(player.getWorld())) {
     return;
   }
   if (!visitorsCanDrop && !plugin.playerIsOnIsland(player) && !plugin.playerIsInSpawn(player)) {
     event.setCancelled(true);
     plugin.notifyPlayer(player, "\u00a7eVisitors can't drop items!");
     return;
   }
   addDropInfo(player, event.getItemDrop().getItemStack());
 }
コード例 #13
0
ファイル: DropInv.java プロジェクト: keybordpiano459/AntiHax
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onItemDrop(PlayerDropItemEvent event) {
   Player player = event.getPlayer();
   ItemStack item = event.getItemDrop().getItemStack();
   int amount = item.getAmount();
   if (!player.hasPermission("antihax.check.dropinv")) {
     if (amount > 64) {
       event.setCancelled(true);
       tellPlayer(
           player,
           "[" + ChatColor.RED + "AntiHax" + ChatColor.RESET + "] You dropped items too fast!");
     }
   }
 }
コード例 #14
0
  @EventHandler(priority = EventPriority.LOWEST)
  public void onItemDrop(PlayerDropItemEvent event) {
    if (event.isCancelled()) return;

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

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

    if (!(plugin.canBuildOnLocation(player, item.getLocation()))) event.setCancelled(true);

    plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled());
  }
コード例 #15
0
 @EventHandler
 public void onPlayerDropitem(PlayerDropItemEvent event) {
   if (Suffocate.isTempHelmet(event.getItemDrop().getItemStack())) {
     event.setCancelled(true);
   }
 }
コード例 #16
0
 @Override
 public void onDrop(PlayerDropItemEvent event) {
   event.getItemDrop().remove();
 }
コード例 #17
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerDropItem(PlayerDropItemEvent event) {

    final Player p = event.getPlayer();
    final Item item = event.getItemDrop();

    if (isWorld(item.getWorld())) {

      new BukkitRunnable() {
        @Override
        public void run() {

          if (item.isDead()) {
            cancel();
            return;
          }

          List<Entity> ents = EntityChecker.getNearbyEntities(item, 2);
          for (Entity ent : ents) {

            MetadataValue meta;
            if (ent instanceof ArmorStand
                && (meta = EntityChecker.getMeta(ent, "isFireplace")) != null
                && meta.asBoolean()) {

              ItemStack result = item.getItemStack();
              item.remove();

              Material type = result.getType();
              switch (type) {
                case RAW_CHICKEN:
                  result.setType(Material.COOKED_CHICKEN);
                  break;
                case RAW_BEEF:
                  result.setType(Material.COOKED_BEEF);
                  break;
                case RAW_FISH:
                  result.setType(Material.COOKED_FISH);
                  break;
                case PORK:
                  result.setType(Material.GRILLED_PORK);
                  break;
                case POTATO_ITEM:
                  result.setType(Material.BAKED_POTATO);
                  break;
                default:
                  break;
              }

              cancel();

              if (p.isOnline()) {
                p.getWorld().dropItem(p.getLocation(), result).setPickupDelay(0);
              } else {
                p.getWorld().dropItem(item.getLocation(), result).setPickupDelay(0);
              }

              break;
            }
          }
        }
      }.runTaskTimer(getCraftZ(), 10, 10);
    }
  }