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


Java Vehicle.eject方法代码示例

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


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

示例1: execCommand

import org.bukkit.entity.Vehicle; //导入方法依赖的package包/类
public static void execCommand(final Vehicle vehicle, final String command, final CommandType commandType, final Boolean teleport) {
	final Entity passenger = vehicle.getPassenger();

	// Spin player 180 deg
	if (teleport) {
		final Location position = vehicle.getLocation();
		float yaw = position.getYaw();
		if ((yaw += 180) > 360) {
			yaw -= 360;
		}
		position.setYaw(yaw);
		position.add(position.getDirection().multiply(2));

		final Vehicle v = position.getWorld().spawn(position, vehicle.getClass());
		vehicle.eject();
		vehicle.remove();
		passenger.teleport(position);
		passenger.setFireTicks(0); // Cancel lava fire
		Plugin.instance.getServer().getScheduler().scheduleSyncDelayedTask(Plugin.instance, new Runnable() {
			@Override
			public void run() {
				v.setPassenger(passenger);
			}
		}, 2);
	}

	// Execute command as player or console
	Plugin.instance.getServer().getScheduler().scheduleSyncDelayedTask(Plugin.instance, new Runnable() {
		@Override
		public void run() {
			execCommand((Player) passenger, command, commandType);
		}
	}, 3);
}
 
开发者ID:NoChanceSD,项目名称:AncientGates,代码行数:35,代码来源:ExecuteUtil.java

示例2: onEntityPortal

import org.bukkit.entity.Vehicle; //导入方法依赖的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

示例3: onEntityPortal

import org.bukkit.entity.Vehicle; //导入方法依赖的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.createNether || ASkyBlock.getNetherWorld() == null) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: Disabled nether: Settings create nether = " + Settings.createNether + " " + (ASkyBlock.getNetherWorld() == null ? "Nether world is null": "Nether world is not null"));
        return;
    }
    if (event.getEntity() == null) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: entity is 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")) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: not an island world");
        return;
    }
    // No entities may pass with the old nether
    if (!Settings.newNether) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: no entities may pass with old nether");
        event.setCancelled(true);
        return;
    }
    // New nether
    // Entities can pass only if there are adjoining portals
    Location dest = event.getFrom().toVector().toLocation(ASkyBlock.getIslandWorld());
    if (event.getFrom().getWorld().getEnvironment().equals(Environment.NORMAL)) {
        dest = event.getFrom().toVector().toLocation(ASkyBlock.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,项目名称:acidisland,代码行数:66,代码来源:NetherPortals.java

示例4: vehicleMove

import org.bukkit.entity.Vehicle; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void vehicleMove(VehicleMoveEvent event) throws IllegalAccessException {
    final org.bukkit.Location from = event.getFrom();
    final org.bukkit.Location to = event.getTo();

    int toX, toZ;
    if ((toX = MathMan.roundInt(to.getX())) != MathMan.roundInt(from.getX()) | (toZ = MathMan.roundInt(to.getZ())) != MathMan.roundInt(from.getZ())) {
        Vehicle vehicle = event.getVehicle();

        // Check allowed


        Entity passenger = vehicle.getPassenger();

        if (passenger instanceof Player) {
            final Player player = (Player) passenger;
            // reset
            if (moveTmp == null) moveTmp = new PlayerMoveEvent(null, from, to);
            moveTmp.setFrom(from);
            moveTmp.setTo(to);
            moveTmp.setCancelled(false);
            fieldPlayer.set(moveTmp, player);

            List<Entity> passengers;
            if (v112) passengers = vehicle.getPassengers();
            else passengers = null;

            this.playerMove(moveTmp);
            org.bukkit.Location dest;
            if (moveTmp.isCancelled()) {
                dest = from;
            } else if (MathMan.roundInt(moveTmp.getTo().getX()) != toX || MathMan.roundInt(moveTmp.getTo().getZ()) != toZ) {
                dest = to;
            } else {
                dest = null;
            }
            if (dest != null) {
                if (passengers != null) {
                    vehicle.eject();
                    vehicle.setVelocity(new Vector(0d, 0d, 0d));
                    vehicle.teleport(dest);
                    for (final Entity entity : passengers) vehicle.addPassenger(entity);
                } else {
                    vehicle.eject();
                    vehicle.setVelocity(new Vector(0d, 0d, 0d));
                    vehicle.teleport(dest);
                    vehicle.setPassenger(player);
                }
                return;
            }
        }
        if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
            switch (vehicle.getType()) {
                case MINECART:
                case MINECART_CHEST:
                case MINECART_COMMAND:
                case MINECART_FURNACE:
                case MINECART_HOPPER:
                case MINECART_MOB_SPAWNER:
                case ENDER_CRYSTAL:
                case MINECART_TNT:
                case BOAT: {
                    List<MetadataValue> meta = vehicle.getMetadata("plot");
                    Plot toPlot = BukkitUtil.getLocation(to).getPlot();
                    if (!meta.isEmpty()) {
                        Plot origin = (Plot) meta.get(0).value();
                        if (!origin.getBasePlot(false).equals(toPlot)) {
                            vehicle.remove();
                        }
                    } else if (toPlot != null) {
                        vehicle.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, toPlot));
                    }
                }
            }
        }
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:78,代码来源:PlayerEvents.java


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