Solved Horse Mount

Discussion in 'Plugin Development' started by king_of_all96543, Jan 1, 2014.

Thread Status:
Not open for further replies.
  1. Hello guys i am trying to figure out the event for when a player mounts a horse. I honestly dont know this i googled it but i couldnt find it. If you can help me that would be great! Thank you.
     
  2. Offline

    Gater12

  3. Gater12 Im not sure but i will check it out thanks.
    Edit: Thanks i believed that worked, but just to make sure i check if the Vehicle is a horse with this right?
    Code:
    @EventHandler
        public void onHorse(VehicleEnterEvent e){
            Entity h = e.getVehicle();
            Player p = (Player) e.getEntered();
            if(!rider.contains(p.getName())){
                if(h.equals(EntityType.HORSE)){
                    e.setCancelled(true);
                    p.sendMessage(ChatColor.RED + "You are not a rider, you may not ride this horse!");
                }
           
            }
           
        }
     
  4. Offline

    Forseth11

    @king_of_all96543 VehicleEnterEvent​
     
  5. Forseth11 Thanks for confirming the event for me. Just to make sure is the code i gave up above the correct way to check if its a horse?
     
  6. Offline

    Forseth11

    king_of_all96543 Mostly. You need to make sure the rider is a player before implementing 'p'.
     
  7. Offline

    Gater12

  8. Offline

    Bart

    You can also do
    Code:java
    1. if(h instanceof Horse)
     
    Gater12 likes this.
Thread Status:
Not open for further replies.

Share This Page