• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java VehicleMoveEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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());
}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:27,代码来源:BeaconProjectileDefenseListener.java


示例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.");
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:10,代码来源:Restrictions.java


示例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);
            }
        }
    }
}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:44,代码来源:PlayerMovementListener.java


示例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());

    }
}
 
开发者ID:dobrakmato,项目名称:PexelCore,代码行数:8,代码来源:EventProcessor.java


示例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;
	}
 
开发者ID:BitLimit,项目名称:Bits,代码行数:37,代码来源:ConfigurationManager.java


示例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()));

}
 
开发者ID:Staartvin,项目名称:Statz,代码行数:56,代码来源:DistanceTravelledVehicleListener.java


示例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));
                    }
                }
            }
        }
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:78,代码来源:PlayerEvents.java


示例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());

}
 
开发者ID:stendec,项目名称:Abyss,代码行数:7,代码来源:VehicleListener.java


示例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());
}
 
开发者ID:DemigodsRPG,项目名称:Demigods3,代码行数:6,代码来源:MoveListener.java


示例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));
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:7,代码来源:FreezeListener.java


示例11: onVehicleMove

import org.bukkit.event.vehicle.VehicleMoveEvent; //导入依赖的package包/类
@EventHandler
public void onVehicleMove(VehicleMoveEvent event) {
	plugin.handleEvent(event);
}
 
开发者ID:basicer,项目名称:parchment,代码行数:5,代码来源:GlobalListenerHeavy.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GraphQLOutputType类代码示例发布时间:2022-05-21
下一篇:
Java Task类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap