Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void onBoatCollideWithEntity(VehicleEntityCollisionEvent event) {
- // You get the entity that was hit.
- Entity entity = event.getEntity();
- // You get the vehicle that hit the entity.
- Vehicle vehicle = event.getVehicle();
- // You ignore this event if the vehicle is not a boat.
- if(!(vehicle instanceof Boat)){
- return;
- }
- // You get the primary passenger of the vehicle.
- Entity passenger = vehicle.getPassenger();
- // You ignore this event if the boat was driven by anything other than a player.
- if(!(entity instanceof Player)){
- return;
- }
- // You get the player instance.
- Player player = (Player) passenger;
- // You check what entity was hit by the boat.
- switch(entity.getType()){
- case BOAT:
- player.sendMessage("You hit a rival!");
- return;
- case ARMOR_STAND:
- player.sendMessage("You hit an armorstand!");
- player.sendMessage("You have received a boost!");
- // add boost here.
- return;
- default:
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement