本文整理汇总了Java中org.bukkit.event.vehicle.VehicleMoveEvent类的典型用法代码示例。如果您正苦于以下问题:Java VehicleMoveEvent类的具体用法?Java VehicleMoveEvent怎么用?Java VehicleMoveEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VehicleMoveEvent类属于org.bukkit.event.vehicle包,在下文中一共展示了VehicleMoveEvent类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onVehicleMove
import org.bukkit.event.vehicle.VehicleMoveEvent; //导入依赖的package包/类
/**
* Check if player comes within range of a beacon
* @param event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onVehicleMove(VehicleMoveEvent event) {
// Remember that teleporting is not detected as player movement..
// If we want to catch movement by teleportation, we have to keep track of the players to-from by ourselves
// Only proceed if there's been a move, not just a head move
if (event.getFrom().getBlockX() == event.getTo().getBlockX() && event.getFrom().getBlockY() == event.getTo().getBlockY()
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ()) {
return;
}
World world = event.getTo().getWorld();
if (!world.equals(getBeaconzWorld())) {
return;
}
if (event.getVehicle().getPassenger() == null) {
return;
}
if (!(event.getVehicle().getPassenger() instanceof Player)) {
return;
}
Player player = (Player)event.getVehicle().getPassenger();
fireOnPlayer(player, event.getFrom(), event.getTo());
}
示例2: onVehicleMove
import org.bukkit.event.vehicle.VehicleMoveEvent; //导入依赖的package包/类
@EventHandler
public void onVehicleMove(VehicleMoveEvent evt) {
String fly = evt.getVehicle().getPassengers().stream().filter(e -> e instanceof Player).map(Entity::getName)
.collect(Collectors.joining(", "));
if (evt.getVehicle().getType() == EntityType.BOAT && !Flight.checkNearby(evt.getFrom(), Material.WATER, Material.STATIONARY_WATER)
&& fly.length() > 0 && evt.getTo().getY() > evt.getFrom().getY() && evt.getVehicle().getVelocity().getY() <= 0)
Core.alertStaff("[BoatFly] " + ChatColor.GRAY + fly + " may be using BoatFly.");
}
示例3: onVehicleMove
import org.bukkit.event.vehicle.VehicleMoveEvent; //导入依赖的package包/类
/**
* Handles movement inside a vehicle (or on a vehicle)
* @param event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onVehicleMove(final VehicleMoveEvent event) {
if (!event.getVehicle().getWorld().equals(getBeaconzWorld())) {
return;
}
// Check if a player is in it
Entity passenger = event.getVehicle().getPassenger();
if (passenger != null && passenger instanceof Player) {
Player player = (Player)passenger;
Location from = event.getFrom();
Location to = event.getTo();
/*
if (checkMove(player, event.getVehicle().getWorld(), from, to)) {
// Vehicle should stop moving
Vector direction = event.getVehicle().getLocation().getDirection();
event.getVehicle().teleport(event.getVehicle().getLocation().add(from.toVector().subtract(to.toVector()).normalize()));
event.getVehicle().getLocation().setDirection(direction);
event.getVehicle().setVelocity(new Vector(0,0,0));
}*/
// Check potion effects for boats etc.
if ((!(event.getVehicle() instanceof LivingEntity))) {
for (PotionEffect effect : getPml().getTriangleEffects(player.getUniqueId())) {
if (effect.getType().equals(PotionEffectType.SLOW)) {
double delay = effect.getAmplifier();
event.getVehicle().setVelocity(event.getVehicle().getVelocity().divide(new Vector(delay,delay,delay)));
break;
}
}
}
// Check if there are any other passengers
for (Player pl : getBeaconzWorld().getPlayers()) {
if (!pl.equals(player) && pl.isInsideVehicle() && pl.getVehicle().getEntityId() == event.getVehicle().getEntityId()) {
//getLogger().info(pl.getName() + " inside vehicle of id " + pl.getVehicle().getEntityId());
//getLogger().info("Event id = " + event.getVehicle().getEntityId());
checkMove(pl, event.getVehicle().getWorld(), from, to);
}
}
}
}
示例4: onVehicleMove
import org.bukkit.event.vehicle.VehicleMoveEvent; //导入依赖的package包/类
@EventHandler
private void onVehicleMove(final VehicleMoveEvent event) {
if (event.getVehicle() instanceof Minecart) {
//ProtectedArea area = Areas.findArea(event.getVehicle().getLocation());
}
}
示例5: getEventClassAssociations
import org.bukkit.event.vehicle.VehicleMoveEvent; //导入依赖的package包/类
private static HashMap<String, Class> getEventClassAssociations()
{
HashMap<String, Class> classHashMap = new HashMap<String, Class>();
classHashMap.put("block-break", BlockBreakEvent.class);
classHashMap.put("block-place", BlockPlaceEvent.class);
// classHashMap.put("entity-leash", PlayerLeashEntityEvent.class);
classHashMap.put("entity-kill", EntityDeathEvent.class);
classHashMap.put("entity-shear", PlayerShearEntityEvent.class);
classHashMap.put("item-brew", BrewEvent.class);
classHashMap.put("item-enchant", EnchantItemEvent.class);
classHashMap.put("item-furnace", FurnaceExtractEvent.class);
classHashMap.put("painting-create", HangingPlaceEvent.class);
classHashMap.put("player-regenerate", EntityRegainHealthEvent.class);
classHashMap.put("player-shoot", EntityShootBowEvent.class);
classHashMap.put("player-chat", AsyncPlayerChatEvent.class);
classHashMap.put("player-death", PlayerDeathEvent.class);
classHashMap.put("player-sleep", PlayerBedEnterEvent.class);
classHashMap.put("player-author", PlayerEditBookEvent.class);
classHashMap.put("player-egg", PlayerEggThrowEvent.class);
classHashMap.put("player-fish", PlayerFishEvent.class);
classHashMap.put("player-eat", PlayerItemConsumeEvent.class);
classHashMap.put("player-join", PlayerJoinEvent.class);
classHashMap.put("player-move", PlayerMoveEvent.class);
classHashMap.put("portal-create", PortalCreateEvent.class);
classHashMap.put("vehicle-move", VehicleMoveEvent.class);
classHashMap.put("world-change", PlayerChangedWorldEvent.class);
return classHashMap;
}
示例6: onMove
import org.bukkit.event.vehicle.VehicleMoveEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMove(final VehicleMoveEvent event) {
final PlayerStat stat = PlayerStat.DISTANCE_TRAVELLED;
Vehicle vehicle = event.getVehicle();
if (vehicle.getPassenger() == null)
return;
// Get player
final Player player;
String movementType;
if (vehicle.getPassenger() instanceof Player) {
player = (Player) vehicle.getPassenger();
movementType = StatzUtil.getMovementType(player);
} else {
// No passenger on the passenger
if (vehicle.getPassenger().getPassenger() == null)
return;
// There is no player riding.
if (!(vehicle.getPassenger().getPassenger() instanceof Player))
return;
player = (Player) vehicle.getPassenger().getPassenger();
movementType = StatzUtil.getMovementType(player);
}
// No player found, no movementType found.
if (player == null || movementType == null)
return;
// Do general check
if (!plugin.doGeneralCheck(player, stat))
return;
final double distTravelled = event.getFrom().distance(event.getTo());
if (distTravelled == 0) {
return;
}
final String movement = movementType;
// Update value to new stat.
plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat,
StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", distTravelled, "moveType",
movement, "world", player.getWorld().getName()));
}
示例7: vehicleMove
import org.bukkit.event.vehicle.VehicleMoveEvent; //导入依赖的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));
}
}
}
}
}
}
示例8: onVehicleMove
import org.bukkit.event.vehicle.VehicleMoveEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVehicleMove(final VehicleMoveEvent event) {
// Do portal logic. We ignore the return value because we couldn't use it anyways.
plugin.usePortal(event.getVehicle(), event.getFrom(), event.getTo());
}
示例9: onBattleVehicleMove
import org.bukkit.event.vehicle.VehicleMoveEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBattleVehicleMove(VehicleMoveEvent event) {
onBattleMoveEvent(event.getVehicle(), event.getTo(), event.getFrom());
onFlagMoveEvent(event.getVehicle(), event.getTo(), event.getFrom());
}
示例10: onVehicleMove
import org.bukkit.event.vehicle.VehicleMoveEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onVehicleMove(final VehicleMoveEvent event) {
if(!event.getVehicle().isEmpty() && freeze.isFrozen(event.getVehicle().getPassenger())) {
event.getVehicle().setVelocity(new Vector(0, 0, 0));
}
}
示例11: onVehicleMove
import org.bukkit.event.vehicle.VehicleMoveEvent; //导入依赖的package包/类
@EventHandler
public void onVehicleMove(VehicleMoveEvent event) {
plugin.handleEvent(event);
}