本文整理汇总了Java中org.bukkit.entity.Vehicle.remove方法的典型用法代码示例。如果您正苦于以下问题:Java Vehicle.remove方法的具体用法?Java Vehicle.remove怎么用?Java Vehicle.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Vehicle
的用法示例。
在下文中一共展示了Vehicle.remove方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onVehicleCreate
import org.bukkit.entity.Vehicle; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onVehicleCreate(VehicleCreateEvent event) {
Vehicle entity = event.getVehicle();
Location location = BukkitUtil.getLocation(entity);
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
Plot plot = area.getOwnedPlotAbs(location);
if (plot == null || checkEntity(entity, plot)) {
entity.remove();
return;
}
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot));
}
}
示例2: onVehicleCreate
import org.bukkit.entity.Vehicle; //导入方法依赖的package包/类
/**
* Handles vehicle spawning
*
* @param e an event representing a vehicle that has spawned
* @see VehicleCreateEvent
* @since 4.0.0
*/
@EventHandler(ignoreCancelled = true)
public void onVehicleCreate(VehicleCreateEvent e) {
Vehicle vehicle = e.getVehicle();
Plot plot;
if ((plot = Plot.getPlot(vehicle.getLocation())) != null) {
if (!plot.addEntity(vehicle))
vehicle.remove();
}
}
示例3: 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);
}
示例4: onVehicleCreate
import org.bukkit.entity.Vehicle; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onVehicleCreate(final VehicleCreateEvent event) {
Vehicle entity = event.getVehicle();
Location loc = BukkitUtil.getLocation(entity);
Plot plot = MainUtil.getPlot(loc);
if (checkEntity(entity, plot)) {
entity.remove();
}
}
示例5: onClick
import org.bukkit.entity.Vehicle; //导入方法依赖的package包/类
/**
* @param e
* This event check throws the boat at a player when they hit it
* unless someone is in it
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onClick(VehicleDamageEvent e) {
// plugin.getLogger().info("Damage event " + e.getDamage());
// Find out what block is being clicked
Vehicle boat = e.getVehicle();
if (!(boat instanceof Boat)) {
return;
}
if (!boat.isEmpty()) {
return;
}
final World playerWorld = boat.getWorld();
if (!playerWorld.getName().equalsIgnoreCase(Settings.worldName)) {
// Not the right world
return;
}
// plugin.getLogger().info("Boat ");
// Find out who is doing the clicking
if (!(e.getAttacker() instanceof Player)) {
// If a creeper blows up the boat, tough cookies!
return;
}
Player p = (Player) e.getAttacker();
if (p == null) {
return;
}
// Try to remove the boat and throw it at the player
Location boatSpot = new Location(boat.getWorld(), boat.getLocation().getX(), boat.getLocation().getY() + 2, boat.getLocation().getZ());
Location throwTo = new Location(boat.getWorld(), p.getLocation().getX(), p.getLocation().getY() + 1, p.getLocation().getZ());
ItemStack newBoat = new ItemStack(Material.BOAT, 1);
// Find the direction the boat should move in
Vector dir = throwTo.toVector().subtract(boatSpot.toVector()).normalize();
dir = dir.multiply(0.5);
Entity newB = boat.getWorld().dropItem(boatSpot, newBoat);
newB.setVelocity(dir);
boat.remove();
e.setCancelled(true);
}
示例6: 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));
}
}
}
}
}
}