mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-31 21:37:39 +01:00
Implementation of the EntityDamage*Events.
A new event EntityDamageByProjectileEvent was created. EntityDamageByProjectileEvent adds the ability to get the projectile entity (such as an egg) and also set if the projectile 'bounces'. New interfaces were created to facilitate all kinds of projectile entities. Changes were made to facilitate the new event, and enable other events, for plugins and event listeners. By: Andrew Ardill <andrew.ardill@gmail.com>
This commit is contained in:
parent
b105f07fa7
commit
40364131cb
@ -9,7 +9,7 @@ import org.bukkit.World;
|
||||
*/
|
||||
public interface Entity {
|
||||
/**
|
||||
* Gets the entitys current position
|
||||
* Gets the entity's current position
|
||||
*
|
||||
* @return Location containing the position of this entity
|
||||
*/
|
||||
|
9
paper-api/src/main/java/org/bukkit/entity/Fireball.java
Normal file
9
paper-api/src/main/java/org/bukkit/entity/Fireball.java
Normal file
@ -0,0 +1,9 @@
|
||||
package org.bukkit.entity;
|
||||
|
||||
/**
|
||||
* Represents a Fireball.
|
||||
*
|
||||
* @author Cogito
|
||||
*/
|
||||
public interface Fireball extends Entity {
|
||||
}
|
9
paper-api/src/main/java/org/bukkit/entity/Fish.java
Normal file
9
paper-api/src/main/java/org/bukkit/entity/Fish.java
Normal file
@ -0,0 +1,9 @@
|
||||
package org.bukkit.entity;
|
||||
|
||||
/**
|
||||
* Represents a Fish.
|
||||
*
|
||||
* @author Cogito
|
||||
*/
|
||||
public interface Fish extends Entity {
|
||||
}
|
@ -417,6 +417,13 @@ public abstract class Event {
|
||||
* @see org.bukkit.event.entity.EntityDamageByEntityEvent
|
||||
*/
|
||||
ENTITY_DAMAGEDBY_ENTITY (Category.LIVING_ENTITY),
|
||||
|
||||
/**
|
||||
* Called when a LivingEntity is damaged by a projectile Entity
|
||||
*
|
||||
* @see org.bukkit.event.entity.EntityDamageByProjectileEvent
|
||||
*/
|
||||
ENTITY_DAMAGEDBY_PROJECTILE (Category.LIVING_ENTITY),
|
||||
|
||||
/**
|
||||
* Called when a LivingEntity is damaged with no source.
|
||||
|
@ -0,0 +1,35 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class EntityDamageByProjectileEvent extends EntityDamageByEntityEvent {
|
||||
|
||||
private Entity projectile;
|
||||
private boolean bounce;
|
||||
|
||||
public EntityDamageByProjectileEvent(Entity damager, Entity damagee, Entity projectile, DamageCause cause, int damage) {
|
||||
super(damager, damagee, cause, damage);
|
||||
this.projectile = projectile;
|
||||
Random random = new Random();
|
||||
this.bounce = random.nextBoolean();
|
||||
}
|
||||
|
||||
/**
|
||||
* The projectile used to cause the event
|
||||
* @return the projectile
|
||||
*/
|
||||
public Entity getProjectile() {
|
||||
return projectile;
|
||||
}
|
||||
|
||||
public void setBounce(boolean bounce){
|
||||
this.bounce = bounce;
|
||||
}
|
||||
|
||||
public boolean getBounce(){
|
||||
return bounce;
|
||||
}
|
||||
|
||||
}
|
@ -15,6 +15,12 @@ public class EntityListener implements Listener {
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
}
|
||||
|
||||
public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
||||
}
|
||||
|
||||
public void onEntityCombust(EntityCombustEvent event) {
|
||||
}
|
||||
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.server.PluginEvent;
|
||||
@ -216,6 +218,12 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
case ENTITY_DAMAGEDBY_ENTITY:
|
||||
trueListener.onEntityDamageByEntity((EntityDamageByEntityEvent)event);
|
||||
break;
|
||||
case ENTITY_DAMAGEDBY_PROJECTILE:
|
||||
trueListener.onEntityDamageByProjectile((EntityDamageByProjectileEvent)event);
|
||||
break;
|
||||
case ENTITY_DAMAGED:
|
||||
trueListener.onEntityDamage((EntityDamageEvent)event);
|
||||
break;
|
||||
case ENTITY_DEATH:
|
||||
// TODO: ENTITY_DEATH hook
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user