Java Code Examples for org.bukkit.event.entity.ItemDespawnEvent#setCancelled()

The following examples show how to use org.bukkit.event.entity.ItemDespawnEvent#setCancelled() . 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: 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);

}