本文整理汇总了Java中org.bukkit.event.entity.EntitySpawnEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java EntitySpawnEvent.getEntity方法的具体用法?Java EntitySpawnEvent.getEntity怎么用?Java EntitySpawnEvent.getEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.EntitySpawnEvent
的用法示例。
在下文中一共展示了EntitySpawnEvent.getEntity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDragonSpawn
import org.bukkit.event.entity.EntitySpawnEvent; //导入方法依赖的package包/类
/**
* This handles end dragon spawning
*
* @param event
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onDragonSpawn(EntitySpawnEvent event) {
if (!Settings.createEnd) {
return;
}
if (!event.getLocation().getWorld().equals(ASkyGrid.getEndWorld())) {
return;
}
if (event.getEntityType().equals(EntityType.ENDER_DRAGON)) {
//plugin.getLogger().info("DEBUG: removing ender dragon");
LivingEntity dragon = (LivingEntity)event.getEntity();
dragon.setHealth(0);
event.getEntity().remove();
event.setCancelled(true);
}
}
示例2: onEntitySpawn
import org.bukkit.event.entity.EntitySpawnEvent; //导入方法依赖的package包/类
/**
* Handles entity spawning
*
* @param e an event representing a spawned entity
* @see EntitySpawnEvent
* @since 2.1.0
*/
@EventHandler(ignoreCancelled = true)
public void onEntitySpawn(EntitySpawnEvent e) {
Entity entity = e.getEntity();
Plot plot;
if ((plot = Plot.getPlot(entity.getLocation())) != null) {
if (!plot.addEntity(entity))
entity.remove();
}
}
示例3: creatureSpawnEvent
import org.bukkit.event.entity.EntitySpawnEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void creatureSpawnEvent(EntitySpawnEvent event) {
Entity entity = event.getEntity();
Location location = BukkitUtil.getLocation(entity.getLocation());
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
Plot plot = area.getOwnedPlotAbs(location);
if (plot == null) {
if (!area.MOB_SPAWNING) {
if (event.getEntityType().isAlive() || !area.MISC_SPAWN_UNOWNED) {
event.setCancelled(true);
}
}
return;
}
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
event.setCancelled(true);
}
switch (entity.getType()) {
case ENDER_CRYSTAL:
if (PlayerEvents.checkEntity(entity, plot)) {
event.setCancelled(true);
}
case SHULKER:
if(!entity.hasMetadata("plot")) {
entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot.getId()));
}
}
}
示例4: onSpawn
import org.bukkit.event.entity.EntitySpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onSpawn(EntitySpawnEvent event)
{
//plugin.getLogger().info("SPAWN EVENT!");
if(event.getEntity() instanceof EnderCrystal)
{
ItemBox itemBox = plugin.getItemBoxRegistry().getByLocation(event.getLocation().getBlock().getLocation());
if(itemBox != null && !itemBox.getEnderCrystal().equals(event.getEntity()))
{
event.setCancelled(true);
}
}
}
示例5: onSpawn
import org.bukkit.event.entity.EntitySpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onSpawn(EntitySpawnEvent e) {
if (e.getEntity() instanceof Animals) e.setCancelled(true);
}