org.bukkit.event.entity.ItemDespawnEvent Java Examples

The following examples show how to use org.bukkit.event.entity.ItemDespawnEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ItemListener.java    From MineTinker with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onDespawn(ItemDespawnEvent event) {
	Item item = event.getEntity();
	ItemStack is = item.getItemStack();

	if (!((modManager.isArmorViable(is) || modManager.isToolViable(is) || modManager.isWandViable(is))
			|| (MineTinker.getPlugin().getConfig().getBoolean("ItemBehaviour.ForModItems")
			&& modManager.isModifierItem(is)))) {
		return;
	}

	if (MineTinker.getPlugin().getConfig().getBoolean("ItemBehaviour.SetPersistent")) {
		event.setCancelled(true);
		item.setTicksLived(1);
	}
}
 
Example #2
Source File: ArmorStandListener.java    From CloudNet with Apache License 2.0 5 votes vote down vote up
@EventHandler
public void handle(ItemDespawnEvent e) {
    MobSelector.MobImpl mob = CollectionWrapper.filter(MobSelector.getInstance().getMobs().values(),
                                                       new Acceptable<MobSelector.MobImpl>() {
                                                           @Override
                                                           public boolean isAccepted(MobSelector.MobImpl value) {
                                                               return ((Entity) value.getDisplayMessage()).getPassenger() != null && e.getEntity()
                                                                                                                                      .getEntityId() == ((Entity) value
                                                                   .getDisplayMessage()).getPassenger().getEntityId();
                                                           }
                                                       });
    if (mob != null) {
        e.setCancelled(true);
    }
}
 
Example #3
Source File: DropProtectListener.java    From NyaaUtils with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onItemDespawn(ItemDespawnEvent e) {
    if (plugin.cfg.dropProtectMode == DropProtectMode.OFF) return;
    Item ent = e.getEntity();
    if (items.getIfPresent(ent.getEntityId()) != null) {
        e.setCancelled(true);
    }
}
 
Example #4
Source File: BonusGoodieManager.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onItemDespawn(ItemDespawnEvent event) {
	BonusGoodie goodie = CivGlobal.getBonusGoodie(event.getEntity().getItemStack());
	if (goodie == null) {
		return;
	}
	
	goodie.replenish(event.getEntity().getItemStack(), event.getEntity(), null, null);	
}
 
Example #5
Source File: CustomItemListener.java    From NBTEditor with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
private void itemDespawnItem(ItemDespawnEvent event) {
	CustomItem customItem = CustomItemManager.getCustomItem(event.getEntity().getItemStack());
	if (verifyCustomItem(customItem, event.getEntity().getWorld())) {
		customItem.onDespawn(event);
	}
}
 
Example #6
Source File: Spawner.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onItemDespawn(ItemDespawnEvent event) {
  if (isTracked(event.getEntity()))
    spawnedEntities -= event.getEntity().getItemStack().getAmount();
}
 
Example #7
Source File: EffectEventHandlers.java    From EliteMobs with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler
public void itemDespawnPrevention(ItemDespawnEvent event) {
    if (EntityTracker.isItemVisualEffect(event.getEntity()))
        event.setCancelled(true);

}
 
Example #8
Source File: KingsCrown.java    From NBTEditor with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onDespawn(ItemDespawnEvent event) {
	if (shouldBroadcastMessage()) {
		UtilsMc.broadcastToWorld(event.getEntity().getWorld(), MessageFormat.format("The {0}§f has been lost forever!", getName()));
	}
}
 
Example #9
Source File: CustomItem.java    From NBTEditor with GNU General Public License v3.0 votes vote down vote up
public void onDespawn(ItemDespawnEvent event) { }