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


Java EntityPortalEvent类代码示例

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


EntityPortalEvent类属于org.bukkit.event.entity包,在下文中一共展示了EntityPortalEvent类的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: shouldTeleportBecauseNotItem

import org.bukkit.event.entity.EntityPortalEvent; //导入依赖的package包/类
@Test
public void shouldTeleportBecauseNotItem() {
    // given
    Pig entity = mock(Pig.class);
    World world = mock(World.class);
    Location from = new Location(world, 1, 2, 3);
    World worldNether = mock(World.class);
    Location to = new Location(worldNether, 1, 2, 3);
    EntityPortalEvent event = new EntityPortalEvent(entity, from, to, mock(TravelAgent.class));

    // when
    listener.onEntityPortalTeleport(event);

    // then
    assertThat(event.isCancelled(), equalTo(false));
}
 
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:17,代码来源:EntityPortalEventListenerTest.java

示例4: shouldTeleportBecauseSameGroup

import org.bukkit.event.entity.EntityPortalEvent; //导入依赖的package包/类
@Test
public void shouldTeleportBecauseSameGroup() {
    // given
    Group group = mockGroup("test_group", GameMode.SURVIVAL, false);

    Item entity = mock(Item.class);

    World world = mock(World.class);
    given(world.getName()).willReturn("test_group");
    Location from = new Location(world, 1, 2, 3);

    World worldNether = mock(World.class);
    given(worldNether.getName()).willReturn("test_group_nether");
    Location to = new Location(worldNether, 1, 2, 3);

    given(groupManager.getGroupFromWorld("test_group")).willReturn(group);
    given(groupManager.getGroupFromWorld("test_group_nether")).willReturn(group);

    EntityPortalEvent event = new EntityPortalEvent(entity, from, to, mock(TravelAgent.class));

    // when
    listener.onEntityPortalTeleport(event);

    // then
    assertThat(event.isCancelled(), equalTo(false));
}
 
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:27,代码来源:EntityPortalEventListenerTest.java

示例5: 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

示例6: 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

示例7: onItemPortal

import org.bukkit.event.entity.EntityPortalEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onItemPortal(final EntityPortalEvent event) {
    this.plugin.entering(this.getClass(), "onItemPortal");
    final Location loc = event.getEntity().getLocation();
    final Altar altar = this.plugin.getAltars().get(new ChunkCoord(loc.getChunk()));
    if (altar != null && altar.getState() == AltarState.EGG_PROVIDED && event.getEntity().isValid()) {
        this.plugin.debug("Teleportation caused by an Altar.");
        if (event.getEntityType() == EntityType.DROPPED_ITEM) {
            this.plugin.debug("Teleporting entity is a Dropped Item, handling it...");
            altar.getBuilder().addItem(((Item)event.getEntity()).getItemStack());
            event.getEntity().remove();
            this.plugin.debug("Entity handled by an Altar. Location=" + altar.getCenterLocation());
        }
        this.plugin.debug("Entity not an item, not handled");
        event.setCancelled(true);
    } else {
        this.plugin.debug("Entity not handled");
    }
    this.plugin.exiting(this.getClass(), "onItemPortal");
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:21,代码来源:ItemListener.java

示例8: PortalCheck

import org.bukkit.event.entity.EntityPortalEvent; //导入依赖的package包/类
@EventHandler
public void PortalCheck(EntityPortalEvent event) {
    if (ConfigPatch.fixPortalInfItem) {
        if (event.getEntityType() == EntityType.MINECART_CHEST || event.getEntityType() == EntityType.MINECART_FURNACE || event.getEntityType() == EntityType.MINECART_HOPPER) {
            event.setCancelled(true);
            event.getEntity().remove();
            AzureAPI.bc(ConfigPatch.AntiPortalInfItemWarnMessage);
        }
    }
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:11,代码来源:AntiPortalInfItem.java

示例9: 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

示例10: get

import org.bukkit.event.entity.EntityPortalEvent; //导入依赖的package包/类
@Override
protected Location[] get(Event event) {
    if (event instanceof PlayerPortalEvent) {
        return new Location[]{createPortal(targetLoc.getSingle(event), radius.getSingle(event).intValue(), ((PlayerPortalEvent) event).getPortalTravelAgent())};
    } else if (event instanceof EntityPortalEvent) {
        return new Location[]{createPortal(targetLoc.getSingle(event), radius.getSingle(event).intValue(), ((EntityPortalEvent) event).getPortalTravelAgent())};
    }
    throw new IllegalArgumentException("The event " + event + " should be a PlayerPortalEvent or EntityPortalEvent");

}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:11,代码来源:ExprNewPortal.java

示例11: init

import org.bukkit.event.entity.EntityPortalEvent; //导入依赖的package包/类
@Override
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
    if (!ScriptLoader.isCurrentEvent(PlayerPortalEvent.class, EntityPortalEvent.class)) {
        Skript.error("'new nether portal' can only be used in an 'on teleport' event!");
        return false;
    }
    radius = (Expression<Number>) expressions[0];
    targetLoc = (Expression<Location>) expressions[1];
    return false;
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:11,代码来源:ExprNewPortal.java

示例12: 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

示例13: shouldNotTeleportBecauseDifferentGroups

import org.bukkit.event.entity.EntityPortalEvent; //导入依赖的package包/类
@Test
public void shouldNotTeleportBecauseDifferentGroups() {
    // given
    Group group = mockGroup("test_group", GameMode.SURVIVAL, false);
    Group otherGroup = mockGroup("other_group", GameMode.SURVIVAL, false);

    Item entity = mock(Item.class);

    World world = mock(World.class);
    given(world.getName()).willReturn("test_group");
    Location from = new Location(world, 1, 2, 3);

    World worldNether = mock(World.class);
    given(worldNether.getName()).willReturn("other_group_nether");
    Location to = new Location(worldNether, 1, 2, 3);

    given(groupManager.getGroupFromWorld("test_group")).willReturn(group);
    given(groupManager.getGroupFromWorld("other_group_nether")).willReturn(otherGroup);

    EntityPortalEvent event = new EntityPortalEvent(entity, from, to, mock(TravelAgent.class));

    // when
    listener.onEntityPortalTeleport(event);

    // then
    assertThat(event.isCancelled(), equalTo(true));
}
 
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:28,代码来源:EntityPortalEventListenerTest.java

示例14: 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

示例15: 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


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