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

项目:RPGInventory    文件:PetListener.java   
@EventHandler
public void onMountPet(VehicleEnterEvent event) {
    if (event.getEntered().getType() != EntityType.PLAYER || event.getVehicle().getType() != EntityType.HORSE) {
        return;
    }

    Player player = (Player) event.getEntered();
    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    Horse vehicle = (Horse) event.getVehicle();
    if (PetManager.getPetFromEntity(vehicle, player) != null && player != vehicle.getOwner()) {
        PlayerUtils.sendMessage(player, RPGInventory.getLanguage().getMessage("error.mount.owner", vehicle.getOwner().getName()));
        event.setCancelled(true);
    }
}
项目:Skript    文件:ExprVehicle.java   
@Override
protected Entity[] get(final Event e, final Entity[] source) {
    return get(source, new Converter<Entity, Entity>() {
        @Override
        @Nullable
        public Entity convert(final Entity p) {
            if (getTime() >= 0 && e instanceof VehicleEnterEvent && p.equals(((VehicleEnterEvent) e).getEntered()) && !Delay.isDelayed(e)) {
                return ((VehicleEnterEvent) e).getVehicle();
            }
            if (getTime() >= 0 && e instanceof VehicleExitEvent && p.equals(((VehicleExitEvent) e).getExited()) && !Delay.isDelayed(e)) {
                return ((VehicleExitEvent) e).getVehicle();
            }
            return p.getVehicle();
        }
    });
}
项目:Skript    文件:ExprPassenger.java   
@Override
protected Entity[] get(final Event e, final Entity[] source) {
    return get(source, new Converter<Entity, Entity>() {
        @Override
        @Nullable
        public Entity convert(final Entity v) {
            if (getTime() >= 0 && e instanceof VehicleEnterEvent && v.equals(((VehicleEnterEvent) e).getVehicle()) && !Delay.isDelayed(e)) {
                return ((VehicleEnterEvent) e).getEntered();
            }
            if (getTime() >= 0 && e instanceof VehicleExitEvent && v.equals(((VehicleExitEvent) e).getVehicle()) && !Delay.isDelayed(e)) {
                return ((VehicleExitEvent) e).getExited();
            }
            return v.getPassenger();
        }
    });
}
项目:NovaGuilds    文件:RegionInteractListener.java   
@EventHandler
public void onVehicleEnter(VehicleEnterEvent event) {
    Vehicle vehicle = event.getVehicle();

    if(!(event.getEntered() instanceof Player)) {
        return;
    }

    final Player player = (Player) event.getEntered();
    NovaPlayer nPlayer = PlayerManager.getPlayer(player);

    List<String> denyRiding = Config.REGION_DENYRIDING.getStringList();

    if(denyRiding.contains(vehicle.getType().name())
            && RegionManager.get(vehicle) != null
            && (!plugin.getRegionManager().canInteract(player, vehicle) || (!nPlayer.getPreferences().getBypass() && !nPlayer.hasPermission(GuildPermission.MOB_RIDE)))
            && !PlayerManager.getPlayer(event.getEntered()).isVehicleListed(vehicle)) {
        event.setCancelled(true);
        Message.CHAT_REGION_DENY_RIDEMOB.send(event.getEntered());
    }
}
项目:horsekeep    文件:HorseKeep.java   
@EventHandler(priority = EventPriority.HIGH)
  public void onVehicleEnter(VehicleEnterEvent event)
  {
if (!(event.getEntered() instanceof Player)) { return; }

Player player = (Player) event.getEntered();

   if (this.manager.isHorse(event.getVehicle()))
   {
    Horse horse = (Horse) event.getVehicle();

    if (this.manager.isOwned(horse.getUniqueId()))
    {
        if (!this.manager.canMountHorse(player, horse) && !perm.has(player, "horsekeep.bypass.mount"))
        {
            String ownerName = this.manager.getOwnerName(horse.getUniqueId());

            if (ownerName == null) ownerName = "Unknown";

            player.sendMessage(this.getChatPrefix() + this.lang.get("horseBelongsTo").replace("%player", ownerName));

            event.setCancelled(true);
        }
    }
   }
  }
