/** @param event */
  @EventHandler(priority = EventPriority.HIGH)
  public void onVehicleDestroy(VehicleDestroyEvent event) {
    Vehicle vehicle = event.getVehicle();

    Field field =
        plugin
            .getForceFieldManager()
            .getEnabledSourceField(vehicle.getLocation(), FieldFlag.PREVENT_VEHICLE_DESTROY);

    if (field != null) {
      if (event.getAttacker() instanceof Player) {
        Player player = (Player) event.getAttacker();

        if (FieldFlag.PREVENT_VEHICLE_DESTROY.applies(field, player)) {
          if (plugin.getPermissionsManager().has(player, "preciousstones.bypass.destroy")) {
            plugin.getCommunicationManager().notifyBypassDestroyVehicle(player, vehicle, field);
          } else {
            event.setCancelled(true);
            plugin.getCommunicationManager().warnDestroyVehicle(player, vehicle, field);
            return;
          }
        }
      }
    }
  }
Esempio n. 2
0
 @EventHandler
 public void onDestroyed(VehicleDestroyEvent e) {
   String time = DateFormat.getInstance().format(new Date(System.currentTimeMillis())) + " ";
   Location loc = e.getVehicle().getLocation();
   String entity = "";
   if (e.getAttacker() != null) {
     entity = "by " + e.getAttacker().getClass();
   }
   out.log(
       time
           + e.getVehicle().toString()
           + " "
           + plugin.translate("vehicle.destroy")
           + " "
           + entity
           + " "
           + plugin.translate("in")
           + " ["
           + (int) loc.getX()
           + ","
           + (int) loc.getY()
           + ","
           + (int) loc.getZ()
           + "]");
 }
 @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);
 }
 @EventHandler(ignoreCancelled = true)
 public void onVehicleDestroyed(VehicleDestroyEvent event) {
   vehicle = new dEntity(event.getVehicle());
   entity = event.getAttacker() != null ? new dEntity(event.getAttacker()) : null;
   this.event = event;
   cancelled = event.isCancelled();
   fire();
   event.setCancelled(cancelled);
 }
 @Override
 public void destroy() {
   VehicleDestroyEvent.getHandlerList().unregister(this);
 }