mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 15:00:13 +01:00
Change vehicle hook changes.
By: sk89q <the.sk89q@gmail.com>
This commit is contained in:
parent
2ff558c10b
commit
04c824307a
6 changed files with 44 additions and 32 deletions
|
@ -337,7 +337,7 @@ public abstract class Event {
|
|||
/**
|
||||
* Called when a vehicle is placed by a player
|
||||
*/
|
||||
VEHICLE_PLACE (Category.VEHICLE),
|
||||
VEHICLE_CREATE (Category.VEHICLE),
|
||||
|
||||
/**
|
||||
* Called when a vehicle is damaged by a LivingEntity
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package org.bukkit.event.vehicle;
|
||||
|
||||
import org.bukkit.Vehicle;
|
||||
|
||||
/**
|
||||
* Raised when a vehicle is created.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class VehicleCreateEvent extends VehicleEvent {
|
||||
public VehicleCreateEvent(Type type, Vehicle vehicle) {
|
||||
super(type, vehicle);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package org.bukkit.event.vehicle;
|
||||
|
||||
import org.bukkit.Entity;
|
||||
import org.bukkit.Vehicle;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
|
@ -9,10 +10,31 @@ import org.bukkit.event.Cancellable;
|
|||
* @author sk89q
|
||||
*/
|
||||
public class VehicleDamageEvent extends VehicleEvent implements Cancellable {
|
||||
private Entity attacker;
|
||||
private int damage;
|
||||
private boolean cancelled;
|
||||
|
||||
public VehicleDamageEvent(Type type, Vehicle vehicle) {
|
||||
public VehicleDamageEvent(Type type, Vehicle vehicle, Entity attacker, int damage) {
|
||||
super(type, vehicle);
|
||||
this.attacker = attacker;
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public Entity getAttacker() {
|
||||
return attacker;
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the damage.
|
||||
*
|
||||
* @param damage
|
||||
*/
|
||||
public void setDamage(int damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
|
|
|
@ -7,11 +7,12 @@ package org.bukkit.event.vehicle;
|
|||
*/
|
||||
public class VehicleListener {
|
||||
/**
|
||||
* Called when a vehicle is placed by a player.
|
||||
* Called when a vehicle is created by a player. This hook will be called
|
||||
* for all vehicles created.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void onVehiclePlace(VehiclePlaceEvent event) {
|
||||
public void onVehicleCreate(VehicleCreateEvent event) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
package org.bukkit.event.vehicle;
|
||||
|
||||
import org.bukkit.Vehicle;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
/**
|
||||
* Raised when a vehicle is placed by a player.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class VehiclePlaceEvent extends VehicleEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
|
||||
public VehiclePlaceEvent(Type type, Vehicle vehicle) {
|
||||
super(type, vehicle);
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
}
|
|
@ -137,8 +137,8 @@ public final class JavaPluginLoader implements PluginLoader {
|
|||
VehicleListener trueListener = (VehicleListener)listener;
|
||||
|
||||
switch (event.getType()) {
|
||||
case VEHICLE_PLACE:
|
||||
trueListener.onVehiclePlace((VehiclePlaceEvent)event);
|
||||
case VEHICLE_CREATE:
|
||||
trueListener.onVehicleCreate((VehicleCreateEvent)event);
|
||||
break;
|
||||
case VEHICLE_DAMAGE:
|
||||
trueListener.onVehicleDamage((VehicleDamageEvent)event);
|
||||
|
|
Loading…
Reference in a new issue