本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
}
}
}
示例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);
}
示例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);
}
}
示例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"));
}
}
示例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());
}
}
示例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());
}
}
}
}
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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);
}
示例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));
}
}
示例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);
}
示例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);
}
}
示例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);
}
}