Java 类org.bukkit.event.vehicle.VehicleCreateEvent 实例源码

项目:PlotSquared    文件:PlayerEvents.java   
@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));
    }
}
项目:modules-extra    文件:ListenerVehicle.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onVehicleCreate(final VehicleCreateEvent event)
{
    Location location = event.getVehicle().getLocation();
    Entity entity = this.plannedVehiclePlace.get(location);
    if (entity != null)
    {
        if (entity instanceof Player)
        {
            VehiclePlace action = this.newAction(VehiclePlace.class, event.getVehicle().getWorld());
            if (action != null)
            {
                action.setVehicle(event.getVehicle());
                action.setLocation(event.getVehicle().getLocation());
                action.setPlayer((Player)entity);
                this.logAction(action);
            }
        }
        else
        {
            // TODO entity place?
        }
    }
    // else not a create by placement -> ignore
}
项目:HCFCore    文件:BoatGlitchFixListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onVehicleCreate(VehicleCreateEvent event) {
    Vehicle vehicle = event.getVehicle();
    if (vehicle instanceof Boat) {
        Boat boat = (Boat) vehicle;
        Block belowBlock = boat.getLocation().add(0, -1, 0).getBlock();
        if (belowBlock.getType() != Material.WATER && belowBlock.getType() != Material.STATIONARY_WATER) {
            boat.remove();
        }
    }
}
项目:HCFCore    文件:BoatGlitchFixListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onVehicleCreate(VehicleCreateEvent event) {
    Vehicle vehicle = event.getVehicle();
    if (vehicle instanceof Boat) {
        Boat boat = (Boat) vehicle;
        Block belowBlock = boat.getLocation().add(0, -1, 0).getBlock();
        if (belowBlock.getType() != Material.WATER && belowBlock.getType() != Material.STATIONARY_WATER) {
            boat.remove();
        }
    }
}
项目:DragoMC-Cardinal-Dev    文件:EntityManager.java   
/** @author Kakalavala **/

    @EventHandler(priority=EventPriority.HIGHEST)
    public void EntityBlock(VehicleCreateEvent event){
        try{
            final EntityType block = event.getVehicle().getType();
            for(EntityType blocked : Main.entitylist){
                if(blocked == block){
                    event.getVehicle().remove();
                }
            }
        }catch(NullPointerException e){}
    }
项目:buildinggame    文件:EntitySpawn.java   
/**
    * 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();
    }
}
项目:PlotSquared-Chinese    文件:PlayerEvents.java   
@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();
    }
}
项目:BCProtect    文件:VehicleCreateListener.java   
@EventHandler (ignoreCancelled = true)
public void onVehicleCreate(VehicleCreateEvent event) {
    Location loc = event.getVehicle().getLocation(BCProtect.location);
    if (Util.getQuadtree(loc).contains(loc)) {
        event.getVehicle().remove();
    }
}
项目:acidisland    文件:EntityLimits.java   
/**
 * Handles minecart placing
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onMinecart(VehicleCreateEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("DEBUG: " + e.getEventName());
        plugin.getLogger().info("DEBUG: Vehicle type = " + e.getVehicle().getType());
    }
    if (!IslandGuard.inWorld(e.getVehicle())) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: Not in world");
        return;
    }
    if (DEBUG)
        plugin.getLogger().info("DEBUG: Checking entity types");
    if (Settings.entityLimits.containsKey(e.getVehicle().getType())) {
        // If someone in that area has the bypass permission, allow the spawning
        for (Entity entity : e.getVehicle().getLocation().getWorld().getNearbyEntities(e.getVehicle().getLocation(), 5, 5, 5)) {
            if (entity instanceof Player) {
                Player player = (Player)entity;
                Boolean bypass = false;
                if (player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypass")) {
                    if (DEBUG)
                        plugin.getLogger().info("DEBUG: op or bypass");
                    bypass = true;
                }
                // Check island
                Island island = plugin.getGrid().getProtectedIslandAt(e.getVehicle().getLocation());

                if (island == null) {
                    // Only count island entities
                    if (DEBUG)
                        plugin.getLogger().info("DEBUG: island is null");
                    return;
                }
                // Ignore spawn
                if (island.isSpawn()) {
                    if (DEBUG)
                        plugin.getLogger().info("DEBUG: ignore spawn");
                    return;
                }
                if (DEBUG)
                    plugin.getLogger().info("DEBUG: Checking entity limits");
                // Check if the player is at the limit
                if (atLimit(island, bypass, e.getVehicle())) {
                    e.setCancelled(true);
                    for (Entity ent : e.getVehicle().getLocation().getWorld().getNearbyEntities(e.getVehicle().getLocation(), 5, 5, 5)) {
                        if (ent instanceof Player) { 
                            Util.sendMessage((Player)ent, ChatColor.RED 
                                    + (plugin.myLocale(player.getUniqueId()).entityLimitReached.replace("[entity]", 
                                            Util.prettifyText(e.getVehicle().getType().toString()))
                                            .replace("[number]", String.valueOf(Settings.entityLimits.get(e.getVehicle().getType())))));
                        }
                    }
                }
            }
        }
    }
    return;
}
项目:askyblock    文件:EntityLimits.java   
/**
 * Handles minecart placing
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onMinecart(VehicleCreateEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("DEBUG: " + e.getEventName());
        plugin.getLogger().info("DEBUG: Vehicle type = " + e.getVehicle().getType());
    }
    if (!IslandGuard.inWorld(e.getVehicle())) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: Not in world");
        return;
    }
    if (DEBUG)
        plugin.getLogger().info("DEBUG: Checking entity types");
    if (Settings.entityLimits.containsKey(e.getVehicle().getType())) {
        // If someone in that area has the bypass permission, allow the spawning
        for (Entity entity : e.getVehicle().getLocation().getWorld().getNearbyEntities(e.getVehicle().getLocation(), 5, 5, 5)) {
            if (entity instanceof Player) {
                Player player = (Player)entity;
                Boolean bypass = false;
                if (player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypass")) {
                    if (DEBUG)
                        plugin.getLogger().info("DEBUG: op or bypass");
                    bypass = true;
                }
                // Check island
                Island island = plugin.getGrid().getProtectedIslandAt(e.getVehicle().getLocation());

                if (island == null) {
                    // Only count island entities
                    if (DEBUG)
                        plugin.getLogger().info("DEBUG: island is null");
                    return;
                }
                // Ignore spawn
                if (island.isSpawn()) {
                    if (DEBUG)
                        plugin.getLogger().info("DEBUG: ignore spawn");
                    return;
                }
                if (DEBUG)
                    plugin.getLogger().info("DEBUG: Checking entity limits");
                // Check if the player is at the limit
                if (atLimit(island, bypass, e.getVehicle())) {
                    e.setCancelled(true);
                    for (Entity ent : e.getVehicle().getLocation().getWorld().getNearbyEntities(e.getVehicle().getLocation(), 5, 5, 5)) {
                        if (ent instanceof Player) { 
                            Util.sendMessage((Player)ent, ChatColor.RED 
                                    + (plugin.myLocale(player.getUniqueId()).entityLimitReached.replace("[entity]", 
                                            Util.prettifyText(e.getVehicle().getType().toString()))
                                            .replace("[number]", String.valueOf(Settings.entityLimits.get(e.getVehicle().getType())))));
                        }
                    }
                }
            }
        }
    }
    return;
}
项目:FlyingTub    文件:TubFlightListener.java   
@EventHandler(ignoreCancelled=true)
public final void onVehicleCreate(VehicleCreateEvent event) {
    fixCart(event.getVehicle());
}