org.bukkit.event.entity.ItemSpawnEvent Java Examples

The following examples show how to use org.bukkit.event.entity.ItemSpawnEvent. 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: BonusGoodieManager.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR) 
public void OnItemSpawn(ItemSpawnEvent event) {
	Item item = event.getEntity();
	
	BonusGoodie goodie = CivGlobal.getBonusGoodie(item.getItemStack());
	if (goodie == null) {
		return;
	}
	
	// Cant validate here, validate in drop item events...
	goodie.setItem(item);
	try {
		goodie.update(false);
		goodie.updateLore(item.getItemStack());
	} catch (CivException e) {
		e.printStackTrace();
	}
}
 
Example #2
Source File: CustomItemManager.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void OnItemSpawn(ItemSpawnEvent event) {
	ItemStack stack = event.getEntity().getItemStack();

	if (LoreMaterial.isCustom(stack)) {
		LoreMaterial.getMaterial(stack).onItemSpawn(event);
	}
	
	if (isUnwantedVanillaItem(stack)) {
		if (!stack.getType().equals(Material.HOPPER) && 
				!stack.getType().equals(Material.HOPPER_MINECART)) {		
			event.setCancelled(true);
			event.getEntity().remove();
		}
	}
}
 
Example #3
Source File: ChunkListener.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event) {
    if (physicsFreeze) {
        event.setCancelled(true);
        return;
    }
    Location loc = event.getLocation();
    int cx = loc.getBlockX() >> 4;
    int cz = loc.getBlockZ() >> 4;
    int[] count = getCount(cx, cz);
    if (count[2] >= Settings.IMP.TICK_LIMITER.ITEMS) {
        event.setCancelled(true);
        return;
    }
    if (++count[2] >= Settings.IMP.TICK_LIMITER.ITEMS) {
        cleanup(loc.getChunk());
        cancelNearby(cx, cz);
        if (rateLimit <= 0) {
            rateLimit = 20;
            Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled item lag source at " + loc);
        }
        event.setCancelled(true);
        return;
    }
}
 
Example #4
Source File: MainListener.java    From HolographicDisplays with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = false)
public void onItemSpawn(ItemSpawnEvent event) {
	if (nmsManager.isNMSEntityBase(event.getEntity())) {
		if (event.isCancelled()) {
			event.setCancelled(false);
		}
	}
}
 
Example #5
Source File: LoreCraftableMaterial.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onItemSpawn(ItemSpawnEvent event) {
	for (ItemComponent comp : this.components.values()) {
		comp.onItemSpawn(event);
	}
	
}
 
Example #6
Source File: DisableShulkerboxes.java    From Minepacks with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onItemSpawn(ItemSpawnEvent event)
{
	if(SHULKER_BOX_MATERIALS.contains(event.getEntity().getItemStack().getType()))
	{
		event.setCancelled(true);
	}
}
 
Example #7
Source File: DWorldListener.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
    if (plugin.getGameWorld(event.getLocation().getWorld()) != null) {
        if (Category.SIGNS.containsItem(event.getEntity().getItemStack())) {
            event.setCancelled(true);
        }
    }
}
 
Example #8
Source File: BowlessListener.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onItemSpawn(ItemSpawnEvent e) {
    ItemStack item = e.getEntity().getItemStack();

    if ((item.getType().equals(Material.BOW) || item.getType().equals(Material.ARROW))) {
        e.setCancelled(true);
    }
}
 
Example #9
Source File: ItemModifyMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
    ItemStack stack = event.getEntity().getItemStack();
    if(applyRules(stack)) {
        event.getEntity().setItemStack(stack);
    }
}
 
Example #10
Source File: ItemDestroyMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void processItemRemoval(ItemSpawnEvent event) {
    final ItemStack item = event.getEntity().getItemStack();
    if(patterns.stream().anyMatch(pattern -> pattern.matches(item))) {
        event.setCancelled(true);
    }
}
 
Example #11
Source File: ItemModifyMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
  ItemStack stack = event.getEntity().getItemStack();
  if (applyRules(stack)) {
    event.getEntity().setItemStack(stack);
  }
}
 
Example #12
Source File: ItemDestroyMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void processItemRemoval(ItemSpawnEvent event) {
  ItemStack item = event.getEntity().getItemStack();
  for (BlockFilter filter : this.itemsToRemove) {
    if (filter.matches(item.getType(), item.getData().getData())) {
      event.setCancelled(true);
    }
  }
}
 
Example #13
Source File: FlagObjective.java    From CardinalPGM with MIT License 4 votes vote down vote up
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
    if (event.getEntity().getItemStack().equals(bannerItem)) {
        event.getEntity().remove();
    }
}
 
Example #14
Source File: ItemRemove.java    From CardinalPGM with MIT License 4 votes vote down vote up
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
    ItemStack itemStack = event.getEntity().getItemStack();
    if (itemStack.getType().equals(item.getMaterial()) && (itemStack.getDurability() == item.getData() || item.getData() < 0))
        event.setCancelled(true);
}
 
Example #15
Source File: TutorialBook.java    From civcraft with GNU General Public License v2.0 4 votes vote down vote up
public void onItemSpawn(ItemSpawnEvent event) {
	event.setCancelled(true);
}
 
Example #16
Source File: UnitItemMaterial.java    From civcraft with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onItemSpawn(ItemSpawnEvent event) {
	// Never let these spawn as items.
	event.setCancelled(true);
	
}
 
Example #17
Source File: EntityEventHandler.java    From GriefDefender with MIT License 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event) {
    handleEntitySpawn(event, null, event.getEntity());
}
 
