当前位置: 首页>>代码示例>>Java>>正文


Java EntityPortalEvent.getEntity方法代码示例

本文整理汇总了Java中org.bukkit.event.entity.EntityPortalEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPortalEvent.getEntity方法的具体用法?Java EntityPortalEvent.getEntity怎么用?Java EntityPortalEvent.getEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.entity.EntityPortalEvent的用法示例。


在下文中一共展示了EntityPortalEvent.getEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onEntityPortal

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityPortal(EntityPortalEvent e) {
	if (!cm.portalDisallowEnabled) {
		return;
	}
	Entity entity = e.getEntity();
	if (entity == null || NeverLagUtils.checkCustomNpc(entity)) {
		return;
	}
	if ((entity instanceof Monster && cm.portalDisallowMonster)
		|| (entity instanceof Animals && cm.portalDisallowAnimals)
		|| (entity instanceof Item && cm.portalDisallowItem)
		|| (entity instanceof Projectile && cm.portalDisallowProjectile)) {
		e.setCancelled(true);
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:17,代码来源:ThroughPortalDisabler.java

示例2: onEntityPortalTeleport

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityPortalTeleport(EntityPortalEvent event) {
    if (!(event.getEntity() instanceof Item))
        return;

    ConsoleLogger.debug("[ENTITYPORTALEVENT] A '" + event.getEntity().getName() + "' is going through a portal!");

    String worldFrom = event.getFrom().getWorld().getName();

    // For some reason, event.getTo().getWorld().getName() is sometimes null
    if (event.getTo() == null || event.getTo().getWorld() == null) { // Not gonna bother checking name; its already a WTF that this is needed
        ConsoleLogger.debug("[ENTITYPORTALEVENT] event.getTo().getWorld().getName() would throw a NPE! Exiting method!");
        return;
    }

    String worldTo = event.getTo().getWorld().getName();
    Group from = groupManager.getGroupFromWorld(worldFrom);
    Group to = groupManager.getGroupFromWorld(worldTo);

    // If the groups are different, cancel the event
    if (!from.equals(to)) {
        ConsoleLogger.debug("[ENTITYPORTALEVENT] Group '" + from.getName() + "' and group '" + to.getName() + "' are different! Canceling event!");
        event.setCancelled(true);
    }
}
 
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:26,代码来源:EntityPortalEventListener.java

示例3: onEntityPortal

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityPortal(EntityPortalEvent event) {
    Location portalLoc = null;
    for(BlockFace face : BlockFace.values()) {
        Block block = event.getFrom().getBlock().getRelative(face);
        if(block.getType() == Material.PORTAL || block.getType() == Material.ENDER_PORTAL) {
            portalLoc = block.getLocation();
        }
    }

    if(portalLoc != null) {
        String portal = this.module.getPortalManager().getPortal(portalLoc);
        if(portal != null) {
            event.setCancelled(true);

            if(!(event.getEntity() instanceof Player)) {
                String destPortal = this.module.getPortalManager().getDestPortal(portal);
                if(destPortal != null && this.module.getPortalManager().isPortal(destPortal)) {
                    Location dest = this.module.getPortalManager().getPortalPoint(destPortal);
                    event.getEntity().teleport(dest);
                }
            }
        }
    }
}
 
开发者ID:Steveice10,项目名称:Peacecraft,代码行数:26,代码来源:PortalListener.java

示例4: onEntityPortal

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
/**
    * This handles non-player portal use
    * Currently disables portal use by entities
    * 
    * @param event
    */
   @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false)
   public void onEntityPortal(EntityPortalEvent event) {
// If the nether is disabled then quit immediately
if (!Settings.createNether) {
    return;
}
if (event.getEntity() == null) {
    return;
}
// If this is not ASkyGrid then return
if (!event.getFrom().getWorld().equals(ASkyGrid.getGridWorld()) && !event.getFrom().getWorld().equals(ASkyGrid.getNetherWorld())) {
    return;
}
// Entities don't go through sky grid portals, sorry.
event.setCancelled(true);
   }
 
开发者ID:tastybento,项目名称:askygrid,代码行数:23,代码来源:NetherPortals.java

示例5: onEntityPortal

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityPortal(EntityPortalEvent e) {
	if (!cm.isAntiMinecartPortal) {
		return;
	}
	if (e.getEntity() instanceof Minecart) {
		e.setCancelled(true);
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:10,代码来源:AntiMinecartPortal.java

示例6: onPortalUse

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPortalUse(EntityPortalEvent event) {
    event.setCancelled(true);

    Entity creator = event.getEntity();
    if (creator instanceof Player) {
        creator.sendMessage(String.format(PORTAL_MESSAGE, "use"));
    }
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:10,代码来源:GeneralListeners.java

示例7: teleportEntity

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
public static void teleportEntity(final EntityPortalEvent event, final Location location) {
	checkChunkLoad(location.getBlock());
	final Entity entity = event.getEntity();

	if (entity.getType().isSpawnable() && !EntityUtil.isEchoPet(entity)) {
		entity.teleport(location);
	} else if (entity.getType() == EntityType.DROPPED_ITEM) {
		entity.remove();
		location.getWorld().dropItemNaturally(location, ((Item) entity).getItemStack());
	}

}
 
开发者ID:NoChanceSD,项目名称:AncientGates,代码行数:13,代码来源:TeleportUtil.java

示例8: onEntityPortal

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityPortal(final EntityPortalEvent event) {
	if (event.isCancelled()) {
		return;
	}
	if (!(event.getEntity() instanceof Player) && !(event.getEntity().getPassenger() instanceof Player)) {
		// Ok so an entity portal event begins
		// Find the nearest gate!
		final WorldCoord entityCoord = new WorldCoord(event.getEntity().getLocation());
		final Gate nearestGate = GateUtil.nearestGate(entityCoord, true);

		if (nearestGate != null) {
			event.setCancelled(true);

			/*
			 * Teleport non-living vehicles - Only when useVanillaPortals is enabled Boolean
			 * Expression: Rtrn = VanilFlag' InstVeh InstLiv';
			 */
			if (!Conf.useVanillaPortals && event.getEntity() instanceof Vehicle && !(event.getEntity() instanceof LivingEntity)) {
				return;
			}

			/*
			 * Teleport entities (incl. living vehicles) - If they're allowed Teleport
			 * non-living vehicles if they're allowed Boolean Expression: Tele = EntFlag
			 * InstVeh' + EntFlag InstLiv + VehFlag InstVeh InstLiv';
			 */
			if (nearestGate.getTeleportEntities() && !(event.getEntity() instanceof Vehicle) || nearestGate.getTeleportEntities() && event.getEntity() instanceof LivingEntity
					|| nearestGate.getTeleportVehicles() && event.getEntity() instanceof Vehicle && !(event.getEntity() instanceof LivingEntity)) {
				if (nearestGate.getBungeeTo() == null) {
					TeleportUtil.teleportEntity(event, nearestGate.getTo());
				} else {
					TeleportUtil.teleportEntity(event, nearestGate.getBungeeTo());
				}
			}
		}
	}
}
 
开发者ID:NoChanceSD,项目名称:AncientGates,代码行数:39,代码来源:PluginEntityListener.java

示例9: onPortalEvent

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
@EventHandler
public void onPortalEvent(EntityPortalEvent epe)
{
    //if it's enabled
    if(isEnabled() && epe.getEntity() instanceof Permissible) {
        //if they're going into the nether cancel it
        if(!((Permissible) epe.getEntity()).hasPermission(ALLOW_NETHER)) {
            if(epe.getTo().getWorld().getEnvironment() == World.Environment.NETHER) {
                epe.setCancelled(true);
            }
        }
    }
}
 
开发者ID:Eluinhost,项目名称:ultrahardcore,代码行数:14,代码来源:NetherFeature.java

示例10: EntityPortalEvent

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void EntityPortalEvent(EntityPortalEvent  event)
{
	if (event.getEntityType() == EntityType.VILLAGER)
    {
        final Entity villager = event.getEntity();
        TradeCraftVillager tcv = Villagers.getVillager(villager.getUniqueId().toString());
        if(tcv != null)
        {
        	Logs.debug("Portal enter " + tcv.getUUID());
        	tcv.setPortaling(true);
        }
    }
}
 
开发者ID:CoreNetwork,项目名称:TradeCraft,代码行数:15,代码来源:TradeCraftListener.java

示例11: onEntityPortal

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityPortal(EntityPortalEvent e) {
	if(e.isCancelled()) {
		return;
	}

	e.setCancelled(true);

	Block block = getPortalNearby(e.getEntity().getLocation().getBlock());
	if(!(block instanceof Block)) {
		return;
	}
	for(Portal portal : pl.getConfiguration().getPortalConfig().getPortals().values()) {
		if(portal.getInnerBlocks().contains(block)) {
			if(e.getEntity() instanceof Item) {
				e.setCancelled(true);
				return;
			}
			e.useTravelAgent(false);
			if(portal.isLinked()) {
				Portal linked = portal.getLinkedPortal();
				if(!(linked instanceof Portal)) {
					e.setCancelled(true);
					return;
				}
				e.setTo(linked.getInnerBlocks().get(linked.getInnerBlocks().size()-1).getLocation());
				e.setCancelled(false);
			} else {
				e.setCancelled(true);
			}
			break;
		}
	}
	e.setCancelled(false);
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:36,代码来源:PortalEvent.java

示例12: onPortalTravel

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
@EventHandler
public void onPortalTravel(EntityPortalEvent e)
{
    if(!(e.getEntity() instanceof Player))
    {
        e.setCancelled(true);
        e.getEntity().teleport(e.getEntity().getLocation().add(0,15,0));
    }
}
 
开发者ID:janie177,项目名称:MausWasHere,代码行数:10,代码来源:EntityListener.java

示例13: onEntityPortal

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
/**
 * This handles non-player portal use
 * Currently disables portal use by entities
 *
 * @param event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityPortal(EntityPortalEvent event) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: nether portal entity " + event.getFrom().getBlock().getType());
    // If the nether is disabled then quit immediately
    if (!Settings.netherGenerate || IslandWorld.getNetherWorld() == null) {
        return;
    }
    if (event.getEntity() == null) {
        return;
    }
    if (event.getFrom() != null && event.getFrom().getBlock().getType().equals(Material.ENDER_PORTAL)) {
        event.setCancelled(true);
        // Same action for all worlds except the end itself
        if (!event.getFrom().getWorld().getEnvironment().equals(Environment.THE_END)) {
            if (plugin.getServer().getWorld(Settings.worldName + "_the_end") != null) {
                // The end exists
                Location end_place = plugin.getServer().getWorld(Settings.worldName + "_the_end").getSpawnLocation();
                event.getEntity().teleport(end_place);
                if (DEBUG)
                    plugin.getLogger().info("DEBUG: Result teleported " + event.getEntityType() + " to " + end_place);
                return;
            }
        }
        return;
    }
    Location currentLocation = event.getFrom().clone();
    String currentWorld = currentLocation.getWorld().getName();
    // Only operate if this is Island territory
    if (!currentWorld.equalsIgnoreCase(Settings.worldName) && !currentWorld.equalsIgnoreCase(Settings.worldName + "_nether")) {
        return;
    }
    // No entities may pass with the old nether
    if (!Settings.netherIslands) {
        event.setCancelled(true);
        return;
    }
    // New nether
    // Entities can pass only if there are adjoining portals
    Location dest = event.getFrom().toVector().toLocation(IslandWorld.getIslandWorld());
    if (event.getFrom().getWorld().getEnvironment().equals(Environment.NORMAL)) {
        dest = event.getFrom().toVector().toLocation(IslandWorld.getNetherWorld());
    }
    // Vehicles
    if (event.getEntity() instanceof Vehicle) {
        Vehicle vehicle = (Vehicle)event.getEntity();
        vehicle.eject();
    }
    new SafeSpotTeleport(plugin, event.getEntity(), dest);
    event.setCancelled(true);
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:58,代码来源:NetherPortals.java

示例14: onEntityPortal

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onEntityPortal(EntityPortalEvent event) {
    if (event.getEntity() instanceof EnderDragon) {
        event.setCancelled(true);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:7,代码来源:PortalListener.java

示例15: onEntityPortalEnter

import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onEntityPortalEnter(EntityPortalEvent event) {
    if (event.getEntity() instanceof EnderDragon) {
        event.setCancelled(true);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:7,代码来源:WorldListener.java


注:本文中的org.bukkit.event.entity.EntityPortalEvent.getEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。