本文整理汇总了Java中org.bukkit.event.vehicle.VehicleDestroyEvent类的典型用法代码示例。如果您正苦于以下问题:Java VehicleDestroyEvent类的具体用法?Java VehicleDestroyEvent怎么用?Java VehicleDestroyEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VehicleDestroyEvent类属于org.bukkit.event.vehicle包,在下文中一共展示了VehicleDestroyEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttacker
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
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;
}
示例2: getAttacker
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
@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;
}
示例3: onVehicleBreak
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
@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);
}
}
示例4: onVehicleBreak
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
@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);
}
}
示例5: onVehicleDestroy
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
@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);
}
}
示例6: onBoatHit
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
/**
* @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);
}
}
示例7: onVehicleDestroy
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
@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!");
}
}
}
}
}
}
示例8: onVehicleDestroy
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
@EventHandler
public void onVehicleDestroy(VehicleDestroyEvent event) {
if (event.getAttacker() != null && event.getAttacker() instanceof Player) {
if (isSpectating((Player) event.getAttacker())) {
event.setCancelled(true);
}
}
}
示例9: init
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
@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;
}
示例10: a
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
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);
}
}
示例11: on
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
@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!"));
}
示例12: onVehicleDestroy
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
@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());
}
示例13: onVehicleDestroy
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
@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);
}
}
}
}
}
示例14: onVehicleDestroy
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
@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); }
}
示例15: VehicleDestroy
import org.bukkit.event.vehicle.VehicleDestroyEvent; //导入依赖的package包/类
@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);
}