Using a run task later scheduler, but can't find if a player is riding an entity. I know it's something along the lines, p.getEntity().getVehicle() instanceof CustomMob but can't really find it.
p.getVehicle() works for me. But I'd first check if the player is in a vehicle: p.isInsideVehicle and then what you did (instanceof) for Horse.
I tried it out with this: Code (Text): public void onTime(final Player p) { Bukkit.getScheduler().runTaskLater(Core.getInstance(), new Runnable() { @Override public void run() { if(p.isInsideVehicle()) { if (p.getVehicle() != null) { if (!(p.getVehicle() instanceof Horse)) { Entity entity = p.getVehicle(); entity.remove(); } } } } },20L); }
Yep that should work. However there is no reason to check whether vehicle != null, since you already checked whether the player is in a vehicle.