I made a horse mount and whenever I click the apple to spawn it, it doesn't do anything. Code: public class mount extends JavaPlugin implements Listener { public void onEnable() { Bukkit.getServer().getPluginManager().registerEvents(this, this); } @EventHandler public void onPlayerUse(PlayerInteractEvent event) { Player player = event.getPlayer(); if (player.isInsideVehicle()) if (player.getItemInHand().getType().equals(Material.APPLE)) { Horse h = (Horse) player.getWorld().spawnEntity(player.getLocation(), EntityType.HORSE); h.setTamed(true); h.setAdult(); h.setVariant(Horse.Variant.SKELETON_HORSE); h.getInventory().setSaddle(new ItemStack(Material.SADDLE, 1)); h.setPassenger(player); } } }
Well, you are only executing your code to create the mount if the player is inside a vehicle...I'd reckon that's your problem.
Put a "return;" underneath your first Boolean. Also I'd recommend you check if the player's hand isn't null first before checking the item's material type, otherwise errors appear when you interact with air in your hand.