コード例 #1
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;
      }
    }
  }
コード例 #2
0
 @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
 public void onPlayerDropsItem(PlayerDropItemEvent event) {
   plugin
       .getServer()
       .getScheduler()
       .runTask(plugin, new ResetIgnoreSleepTask(plugin, event.getPlayer().getName()));
 }
コード例 #3
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();
     }
   }
 }
コード例 #4
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();
     }
   }
 }
コード例 #5
0
 @EventHandler
 public void SpectatorDrops(PlayerDropItemEvent event) {
   Player p = event.getPlayer();
   String pname = p.getName();
   for (i = 0; i < plugin.Watching.size(); i++) {
     if (plugin.Watching.get(i) != null) {
       if (plugin.Watching.get(i).contains(pname)) {
         event.setCancelled(true);
         p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
       }
     }
   }
 }
コード例 #6
0
 /**
  * Handles item dropping.<br>
  * If the player is in an arena, the game's onItemDrop method is called.<br>
  * If the player is spectating an arena, the event is cancelled.
  */
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onItemDrop(PlayerDropItemEvent event) {
   String playerName = event.getPlayer().getName();
   if (ultimateGames.getPlayerManager().isPlayerInArena(playerName)) {
     Arena arena = ultimateGames.getPlayerManager().getPlayerArena(playerName);
     if (arena.getStatus() == ArenaStatus.RUNNING) {
       arena.getGame().getGamePlugin().onItemDrop(arena, event);
     } else {
       event.setCancelled(true);
     }
   } else if (ultimateGames.getPlayerManager().isPlayerSpectatingArena(playerName)) {
     event.setCancelled(true);
   }
 }