本文整理汇总了Java中org.bukkit.event.entity.ItemSpawnEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java ItemSpawnEvent.getEntity方法的具体用法?Java ItemSpawnEvent.getEntity怎么用?Java ItemSpawnEvent.getEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.ItemSpawnEvent
的用法示例。
在下文中一共展示了ItemSpawnEvent.getEntity方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onItemSpawn(final ItemSpawnEvent event) {
if (event.isCancelled())
return;
final Entity item = event.getEntity();
if (item.getType() != EntityType.DROPPED_ITEM || ((Item) item).getItemStack().getType() != Material.SUGAR_CANE)
return;
// Stop sugarcane block from decaying (workaround for lack of 1.7.2-R0.1 physics support)
final WorldCoord coord = new WorldCoord((Item) item);
final Gate nearestGate = Gates.gateFromPortal(coord);
if (nearestGate != null) {
if (nearestGate.getMaterial() != Material.SUGAR_CANE_BLOCK)
return;
event.getEntity().remove();
plugin.getServer().getScheduler().scheduleSyncDelayedTask(Plugin.instance, new Runnable() {
@Override
public void run() {
coord.getBlock().setType(Material.SUGAR_CANE_BLOCK);
}
}, 1);
}
}
示例2: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event) {
Item entity = event.getEntity();
Chunk chunk = entity.getLocation().getChunk();
if (chunk == lastChunk) {
event.getEntity().remove();
event.setCancelled(true);
return;
}
if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) {
return;
}
Entity[] entities = chunk.getEntities();
if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) {
event.getEntity().remove();
event.setCancelled(true);
lastChunk = chunk;
}
else {
lastChunk = null;
}
}
示例3: OnItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@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();
}
}
示例4: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event) {
Item entity = event.getEntity();
Chunk chunk = entity.getLocation().getChunk();
if (chunk == this.lastChunk) {
event.getEntity().remove();
event.setCancelled(true);
return;
}
if (!PS.get().hasPlotArea(chunk.getWorld().getName())) {
return;
}
Entity[] entities = chunk.getEntities();
if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
event.getEntity().remove();
event.setCancelled(true);
this.lastChunk = chunk;
} else {
this.lastChunk = null;
}
}
示例5: onDrop
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onDrop(ItemSpawnEvent event)
{
if(event.isCancelled()) return;
final Item itemDrop = event.getEntity();
if(itemDrop.getItemStack().getType() == Material.BOWL)
{
final Runnable task = new Runnable()
{
public void run()
{
if(itemDrop.getItemStack().getAmount() != 1) return;
Location itemLocation = itemDrop.getLocation();
if(itemLocation.getBlock().getType() == Material.WATER || itemLocation.getBlock().getType() == Material.STATIONARY_WATER)
{
itemDrop.remove();
ItemStack i_beetroot = new ItemStack(Material.BEETROOT_SOUP, 1);
ItemMeta beetrootMeta= i_beetroot.getItemMeta();
beetrootMeta.setDisplayName(ChatColor.RESET + Survival.instance.Words.get("Water Bowl"));
i_beetroot.setItemMeta(beetrootMeta);
itemDrop.getWorld().dropItem(itemLocation, i_beetroot);
}
}
};
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Survival.instance, task, 20L);
}
}
示例6: onGhastTearSlimeBlock
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onGhastTearSlimeBlock(ItemSpawnEvent e)
{
if(e.getEntityType() == EntityType.DROPPED_ITEM)
{
Item i = (Item)e.getEntity();
switch(i.getItemStack().getType())
{
case GHAST_TEAR:
Bukkit.getScheduler().runTaskLater(Survival.instance, initRunnable(i), 20);
break;
default:
}
}
}
示例7: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
Item item = event.getEntity();
ItemStack stack = item.getItemStack();
World world = item.getWorld();
if (world.getEnvironment() != Environment.THE_END || stack.getType() != Material.DRAGON_EGG
|| stack.hasItemMeta()) return;
DragonTemplate dragon = plugin.getDEDManager().getWorldWrapper(world).getActiveBattle();
DragonLoot loot = dragon.getLoot();
String eggName = loot.getEggName().replace("%dragon%", dragon.getName());
List<String> eggLore = loot.getEggLore().stream()
.map(s -> s.replace("%dragon%", dragon.getName()))
.collect(Collectors.toList());
ItemMeta eggMeta = stack.getItemMeta();
if (eggName != null && !eggName.isEmpty()) {
eggMeta.setDisplayName(eggName);
}
if (eggLore != null && !eggLore.isEmpty()) {
eggMeta.setLore(eggLore);
}
stack.setItemMeta(eggMeta);
}
示例8: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemSpawn(ItemSpawnEvent e) {
if (e.isCancelled()) {
return;
}
Item item = e.getEntity();
ItemStack is = item.getItemStack();
if (isMoneyItem(is)) {
item.setCustomName(is.getItemMeta().getDisplayName());
item.setCustomNameVisible(true);
}
}
示例9: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
* Track the location of a pearl if it spawns as an item for any reason
* @param e The event args
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onItemSpawn(ItemSpawnEvent e) {
Item item = e.getEntity();
ExilePearl pearl = pearlApi.getPearlFromItemStack(item.getItemStack());
if (pearl == null) {
return;
}
pearl.setHolder(item);
}
示例10: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onItemSpawn(ItemSpawnEvent event)
{
if (!data.getChestCache().isChestListEmpty() && event.getEntity() instanceof Item )//&& plugin.worldSet.contains(event.getEntity().getWorld().getName()))
{
for (Loc loc : data.getChestCache().getChestList())
{
Location l = loc.toLocation();
if (event.getEntity().getLocation().getWorld().getName().equals(l.getWorld().getName()) && l.distanceSquared(event.getEntity().getLocation()) < 4)
{
((Item) event.getEntity()).setPickupDelay(20);
}
}
}
}
示例11: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
* Concentrate stacks
*
* @param event Event
*/
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
if (event.getEntityType() != EntityType.DROPPED_ITEM)
return;
Item newEntity = event.getEntity();
List<Entity> entityList = newEntity.getNearbyEntities(this.radius, 1, this.radius);
int maxSize = newEntity.getItemStack().getMaxStackSize();
for (Entity anEntityList : entityList)
{
if (anEntityList instanceof Item)
{
Item curEntity = (Item) anEntityList;
if (!curEntity.isDead()
&& curEntity.getItemStack().getType().equals(newEntity.getItemStack().getType())
&& curEntity.getItemStack().getData().getData() == newEntity.getItemStack().getData().getData()
&& curEntity.getItemStack().getDurability() == newEntity.getItemStack().getDurability()
&& Math.abs(curEntity.getLocation().getX() - newEntity.getLocation().getX()) <= this.radius
&& Math.abs(curEntity.getLocation().getY() - newEntity.getLocation().getY()) <= this.radius
&& Math.abs(curEntity.getLocation().getZ() - newEntity.getLocation().getZ()) <= this.radius)
{
int newAmount = newEntity.getItemStack().getAmount();
int curAmount = curEntity.getItemStack().getAmount();
int more = Math.min(newAmount, maxSize - curAmount);
curAmount += more;
newAmount -= more;
curEntity.getItemStack().setAmount(curAmount);
newEntity.getItemStack().setAmount(newAmount);
if (newAmount <= 0)
event.setCancelled(true);
return;
}
}
}
}
示例12: onSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onSpawn(ItemSpawnEvent e) {
if (cm.isAntiNegativeItemDupe && e.getEntity() != null && e.getEntity().getItemStack() != null && e.getEntity().getItemStack().getAmount() <= 0) {
e.setCancelled(true);
}
}