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

项目:Skript    文件:ExprAttackerAlt.java   
private static Object getAttacker(final Event e) {
    if (e instanceof EntityDamageByEntityEvent) {
        if (((EntityDamageByEntityEvent) e).getDamager() instanceof Projectile) {
            return ((Projectile) ((EntityDamageByEntityEvent) e).getDamager()).getShooter();
        }
        return ((EntityDamageByEntityEvent) e).getDamager();
    } else if (e instanceof EntityDamageByBlockEvent) {
        return ((EntityDamageByBlockEvent) e).getDamager();
    } else if (e instanceof EntityDeathEvent) {
        return getAttacker(((EntityDeathEvent) e).getEntity().getLastDamageCause());
    } else if (e instanceof VehicleDamageEvent) {
        return ((VehicleDamageEvent) e).getAttacker();
    } else if (e instanceof VehicleDestroyEvent) {
        return ((VehicleDestroyEvent) e).getAttacker();
    }
    return null;
}
项目:Skript    文件:ExprAttacker.java   
@Nullable
    private static Entity getAttacker(final @Nullable Event e) {
        if (e == null)
            return null;
        if (e instanceof EntityDamageByEntityEvent) {
            if (((EntityDamageByEntityEvent) e).getDamager() instanceof Projectile) {
                final Object o = ProjectileUtils.getShooter((Projectile) ((EntityDamageByEntityEvent) e).getDamager());
                if (o instanceof Entity)
                    return (Entity) o;
                return null;
            }
            return ((EntityDamageByEntityEvent) e).getDamager();
//      } else if (e instanceof EntityDamageByBlockEvent) {
//          return ((EntityDamageByBlockEvent) e).getDamager();
        } else if (e instanceof EntityDeathEvent) {
            return getAttacker(((EntityDeathEvent) e).getEntity().getLastDamageCause());
        } else if (e instanceof VehicleDamageEvent) {
            return ((VehicleDamageEvent) e).getAttacker();
        } else if (e instanceof VehicleDestroyEvent) {
            return ((VehicleDestroyEvent) e).getAttacker();
        }
        return null;
    }