项目:modules-extra    文件:ListenerVehicle.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onVehicleEnter(final VehicleEnterEvent event)
{
    if (event.getEntered() instanceof Player)
    {
        VehicleEnter action = this.newAction(VehicleEnter.class, event.getEntered().getWorld());
        if (action != null)
        {
            action.setVehicle(event.getVehicle());
            action.setLocation(event.getVehicle().getLocation());
            action.setPlayer((Player)event.getEntered());
            this.logAction(action);
        }
    }
    else
    {
        // TODO entity vehicle enter
    }
}
项目:AddGun    文件:PlayerListener.java   
/**
 * We keep track of players entering and exiting vehicles.
 * 
 * @param event
 *  the entrance event
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void vehicleEnterEvent(VehicleEnterEvent event) {
    if (event.getEntered() != null && event.getVehicle() != null && event.getEntered() instanceof Player) {
        Player eventPlayer = (Player) event.getEntered();
        vehicleSince.computeIfAbsent(eventPlayer.getUniqueId(), u -> {
            //if (eventPlayer.hasPermission("addgun.data")) {eventPlayer.sendMessage(ChatColor.GOLD + " entered vehicle"); }
            return System.currentTimeMillis(); 
        });
        vehicleLeft.remove(eventPlayer.getUniqueId());
    }
}
项目:HCFCore    文件:ProtectionListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onVehicleEnter(VehicleEnterEvent event) {
    Entity entered = event.getEntered();
    if (entered instanceof Player) {
        Vehicle vehicle = event.getVehicle();
        if (vehicle instanceof Horse) {
            Horse horse = (Horse) event.getVehicle();
            AnimalTamer owner = horse.getOwner();
            if (owner != null && !owner.equals(entered)) {
                ((Player) entered).sendMessage(ChatColor.YELLOW + "You cannot ride a Horse that belongs to " + ChatColor.RED + owner.getName() + ChatColor.YELLOW + '.');
                event.setCancelled(true);
            }
        }
    }
}
项目:HCFCore    文件:ProtectionListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onVehicleEnter(VehicleEnterEvent event) {
    Entity entered = event.getEntered();
    if (entered instanceof Player) {
        Vehicle vehicle = event.getVehicle();
        if (vehicle instanceof Horse) {
            Horse horse = (Horse) event.getVehicle();
            AnimalTamer owner = horse.getOwner();
            if (owner != null && !owner.equals(entered)) {
                ((Player) entered).sendMessage(ChatColor.YELLOW + "You cannot ride a Horse that belongs to " + ChatColor.RED + owner.getName() + ChatColor.YELLOW + '.');
                event.setCancelled(true);
            }
        }
    }
}
项目:AthenaGM    文件:SpectatorModule.java   
@EventHandler
public void onVehicleEnter(VehicleEnterEvent event) {
    if (event.getEntered() instanceof Player) {
        Player player = (Player) event.getEntered();
        if (isPlayerSpectator(player)) {
            event.setCancelled(true);
        }
    }
}
项目:Cardinal    文件:InteractModule.java   
/**
 * Prevents a player that can't interact from entering vehicles.
 *
 * @param event The event.
 */
