Java Code Examples for org.bukkit.entity.Entity#eject()

The following examples show how to use org.bukkit.entity.Entity#eject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PassengerUtils.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add the passenger to the vehicle
 * @param vehicle - The entity vehicle
 * @param passenger - The entity passenger
 */
public static void addPassenger(Entity vehicle, Entity passenger) {
	if (vehicle == null || passenger == null)
		return;
	if (hasMultiplePassenger()) {
		vehicle.addPassenger(passenger);
	} else {
		try {
			vehicle.eject();
			setPassenger.invoke(vehicle, passenger);
		} catch (final Exception ex) { 
			Skript.exception(ex, "A error occured while trying to set a passenger in version lower than 1.11.2.");
		}
	}
}
 
Example 2
Source File: PassengerUtils.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Remove the passenger from the vehicle.
 * @param vehicle - The entity vehicle
 * @param passenger - The entity passenger
 */
public static void removePassenger(Entity vehicle, Entity passenger){
	if (vehicle == null || passenger == null)
		return;
	if (hasMultiplePassenger()){
		vehicle.removePassenger(passenger);
	} else {
		vehicle.eject();
	}
}
 
Example 3
Source File: HorsesModule.java    From UHC with MIT License 5 votes vote down vote up
protected void kickOffHorse(Player player) {
    final Entity vehicle = player.getVehicle();
    if (vehicle == null) return;

    vehicle.eject();
    player.sendMessage(messages.getRaw("disabled message"));
}