项目:RedProtect    文件:RPGlobalListener.java   
@EventHandler
public void onVehicleBreak(VehicleDestroyEvent e){
    if (e.isCancelled()){
        return;
    }
    if (!(e.getAttacker() instanceof Player)){
        return;
    }

    Vehicle cart = e.getVehicle();
    Player p = (Player) e.getAttacker();
    Region r = RedProtect.get().rm.getTopRegion(cart.getLocation());
    if (r != null){
        return;
    }

    if (!RPConfig.getGlobalFlagBool(p.getWorld().getName()+".use-minecart") && !p.hasPermission("redprotect.bypass.world")){
        e.setCancelled(true);
    }
}
项目:RedProtect    文件:RPBlockListener.java   
@EventHandler
public void onVehicleBreak(VehicleDestroyEvent e){
    RedProtect.get().logger.debug("RPBlockListener - Is VehicleDestroyEvent event");
    if (e.isCancelled()){
        return;
    }
    if (!(e.getAttacker() instanceof Player)){
        return;
    }
    Vehicle cart = e.getVehicle();
    Player p = (Player) e.getAttacker();
    Region r = RedProtect.get().rm.getTopRegion(cart.getLocation());

    if (r != null && !r.canMinecart(p)){
        RPLang.sendMessage(p, "blocklistener.region.cantbreak");
        e.setCancelled(true);
    }
}
项目:Peacecraft    文件:ProtectListener.java   
@EventHandler
public void onVehicleDestroy(VehicleDestroyEvent event) {
    EntityProtection entityProtection = this.module.getProtectManager().getEntityProtection(event.getVehicle().getType(), event.getVehicle().getUniqueId());
    if(entityProtection.exists()) {
        if(event.getAttacker() instanceof Player) {
            Player player = (Player) event.getAttacker();

            if(entityProtection.getOwner().equals(player.getUniqueId()) || player.hasPermission(ProtectPermissions.MODIFY_ALL)) {
                entityProtection.remove();
                sendMessage(player, "protect.entity-unprotected");
                return;
            }

            sendMessage(player, "protect.entity-protected-by", getDisplayName(this.module.getManager().getUsername(entityProtection.getOwner()), event.getVehicle().getWorld().getName()));
        }

        event.setCancelled(true);
    }
}
项目:acidisland    文件:SafeBoat.java   
/**
 * @param e
 *            This function prevents boats from exploding when they hit
 *            something
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false)
public void onBoatHit(VehicleDestroyEvent e) {
    // plugin.getLogger().info("Vehicle destroyed event called");
    final Entity boat = e.getVehicle();
    if (!(boat instanceof Boat)) {
        return;
    }
    if (!boat.getWorld().getName().equalsIgnoreCase(Settings.worldName)) {
        // Not the right world
        return;
    }
    if (!(e.getAttacker() instanceof Player)) {
        // plugin.getLogger().info("Attacker is not a player so cancel event");
        e.setCancelled(true);
    }
}
项目:askyblock    文件:SafeBoat.java   
/**
 * @param e
 *            This function prevents boats from exploding when they hit
 *            something
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false)
public void onBoatHit(VehicleDestroyEvent e) {
    // plugin.getLogger().info("Vehicle destroyed event called");
    final Entity boat = e.getVehicle();
    if (!(boat instanceof Boat)) {
        return;
    }
    if (!boat.getWorld().getName().equalsIgnoreCase(Settings.worldName)) {
        // Not the right world
        return;
    }
    if (!(e.getAttacker() instanceof Player)) {
        // plugin.getLogger().info("Attacker is not a player so cancel event");
        e.setCancelled(true);
    }
}
项目:simple-survival-games    文件:SSGVehicleListener.java   
@EventHandler
public void onVehicleDestroy(VehicleDestroyEvent event) {
    Vehicle v = event.getVehicle();
    Entity attacker = event.getAttacker();

    ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();

    for(Arena a : am.getArenas()) {
        if(a.isArenaCuboidSet()) {
            if(a.getArenaCuboid().isInsideCuboid(v.getLocation())) {
                if(!a.isInEditMode()) {
                    event.setCancelled(true);
                    if(attacker instanceof Player) {
                        Player p = (Player) attacker;
                        p.sendMessage(ChatColor.DARK_RED + "You may not destroy this vehicle!");
                    }
                }
            }
        }
    }
}
项目:Warzone    文件:SpectatorModule.java   
@EventHandler
public void onVehicleDestroy(VehicleDestroyEvent event) {
    if (event.getAttacker() != null && event.getAttacker() instanceof Player) {
        if (isSpectating((Player) event.getAttacker())) {
            event.setCancelled(true);
        }
    }
}
项目:Skript    文件:ExprAttacker.java   
@SuppressWarnings("unchecked")
@Override
public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {
    if (!ScriptLoader.isCurrentEvent(EntityDamageByEntityEvent.class, EntityDeathEvent.class, VehicleDamageEvent.class, VehicleDestroyEvent.class)) {
        Skript.error("Cannot use 'attacker' outside of a damage/death/destroy event", ErrorQuality.SEMANTIC_ERROR);
        return false;
    }
    return true;
}
项目:CraftBukkit    文件:EntityBoat.java   
protected void a(double d0, boolean flag) {
    int i = MathHelper.floor(this.locX);
    int j = MathHelper.floor(this.locY);
    int k = MathHelper.floor(this.locZ);

    if (flag) {
        if (this.fallDistance > 3.0F) {
            this.b(this.fallDistance);
            if (!this.world.isStatic && !this.dead) {
                // CraftBukkit start
                Vehicle vehicle = (Vehicle) this.getBukkitEntity();
                VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
                this.world.getServer().getPluginManager().callEvent(destroyEvent);
                if (!destroyEvent.isCancelled()) {
                    this.die();

                    int l;

                    for (l = 0; l < 3; ++l) {
                        this.a(Item.getItemOf(Blocks.WOOD), 1, 0.0F);
                    }

                    for (l = 0; l < 2; ++l) {
                        this.a(Items.STICK, 1, 0.0F);
                    }
                }
                // CraftBukkit end
            }

            this.fallDistance = 0.0F;
        }
    } else if (this.world.getType(i, j - 1, k).getMaterial() != Material.WATER && d0 < 0.0D) {
        this.fallDistance = (float) ((double) this.fallDistance - d0);
    }
}
项目:uSkyBlock    文件:ExploitEvents.java   
@EventHandler
public void on(VehicleDestroyEvent e) {
    if (breakVehicleEnabled || !(e.getAttacker() instanceof Player)) {
        return;
    }
    Player player = (Player) e.getAttacker();
    if (hasPermission(player, "usb.mod.bypassprotection") || plugin.playerIsOnIsland(player)) {
        return;
    }
    e.setCancelled(true);
    player.sendMessage(tr("\u00a7eYou cannot break vehicles while being a visitor!"));
}
项目:AntiCheat-COMPAT    文件:VehicleListener.java   
@EventHandler(ignoreCancelled = true)
public void onVehicleDestroy(VehicleDestroyEvent event) {
    if (event.getVehicle().getPassenger() != null && event.getVehicle().getPassenger() instanceof Player) {
        getBackend().logEnterExit((Player) event.getVehicle().getPassenger());
    }

    AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
项目:Tweakkit-Server    文件:EntityBoat.java   
protected void a(double d0, boolean flag) {
    int i = MathHelper.floor(this.locX);
    int j = MathHelper.floor(this.locY);
    int k = MathHelper.floor(this.locZ);

    if (flag) {
        if (this.fallDistance > 3.0F) {
            this.b(this.fallDistance);
            if (!this.world.isStatic && !this.dead) {
                // CraftBukkit start
                Vehicle vehicle = (Vehicle) this.getBukkitEntity();
                VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
                this.world.getServer().getPluginManager().callEvent(destroyEvent);
                if (!destroyEvent.isCancelled()) {
                    this.die();

                    int l;

                    for (l = 0; l < 3; ++l) {
                        this.a(Item.getItemOf(Blocks.WOOD), 1, 0.0F);
                    }

                    for (l = 0; l < 2; ++l) {
                        this.a(Items.STICK, 1, 0.0F);
                    }
                }
                // CraftBukkit end
            }

            this.fallDistance = 0.0F;
        }
    } else if (this.world.getType(i, j - 1, k).getMaterial() != Material.WATER && d0 < 0.0D) {
        this.fallDistance = (float) ((double) this.fallDistance - d0);
    }
}
项目:PlotSquared    文件:PlayerEvents.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onVehicleDestroy(VehicleDestroyEvent event) {
    Location l = BukkitUtil.getLocation(event.getVehicle());
    PlotArea area = l.getPlotArea();
    if (area == null) {
        return;
    }
    Entity d = event.getAttacker();
    if (d instanceof Player) {
        Player p = (Player) d;
        PlotPlayer pp = BukkitUtil.getPlayer(p);
        Plot plot = area.getPlot(l);
        if (plot == null) {
            if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) {
                MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.road");
                event.setCancelled(true);
            }
        } else {
            if (!plot.hasOwner()) {
                if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.unowned")) {
                    MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.unowned");
                    event.setCancelled(true);
                    return;
                }
                return;
            }
            if (!plot.isAdded(pp.getUUID())) {
                if (plot.getFlag(Flags.VEHICLE_BREAK, false)) {
                    return;
                }
                if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) {
                    MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.other");
                    event.setCancelled(true);
                }
            }
        }
    }
}
项目:CraftoPlugin    文件:EntityProtectionBreakListener.java   
@EventHandler
public void onVehicleDestroy(final VehicleDestroyEvent event) {
    debug("VehicleDamageEvent triggered!");
    if (event.getAttacker() == null) { return; }

    final Entity damager = Utility.getRealDamager(event.getAttacker());
    if (!(damager instanceof Player)) { return; }
    debug("Determined real damager: " + damager.getName());

    if (!this.canInteract(event.getVehicle(), (Player)damager)) { event.setCancelled(true); }
}
项目:CrazyLogin    文件:DynamicVehicleListener.java   
@EventHandler
public void VehicleDestroy(final VehicleDestroyEvent event)
{
    if (!(event.getAttacker() instanceof Player))
        return;
    final Player player = (Player) event.getAttacker();
    if (plugin.isLoggedIn(player))
        return;
    event.setCancelled(true);
    plugin.sendAuthReminderMessage(player);
}
项目:SpigotSource    文件:EntityBoat.java   
protected void a(double d0, boolean flag, IBlockData iblockdata, BlockPosition blockposition) {
    this.aI = this.motY;
    if (!this.isPassenger()) {
        if (flag) {
            if (this.fallDistance > 3.0F) {
                if (this.aG != EntityBoat.EnumStatus.ON_LAND) {
                    this.fallDistance = 0.0F;
                    return;
                }

                this.e(this.fallDistance, 1.0F);
                if (!this.world.isClientSide && !this.dead) {
                // CraftBukkit start
                Vehicle vehicle = (Vehicle) this.getBukkitEntity();
                VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
                this.world.getServer().getPluginManager().callEvent(destroyEvent);
                if (!destroyEvent.isCancelled()) {
                    this.die();
                    if (this.world.getGameRules().getBoolean("doEntityDrops")) {
                        int i;

                        for (i = 0; i < 3; ++i) {
                            this.a(new ItemStack(Item.getItemOf(Blocks.PLANKS), 1, this.getType().b()), 0.0F);
                        }

                        for (i = 0; i < 2; ++i) {
                            this.a(Items.STICK, 1, 0.0F);
                        }
                    }
                }
                } // CraftBukkit end
            }

            this.fallDistance = 0.0F;
        } else if (this.world.getType((new BlockPosition(this)).down()).getMaterial() != Material.WATER && d0 < 0.0D) {
            this.fallDistance = (float) ((double) this.fallDistance - d0);
        }

    }
}
项目:BCProtect    文件:VehicleDestroyListener.java   
@EventHandler (ignoreCancelled = true)
public void onVehicleDestroy(VehicleDestroyEvent event) {
    Location loc = event.getVehicle().getLocation(BCProtect.location);
    if (Util.getQuadtree(loc).contains(loc)) {
        event.setCancelled(true);
    }
}
项目:NPlugins    文件:BuildFlagListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onVehicleDestroy(final VehicleDestroyEvent event) {
    if (event.getAttacker() != null && event.getAttacker().getType() == EntityType.PLAYER) {
        final Player player = (Player)event.getAttacker();
        final GeneralRegion region = this.getPlugin().getDb().getPriorByLocation(event.getVehicle().getLocation());
        if (region != null && region.getFlag(Flag.BUILD) && !region.isUser(player)) {
            event.setCancelled(true);
        }
    }
}
项目:AbilityAPI    文件:SequenceListener.java   
@EventHandler
public void onVehicleDestroy(VehicleDestroyEvent event) {
    if (event.getAttacker() instanceof Player) {
        this.manager.invoke((Player) event.getAttacker(), event);
    }
}
项目:CraftBukkit    文件:EntityMinecartAbstract.java   
public boolean damageEntity(DamageSource damagesource, float f) {
    if (!this.world.isStatic && !this.dead) {
        if (this.isInvulnerable()) {
            return false;
        } else {
            // CraftBukkit start - fire VehicleDamageEvent
            Vehicle vehicle = (Vehicle) this.getBukkitEntity();
            org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();

            VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, f);
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return true;
            }

            f = (float) event.getDamage();
            // CraftBukkit end

            this.j(-this.l());
            this.c(10);
            this.Q();
            this.setDamage(this.getDamage() + f * 10.0F);
            boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;

            if (flag || this.getDamage() > 40.0F) {
                if (this.passenger != null) {
                    this.passenger.mount(this);
                }

                // CraftBukkit start
                VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
                this.world.getServer().getPluginManager().callEvent(destroyEvent);

                if (destroyEvent.isCancelled()) {
                    this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
                    return true;
                }
                // CraftBukkit end

                if (flag && !this.k_()) {
                    this.die();
                } else {
                    this.a(damagesource);
                }
            }

            return true;
        }
    } else {
        return true;
    }
}
项目:CraftBukkit    文件:EntityBoat.java   
public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable()) {
        return false;
    } else if (!this.world.isStatic && !this.dead) {
        // CraftBukkit start
        Vehicle vehicle = (Vehicle) this.getBukkitEntity();
        org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();

        VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f);
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return true;
        }
        // f = event.getDamage(); // TODO Why don't we do this?
        // CraftBukkit end

        this.c(-this.i());
        this.a(10);
        this.setDamage(this.getDamage() + f * 10.0F);
        this.Q();
        boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;

        if (flag || this.getDamage() > 40.0F) {
            // CraftBukkit start
            VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
            this.world.getServer().getPluginManager().callEvent(destroyEvent);

            if (destroyEvent.isCancelled()) {
                this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away
                return true;
            }
            // CraftBukkit end

            if (this.passenger != null) {
                this.passenger.mount(this);
            }

            if (!flag) {
                this.a(Items.BOAT, 1, 0.0F);
            }

            this.die();
        }

        return true;
    } else {
        return true;
    }
}
项目:PlotSquared-Chinese    文件:PlayerEvents.java   
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onVehicleDestroy(final VehicleDestroyEvent e) {
    final Location l = BukkitUtil.getLocation(e.getVehicle());
    if (PlotSquared.isPlotWorld(l.getWorld())) {
        final Entity d = e.getAttacker();
        if (d instanceof Player) {
            final Player p = (Player) d;
            PlotSquared.getPlotWorld(l.getWorld());
            final PlotPlayer pp = BukkitUtil.getPlayer(p);
            Plot plot = MainUtil.getPlot(l);
            if (plot == null) {
                if (!MainUtil.isPlotAreaAbs(l)) {
                    return;
                }
                if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) {
                    MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.road");
                    e.setCancelled(true);
                    return;
                }
            } else {
                if (!plot.hasOwner()) {
                    if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.unowned")) {
                        MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.unowned");
                        e.setCancelled(true);
                        return;
                    }
                    return;
                }
                if (!plot.isAdded(pp.getUUID())) {
                    if (FlagManager.isPlotFlagTrue(plot, "vehicle-break")) {
                        return;
                    }
                    if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) {
                        if (MainUtil.isPlotArea(l)) {
                            MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.vehicle.break.other");
                            e.setCancelled(true);
                            return;
                        }
                    }
                }
            }
        }
    }
}
项目:Almura-Server    文件:EntityMinecartAbstract.java   
public boolean damageEntity(DamageSource damagesource, float f) {
    if (!this.world.isStatic && !this.dead) {
        if (this.isInvulnerable()) {
            return false;
        } else {
            // CraftBukkit start
            Vehicle vehicle = (Vehicle) this.getBukkitEntity();
            org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();

            VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, f);
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return true;
            }

            f = (float) event.getDamage();
            // CraftBukkit end

            this.h(-this.k());
            this.c(10);
            this.K();
            this.setDamage(this.getDamage() + f * 10.0F);
            boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;

            if (flag || this.getDamage() > 40.0F) {
                if (this.passenger != null) {
                    this.passenger.mount(this);
                }

                // CraftBukkit start
                VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
                this.world.getServer().getPluginManager().callEvent(destroyEvent);

                if (destroyEvent.isCancelled()) {
                    this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
                    return true;
                }
                // CraftBukkit end

                if (flag && !this.c()) {
                    this.die();
                } else {
                    this.a(damagesource);
                }
            }

            return true;
        }
    } else {
        return true;
    }
}
项目:Almura-Server    文件:EntityBoat.java   
public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable()) {
        return false;
    } else if (!this.world.isStatic && !this.dead) {
        // CraftBukkit start
        Vehicle vehicle = (Vehicle) this.getBukkitEntity();
        org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();

        VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f);
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return true;
        }
        // i = event.getDamage(); // TODO Why don't we do this?
        // CraftBukkit end

        this.c(-this.h());
        this.a(10);
        this.setDamage(this.getDamage() + f * 10.0F);
        this.K();
        boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;

        if (flag || this.getDamage() > 40.0F) {
            // CraftBukkit start
            VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
            this.world.getServer().getPluginManager().callEvent(destroyEvent);

            if (destroyEvent.isCancelled()) {
                this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away
                return true;
            }
            // CraftBukkit end

            if (this.passenger != null) {
                this.passenger.mount(this);
            }

            if (!flag) {
                this.a(Item.BOAT.id, 1, 0.0F);
            }

            this.die();
        }

        return true;
    } else {
        return true;
    }
}
项目:Tweakkit-Server    文件:EntityMinecartAbstract.java   
public boolean damageEntity(DamageSource damagesource, float f) {
    if (!this.world.isStatic && !this.dead) {
        if (this.isInvulnerable()) {
            return false;
        } else {
            // CraftBukkit start - fire VehicleDamageEvent
            Vehicle vehicle = (Vehicle) this.getBukkitEntity();
            org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();

            VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, f);
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return true;
            }

            f = (float) event.getDamage();
            // CraftBukkit end

            this.j(-this.l());
            this.c(10);
            this.Q();
            this.setDamage(this.getDamage() + f * 10.0F);
            boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;

            if (flag || this.getDamage() > 40.0F) {
                if (this.passenger != null) {
                    this.passenger.mount(this);
                }

                // CraftBukkit start
                VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
                this.world.getServer().getPluginManager().callEvent(destroyEvent);

                if (destroyEvent.isCancelled()) {
                    this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
                    return true;
                }
                // CraftBukkit end

                if (flag && !this.k_()) {
                    this.die();
                } else {
                    this.a(damagesource);
                }
            }

            return true;
        }
    } else {
        return true;
    }
}
项目:Tweakkit-Server    文件:EntityBoat.java   
public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable()) {
        return false;
    } else if (!this.world.isStatic && !this.dead) {
        // CraftBukkit start
        Vehicle vehicle = (Vehicle) this.getBukkitEntity();
        org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();

        VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f);
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return true;
        }
        // f = event.getDamage(); // TODO Why don't we do this?
        // CraftBukkit end

        this.c(-this.i());
        this.a(10);
        this.setDamage(this.getDamage() + f * 10.0F);
        this.Q();
        boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;

        if (flag || this.getDamage() > 40.0F) {
            // CraftBukkit start
            VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
            this.world.getServer().getPluginManager().callEvent(destroyEvent);

            if (destroyEvent.isCancelled()) {
                this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away
                return true;
            }
            // CraftBukkit end

            if (this.passenger != null) {
                this.passenger.mount(this);
            }

            if (!flag) {
                this.a(Items.BOAT, 1, 0.0F);
            }

            this.die();
        }

        return true;
    } else {
        return true;
    }
}
项目:Cauldron    文件:EntityMinecart.java   
public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_)
{
    if (!this.worldObj.isRemote && !this.isDead)
    {
        if (this.isEntityInvulnerable())
        {
            return false;
        }
        else
        {
            // CraftBukkit start
            Vehicle vehicle = (Vehicle) this.getBukkitEntity();
            org.bukkit.entity.Entity passenger = (p_70097_1_.getEntity() == null) ? null : p_70097_1_.getEntity().getBukkitEntity();
            VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, p_70097_2_);
            this.worldObj.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled())
            {
                return true;
            }

            p_70097_2_ = (float) event.getDamage();
            // CraftBukkit end
            this.setRollingDirection(-this.getRollingDirection());
            this.setRollingAmplitude(10);
            this.setBeenAttacked();
            this.setDamage(this.getDamage() + p_70097_2_ * 10.0F);
            boolean flag = p_70097_1_.getEntity() instanceof EntityPlayer && ((EntityPlayer)p_70097_1_.getEntity()).capabilities.isCreativeMode;

            if (flag || this.getDamage() > 40.0F)
            {
                if (this.riddenByEntity != null)
                {
                    this.riddenByEntity.mountEntity(this);
                }

                // CraftBukkit start
                VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
                this.worldObj.getServer().getPluginManager().callEvent(destroyEvent);

                if (destroyEvent.isCancelled())
                {
                    this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
                    return true;
                }

                // CraftBukkit end

                if (flag && !this.hasCustomInventoryName())
                {
                    this.setDead();
                }
                else
                {
                    this.killMinecart(p_70097_1_);
                }
            }

            return true;
        }
    }
    else
    {
        return true;
    }
}
项目:Cauldron    文件:EntityBoat.java   
public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_)
{
    if (this.isEntityInvulnerable())
    {
        return false;
    }
    else if (!this.worldObj.isRemote && !this.isDead)
    {
        // CraftBukkit start
        Vehicle vehicle = (Vehicle) this.getBukkitEntity();
        org.bukkit.entity.Entity attacker = (p_70097_1_.getEntity() == null) ? null : p_70097_1_.getEntity().getBukkitEntity();
        VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) p_70097_2_);
        this.worldObj.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled())
        {
            return true;
        }

        // f = event.getDamage(); // TODO Why don't we do this?
        // CraftBukkit end
        this.setForwardDirection(-this.getForwardDirection());
        this.setTimeSinceHit(10);
        this.setDamageTaken(this.getDamageTaken() + p_70097_2_ * 10.0F);
        this.setBeenAttacked();
        boolean flag = p_70097_1_.getEntity() instanceof EntityPlayer && ((EntityPlayer)p_70097_1_.getEntity()).capabilities.isCreativeMode;

        if (flag || this.getDamageTaken() > 40.0F)
        {
            // CraftBukkit start
            VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
            this.worldObj.getServer().getPluginManager().callEvent(destroyEvent);

            if (destroyEvent.isCancelled())
            {
                this.setDamageTaken(40F); // Maximize damage so this doesn't get triggered again right away
                return true;
            }

            // CraftBukkit end

            if (this.riddenByEntity != null)
            {
                this.riddenByEntity.mountEntity(this);
            }

            if (!flag)
            {
                this.func_145778_a(Items.boat, 1, 0.0F);
            }

            this.setDead();
        }

        return true;
    }
    else
    {
        return true;
    }
}
项目:SpigotSource    文件:EntityMinecartAbstract.java   
public boolean damageEntity(DamageSource damagesource, float f) {
    if (!this.world.isClientSide && !this.dead) {
        if (this.isInvulnerable(damagesource)) {
            return false;
        } else {
            // CraftBukkit start - fire VehicleDamageEvent
            Vehicle vehicle = (Vehicle) this.getBukkitEntity();
            org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();

            VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, f);
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return true;
            }

            f = (float) event.getDamage();
            // CraftBukkit end
            this.e(-this.u());
            this.d(10);
            this.ao();
            this.setDamage(this.getDamage() + f * 10.0F);
            boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;

            if (flag || this.getDamage() > 40.0F) {
                // CraftBukkit start
                VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
                this.world.getServer().getPluginManager().callEvent(destroyEvent);

                if (destroyEvent.isCancelled()) {
                    this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
                    return true;
                }
                // CraftBukkit end
                this.az();
                if (flag && !this.hasCustomName()) {
                    this.die();
                } else {
                    this.a(damagesource);
                }
            }

            return true;
        }
    } else {
        return true;
    }
}
项目:SpigotSource    文件:EntityBoat.java   
public boolean damageEntity(DamageSource damagesource, float f) {
    if (this.isInvulnerable(damagesource)) {
        return false;
    } else if (!this.world.isClientSide && !this.dead) {
        if (damagesource instanceof EntityDamageSourceIndirect && damagesource.getEntity() != null && this.w(damagesource.getEntity())) {
            return false;
        } else {
            // CraftBukkit start
            Vehicle vehicle = (Vehicle) this.getBukkitEntity();
            org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();

            VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f);
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return true;
            }
            // f = event.getDamage(); // TODO Why don't we do this?
            // CraftBukkit end

            this.d(-this.q());
            this.b(10);
            this.setDamage(this.n() + f * 10.0F);
            this.ao();
            boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;

            if (flag || this.n() > 40.0F) {
                // CraftBukkit start
                VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
                this.world.getServer().getPluginManager().callEvent(destroyEvent);

                if (destroyEvent.isCancelled()) {
                    this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away
                    return true;
                }
                // CraftBukkit end
                if (!flag && this.world.getGameRules().getBoolean("doEntityDrops")) {
                    this.a(this.j(), 1, 0.0F);
                }

                this.die();
            }

            return true;
        }
    } else {
        return true;
    }
}
项目:Craft-city    文件:EntityMinecartAbstract.java   
public boolean damageEntity(DamageSource damagesource, int i) {
    if (!this.world.isStatic && !this.dead) {
        if (this.isInvulnerable()) {
            return false;
        } else {
            // CraftBukkit start
            Vehicle vehicle = (Vehicle) this.getBukkitEntity();
            org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();

            VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, i);
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return true;
            }

            i = event.getDamage();
            // CraftBukkit end

            this.j(-this.k());
            this.i(10);
            this.J();
            this.setDamage(this.getDamage() + i * 10);
            boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;

            if (flag || this.getDamage() > 40) {
                if (this.passenger != null) {
                    this.passenger.mount(this);
                }

                // CraftBukkit start
                VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
                this.world.getServer().getPluginManager().callEvent(destroyEvent);

                if (destroyEvent.isCancelled()) {
                    this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
                    return true;
                }
                // CraftBukkit end

                if (flag && !this.c()) {
                    this.die();
                } else {
                    this.a(damagesource);
                }
            }

            return true;
        }
    } else {
        return true;
    }
}
项目:Craft-city    文件:EntityBoat.java   
public boolean damageEntity(DamageSource damagesource, int i) {
    if (this.isInvulnerable()) {
        return false;
    } else if (!this.world.isStatic && !this.dead) {
        // CraftBukkit start
        Vehicle vehicle = (Vehicle) this.getBukkitEntity();
        org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();

        VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, i);
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return true;
        }
        // i = event.getDamage(); // TODO Why don't we do this?
        // CraftBukkit end

        this.h(-this.h());
        this.b(10);
        this.setDamage(this.getDamage() + i * 10);
        this.J();
        boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;

        if (flag || this.getDamage() > 40) {
            // CraftBukkit start
            VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
            this.world.getServer().getPluginManager().callEvent(destroyEvent);

            if (destroyEvent.isCancelled()) {
                this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
                return true;
            }
            // CraftBukkit end

            if (this.passenger != null) {
                this.passenger.mount(this);
            }

            if (!flag) {
                this.a(Item.BOAT.id, 1, 0.0F);
            }

            this.die();
        }

        return true;
    } else {
        return true;
    }
}