本文整理汇总了Java中org.bukkit.event.entity.EntityPortalEvent.getEntityType方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPortalEvent.getEntityType方法的具体用法?Java EntityPortalEvent.getEntityType怎么用?Java EntityPortalEvent.getEntityType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.EntityPortalEvent
的用法示例。
在下文中一共展示了EntityPortalEvent.getEntityType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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");
}
示例2: 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);
}
}
}
示例3: 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);
}
}
}
示例4: teleportEntity
import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
public static void teleportEntity(final EntityPortalEvent event, final Map<String, String> location) {
if (Conf.bungeeCordSupport && (event.getEntityType().isSpawnable() && !EntityUtil.isEchoPet(event.getEntity()) || event.getEntityType() == EntityType.DROPPED_ITEM)) {
// Send spawn command packet via BungeeCord
if (!Conf.useSocketComms || Plugin.serv == null) {
// Send AGBungeeSpawn packet
final PluginMessage msg = new PluginMessage(event.getEntityType(), event.getEntity(), location);
// Send over the AGBungeeTele BungeeCord channel
if (Plugin.instance.getServer().getOnlinePlayers().size() > 0) {
// Use any player to send the plugin message
Iterables.getFirst(Bukkit.getOnlinePlayers(), null).sendPluginMessage(Plugin.instance, "BungeeCord", msg.toByteArray());
// Imitate teleport by removing entity
event.getEntity().remove();
}
// Send spawn command packet via client socket
} else if (!entityCache.asMap().containsKey(event.getEntity().getEntityId())) {
// Put entity in cache so we don't end up with duplicate entities
entityCache.put(event.getEntity().getEntityId(), event.getEntity());
// Get server
final Server server = Server.get(location.get(SERVER));
// Construct spawn entity packet
final Packet packet = new Packet(event.getEntity(), event.getEntityType(), location);
// Setup socket client and listener
final SocketClient client = new SocketClient(server.getAddress(), server.getPort(), server.getPassword());
client.setListener(new SocketClientEventListener() {
@Override
public void onServerMessageRecieve(final SocketClient client1, final Packets packets) {
for (final Packet packet1 : packets.packets) {
if (packet1.command.toLowerCase().equals("removeentity")) {
// Extract receiving packet arguments
final String world = String.valueOf(packet1.args[0]);
final int entityId = Integer.parseInt(packet1.args[1]);
// Iterate and remove teleported entity
final List<Entity> entities = Bukkit.getServer().getWorld(world).getEntities();
final Iterator<Entity> it = entities.iterator();
while (it.hasNext()) {
final Entity entity = it.next();
if (entity.getEntityId() == entityId) {
entityCache.invalidate(entityId);
entity.remove();
break;
}
}
}
}
client1.close();
}
@Override
public void onServerMessageError() {
}
});
// Connect and send packet
try {
client.connect();
client.send(packet);
} catch (final Exception e) {
Plugin.log(Level.SEVERE, "Error sending spawn packet to the server.");
}
}
}
}
示例5: onEntityUsePortal
import org.bukkit.event.entity.EntityPortalEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
public void onEntityUsePortal(final EntityPortalEvent event) {
this.plugin.entering(this.getClass(), "onEntityUsePortal", "entity=" + event.getEntityType() + ";from=" + NLocation.toString(event.getFrom()) + ";to=" + NLocation.toString(event.getTo()));
if (event.getEntityType() == EntityType.ENDER_DRAGON) {
this.plugin.exiting(this.getClass(), "onEntityUsePortal", "EnderDragon should really stay in the End!");
event.setCancelled(true);
return;
}
final GeneralWorld world = this.plugin.getWorlds().get(event.getFrom().getWorld().getName());
if (GeneralWorld.WorldType.isStock(world)) {
this.plugin.exiting(this.getClass(), "onEntityUsePortal", "Stock world!");
return;
}
// Build a fake TeleportCause based on From and To locations
PlayerTeleportEvent.TeleportCause cause = null;
final Block block = event.getFrom().getBlock();
switch (block.getType()) {
case PORTAL:
cause = PlayerTeleportEvent.TeleportCause.NETHER_PORTAL;
break;
case ENDER_PORTAL:
cause = PlayerTeleportEvent.TeleportCause.END_PORTAL;
break;
default:
this.plugin.debug("Strange block found: " + block.getType() + ", trying to find a portal block near the Location");
for (final BlockFace face : blockFaces) {
if (block.getRelative(face).getType() == Material.PORTAL) {
cause = PlayerTeleportEvent.TeleportCause.NETHER_PORTAL;
this.plugin.debug("Found a Nether Portal block at " + NLocation.toString(block.getRelative(face).getLocation()));
break;
} else if (block.getRelative(face).getType() == Material.ENDER_PORTAL) {
cause = PlayerTeleportEvent.TeleportCause.END_PORTAL;
this.plugin.debug("Found an End Portal block at " + NLocation.toString(block.getRelative(face).getLocation()));
break;
}
}
if (cause == null) {
cause = PlayerTeleportEvent.TeleportCause.PLUGIN;
}
break;
}
if (world.getType() == WorldType.ADDITIONAL) {
final AdditionalWorld additionalWorld = (AdditionalWorld)world;
if (cause == TeleportCause.NETHER_PORTAL && !additionalWorld.hasNether()) {
event.setCancelled(true);
this.plugin.exiting(this.getClass(), "onEntityUsePortal", "doesn't have required subworld (nether)");
return;
} else if (cause == TeleportCause.END_PORTAL && !additionalWorld.hasEnd()) {
event.setCancelled(true);
this.plugin.exiting(this.getClass(), "onEntityUsePortal", "doesn't have required subworld (end)");
return;
}
}
final PortalEventResult result = this.handlePortalEvent(event.getFrom(), cause, event.getPortalTravelAgent());
if (result == null) {
this.plugin.exiting(this.getClass(), "onEntityUsePortal", "result is null");
return;
}
if (result.destination != null) {
event.setTo(result.destination);
}
if (result.useTravelAgent) {
event.useTravelAgent(true);
}
if (result.cancelEvent) {
event.setCancelled(true);
}
this.plugin.exiting(this.getClass(), "onEntityUsePortal");
}