Example #18
Source File: DisableXPListener.java    From civcraft with GNU General Public License v2.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
	public void onItemSpawnEvent(ItemSpawnEvent event) {
//		if (event.getEntity().getType().equals(EntityType.EXPERIENCE_ORB)) {
//			event.setCancelled(true);
//		}
	}
 
Example #19
Source File: ThreadSafetyListener.java    From LagMonitor with MIT License 4 votes vote down vote up
@EventHandler
public void onItemSpawn(ItemSpawnEvent itemSpawnEvent) {
    checkSafety(itemSpawnEvent);
}
 
Example #20
Source File: HologramListener.java    From Holograms with MIT License 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onItemSpawn(ItemSpawnEvent event) {
    if (event.isCancelled() && plugin.getEntityController().getHologramEntity(event.getEntity()) != null) {
        event.setCancelled(false);
    }
}
 
Example #21
Source File: ThreadSafetyListener.java    From LagMonitor with MIT License 4 votes vote down vote up
@EventHandler
public void onItemSpawn(ItemSpawnEvent itemSpawnEvent) {
    checkSafety(itemSpawnEvent);
}
 
Example #22
Source File: QuickShop.java    From QuickShop-Reremake with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Load 3rdParty plugin support module.
 */
private void load3rdParty() {
    // added for compatibility reasons with OpenInv - see
    // https://github.com/KaiKikuchi/QuickShop/issues/139
    if (getConfig().getBoolean("plugin.OpenInv")) {
        this.openInvPlugin = Bukkit.getPluginManager().getPlugin("OpenInv");
        if (this.openInvPlugin != null) {
            getLogger().info("Successfully loaded OpenInv support!");
        }
    }
    if (getConfig().getBoolean("plugin.PlaceHolderAPI")) {
        this.placeHolderAPI = Bukkit.getPluginManager().getPlugin("PlaceholderAPI");
        if (this.placeHolderAPI != null) {
            getLogger().info("Successfully loaded PlaceHolderAPI support!");
        }
    }
    if (getConfig().getBoolean("plugin.BlockHub")) {
        this.blockHubPlugin = Bukkit.getPluginManager().getPlugin("BlockHub");
        if (this.blockHubPlugin != null) {
            getLogger().info("Successfully loaded BlockHub support!");
        }
    }
    if (getConfig().getBoolean("plugin.LWC")) {
        this.lwcPlugin = Bukkit.getPluginManager().getPlugin("LWC");
        if (this.lwcPlugin != null) {
            getLogger().info("Successfully loaded LWC support!");
        }
    }
    if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
        compatibilityTool.register(new NCPCompatibilityModule(this));
    }
    if (this.display) {
        //VirtualItem support
        if (DisplayItem.getNowUsing() == DisplayType.VIRTUALITEM) {
            getLogger().info("Using Virtual item Display, loading ProtocolLib support...");
            Plugin protocolLibPlugin = Bukkit.getPluginManager().getPlugin("ProtocolLib");
            if (protocolLibPlugin != null && protocolLibPlugin.isEnabled()) {
                getLogger().info("Successfully loaded ProtocolLib support!");
            } else {
                getLogger().warning("Failed to load ProtocolLib support, fallback to real item display");
                getConfig().set("shop.display-type", 0);
                saveConfig();
            }
        }

        if (DisplayItem.getNowUsing() != DisplayType.VIRTUALITEM && Bukkit.getPluginManager().getPlugin("ClearLag") != null) {
            try {
                Clearlag clearlag = (Clearlag) Bukkit.getPluginManager().getPlugin("ClearLag");
                for (RegisteredListener clearLagListener : ItemSpawnEvent.getHandlerList().getRegisteredListeners()) {
                    if (!clearLagListener.getPlugin().equals(clearlag)) {
                        continue;
                    }
                    int spamTimes = 20;
                    if (clearLagListener.getListener().getClass().equals(ItemMergeListener.class)) {
                        ItemSpawnEvent.getHandlerList().unregister(clearLagListener.getListener());
                        for (int i = 0; i < spamTimes; i++) {
                            getLogger().warning("+++++++++++++++++++++++++++++++++++++++++++");
                            getLogger().severe("Detected incompatible module of ClearLag-ItemMerge module, it will broken the QuickShop display, we already unregister this module listener!");
                            getLogger().severe("Please turn off it in the ClearLag config.yml or turn off the QuickShop display feature!");
                            getLogger().severe("If you didn't do that, this message will keep spam in your console every times you server boot up!");
                            getLogger().warning("+++++++++++++++++++++++++++++++++++++++++++");
                            getLogger().info("This message will spam more " + (spamTimes - i) + " times!");
                        }
                    }
                }
            } catch (Throwable ignored) {
            }
        }
    }
}
 
Example #23
Source File: RareDropEffect.java    From EliteMobs with GNU General Public License v3.0 3 votes vote down vote up
@EventHandler
public void onItemDrop(ItemSpawnEvent event) {

    if (!ObfuscatedSignatureLoreData.obfuscatedSignatureDetector(event.getEntity().getItemStack())) return;

    runEffect(event.getEntity());

}
 
Example #24
Source File: UnitMaterial.java    From civcraft with GNU General Public License v2.0 2 votes vote down vote up
@Override
public void onItemSpawn(ItemSpawnEvent event) {
	
}
 
Example #25
Source File: LoreMaterial.java    From civcraft with GNU General Public License v2.0 votes vote down vote up
public abstract void onItemSpawn(ItemSpawnEvent event); 
Example #26
Source File: ItemComponent.java    From civcraft with GNU General Public License v2.0 votes vote down vote up
public void onItemSpawn(ItemSpawnEvent event) {}