@EventHandler(ignoreCancelled = true)
public void onVehicleEnter(VehicleEnterEvent event) {
  if (event.getActor() instanceof Player && !canInteract((Player) event.getActor())) {
    event.setCancelled(true);
  }
}
项目:uSkyBlock    文件:ExploitEvents.java   
@EventHandler
public void on(VehicleEnterEvent e) {
    if (mountEnabled || !(e.getEntered() instanceof Player)) {
        return;
    }
    Player player = (Player) e.getEntered();
    if (hasPermission(player, "usb.mod.bypassprotection") || plugin.playerIsOnIsland(player)) {
        return;
    }
    e.setCancelled(true);
    player.sendMessage(tr("\u00a7eRiding is only allowed on your own island!"));
}
项目:AntiCheat-COMPAT    文件:VehicleListener.java   
@EventHandler(ignoreCancelled = true)
public void onVehicleEnter(VehicleEnterEvent event) {
    if (event.getEntered() instanceof Player) {
        getBackend().logEnterExit((Player) event.getEntered());
    }

    AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
项目:BetonQuest    文件:VehicleObjective.java   
@EventHandler
public void onVehicleEnter(VehicleEnterEvent event) {
    if (!(event.getEntered() instanceof Player))
        return;
    String playerID = PlayerConverter.getID((Player) event.getEntered());
    if (containsPlayer(playerID) && (any || event.getVehicle().getType() == vehicle) && checkConditions(playerID)) {
        completeObjective(playerID);
    }
}
项目:CrazyLogin    文件:DynamicVehicleListener.java   
@EventHandler
public void VehicleEnter(final VehicleEnterEvent event)
{
    if (!(event.getVehicle().getPassenger() instanceof Player))
        return;
    final Player player = (Player) event.getVehicle().getPassenger();
    if (plugin.isLoggedIn(player))
        return;
    event.setCancelled(true);
    plugin.sendAuthReminderMessage(player);
}
项目:HorseMount    文件:HorseMount.java   
@EventHandler
public void onVehicleEnter(VehicleEnterEvent event) {
    Player player = (Player) event.getEntered();
    if (player.getVehicle() instanceof Horse) {
        player.getVehicle().remove();
        msgPlayer(player, "Automatically dismounted due to vehicle change.");
    }
}
项目:SpectatorPlus    文件:SpectatorsInteractionsListener.java   
/**
 * Stops spectators riding horses, Minecarts, etc.
 */
@EventHandler (priority = EventPriority.HIGHEST)
public void onVehicleEnter(final VehicleEnterEvent e)
{
    if (e.getEntered() instanceof Player && p.getPlayerData((Player) e.getEntered()).isSpectating())
    {
        e.setCancelled(true);
    }
}
项目:Shopkeepers    文件:LivingEntityShopListener.java   
@EventHandler(ignoreCancelled = true)
void onEntityEnterVehicle(VehicleEnterEvent event) {
    Entity entity = event.getEntered();
    if (plugin.isShopkeeper(entity)) {
        event.setCancelled(true);
    }
}
项目:ProjectAres    文件:EventFilterMatchModule.java   
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onVehicleEnter(final VehicleEnterEvent event) {
    cancelUnlessInteracting(event, event.getEntered());
}
项目:ProjectAres    文件:FreezeListener.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVehicleEnter(final VehicleEnterEvent event) {
    if(freeze.isFrozen(event.getEntered())) {
        event.setCancelled(true);
    }
}
项目:SkyWarsReloaded    文件:SpectatorListener.java   
@EventHandler
public void onVehicleEnter(VehicleEnterEvent e) {
    if (e.getEntered() instanceof Player && SkyWarsReloaded.getPC().getPlayer(((Player) e.getEntered()).getUniqueId()).isSpectating()) {
        e.setCancelled(true);
    }
}
项目:GamePlate    文件:ObserverModule.java   
@EventHandler
public void onVehicleEnter(VehicleEnterEvent event) {
    if (event.getEntered() instanceof Player && isObserver((Player) event.getEntered())) {
        event.setCancelled(true);
    }
}
项目:Skript    文件:ExprVehicle.java   
@SuppressWarnings("unchecked")
@Override
public boolean setTime(final int time) {
    return super.setTime(time, getExpr(), VehicleEnterEvent.class, VehicleExitEvent.class);
}
项目:Skript    文件:ExprPassenger.java   
@SuppressWarnings("unchecked")
@Override
public boolean setTime(final int time) {
    return super.setTime(time, getExpr(), VehicleEnterEvent.class, VehicleExitEvent.class);
}
项目:AbilityAPI    文件:SequenceListener.java   
@EventHandler
public void onVehicleEnter(VehicleEnterEvent event) {
    if (event.getEntered() instanceof Player) {
        this.manager.invoke((Player) event.getEntered(), event);
    }
}
项目:Arcade2    文件:ObserverListeners.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVehicleEnter(VehicleEnterEvent event) {
    if (this.isObserving(event.getEntered())) {
        event.setCancelled(true);
    }
}
项目:Cardinal-Plus    文件:ObserverModule.java   
@EventHandler
public void onVehicleEnter(VehicleEnterEvent event) {
    if (!match.isRunning() || event.getEntered() instanceof Player && TeamUtils.getTeamByPlayer((Player) event.getEntered()).isObserver()) {
        event.setCancelled(true);
    }
}
项目:NoHack    文件:NoHackListener.java   
@EventHandler(ignoreCancelled = true)
public void onMount(VehicleEnterEvent event) {

    if (event.getEntered() instanceof Player) {

        Player p = (Player) event.getEntered();

        MoveData md = nh.vars.getMoveData(p.getName());

        md.lastmounting = System.currentTimeMillis();

        nh.vars.setMoveData(p.getName(), md);

    }

}
项目:ProtocolSupport    文件:MultiplePassengersRestrict.java   
@EventHandler(ignoreCancelled = true)
public void onVehicleEnter(VehicleEnterEvent event) {
    if (!event.getVehicle().getPassengers().isEmpty() && needsRestrict()) {
        event.setCancelled(true);
    }
}
项目:CraftoPlugin    文件:EntityProtectionBreakListener.java   
@EventHandler
public void onVehicleEnter(final VehicleEnterEvent event) {
    if (!(event.getEntered() instanceof Player)) { return; }
    if (!this.canInteract(event.getVehicle(), (Player)event.getEntered())) { event.setCancelled(true); }
}
项目:CardinalPGM    文件:ObserverModule.java   
@EventHandler
public void onVehicleEnter(VehicleEnterEvent event) {
    if (event.getEntered() instanceof Player && testObserverOrDead((Player) event.getEntered())) {
        event.setCancelled(true);
    }
}
项目:ECHorses    文件:ECHorsesListeners.java   
@EventHandler
    public void horseEnter(VehicleEnterEvent event){

    if(event.getVehicle() instanceof Horse){

      EntityType entered = (EntityType)event.getEntered().getType();
      if(entered == EntityType.PLAYER){ //Playercheck

          Player p = (Player)event.getEntered();
          String playername = p.getName();
          @SuppressWarnings("unused")
        Server server = p.getServer(); //Not used for now
          Horse h = (Horse)event.getVehicle();
          AnimalTamer owner = h.getOwner();
          HashMap<String, ArrayList<Block>> map = ECHorses.hashmap; //Getting hashmap from main class
          if(map.containsKey(playername)){ //If player has done /horseunclaim, then when the player left click the horse, unclaim the horse.
              if(owner == null){
                  p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.GREEN + " Nobody owns this horse!");

                  return;
              }
              if(!(owner == null)){
                  if(p.isOp() || p.hasPermission("echorse.override")){
                      p.sendMessage("You are overriding horse protection!");
                      h.setOwner(null); //Removing horse claim (untame horse)
                      map.remove(playername); //Remove the player from hashmap.
                      return;
                  }
                 if(h.getOwner().getName() == p.getName()){ //Owner check
                    Location loc = h.getLocation().clone();
                    Inventory inv = h.getInventory();
                    for (ItemStack item : inv.getContents()){ //Checking if the horse has saddle & armor & or something its inventory (Donkey)
                        if(item!= null){
                            loc.getWorld().dropItemNaturally(loc, item.clone()); //Drops all the inventory contents on the horse location ground.
                        }
                    }
                    inv.clear(); //Clears the inventory of the horse.
                    if(h.isCarryingChest()){ //If the horse is carrying a chest (Donkey)
                        h.setCarryingChest(false); //if true then remove the chest.
                    }
                     h.setOwner(null); //Remove horse claim (untame horse.)
                     p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.GOLD + " Successfully removed horse protection. (Horse is not tamed anymore)");
                     map.remove(playername); //Remove the player from hashmap.
                     event.setCancelled(true);
                     return;
                 }        
              }
          }    
          //Horse stealing protection (Entering the horse)
          if(!(owner == null)){

              if(p.isOp() || p.hasPermission("echorse.override")){ //Overriding the protection if player is OP
                  return;
              }
              if(h.getOwner().getName() == p.getName()){ //Checking if entering player is the owner
              return;
              }
              else {
                  p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.RED + " This horse is owned by " + h.getOwner().getName());
                  Bukkit.getLogger().info("[ECHorses] " + playername + " tried entering someone elses horse");
                  event.setCancelled(true);
                  return;
              }
          } 
       p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.GREEN + " This horse is untamed!"); 
      }     
    }
}
项目:FlyingTub    文件:TubFlightListener.java   
@EventHandler(ignoreCancelled=true)
public final void onVehicleEnter(VehicleEnterEvent event) {
    fixCart(event.getVehicle());
}