geforkt von Mirrors/Paper
Extend EntityCombustEvent to allow setting combustion duration.
Also extend with two new events that track the entity or block that caused the combustion. By: Andrew Ardill <andrew.ardill@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
3055f33fca
Commit
ae4cd083ac
@ -25,6 +25,8 @@ public interface Projectile extends Entity {
|
|||||||
/**
|
/**
|
||||||
* Determine if this projectile should bounce or not when it hits.
|
* Determine if this projectile should bounce or not when it hits.
|
||||||
*
|
*
|
||||||
|
* If a small fireball does not bounce it will set the target on fire.
|
||||||
|
*
|
||||||
* @return true if it should bounce.
|
* @return true if it should bounce.
|
||||||
*/
|
*/
|
||||||
public boolean doesBounce();
|
public boolean doesBounce();
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package org.bukkit.event.entity;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
|
public class EntityCombustByBlockEvent extends EntityCombustEvent {
|
||||||
|
|
||||||
|
private Block combuster;
|
||||||
|
|
||||||
|
public EntityCombustByBlockEvent(Block combuster, Entity combustee, int duration) {
|
||||||
|
super(combustee, duration);
|
||||||
|
this.combuster = combuster;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The combuster can be lava or a block that is on fire.
|
||||||
|
*
|
||||||
|
* WARNING: block may be null.
|
||||||
|
* @return the Block that set the combustee alight.
|
||||||
|
*/
|
||||||
|
public Block getCombuster() {
|
||||||
|
return combuster;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package org.bukkit.event.entity;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
|
public class EntityCombustByEntityEvent extends EntityCombustEvent {
|
||||||
|
|
||||||
|
private Entity combuster;
|
||||||
|
|
||||||
|
public EntityCombustByEntityEvent(Entity combuster, Entity combustee, int duration) {
|
||||||
|
super(combustee, duration);
|
||||||
|
this.combuster = combuster;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The combuster can be a WeatherStorm a Blaze, or an Entity holding a FIRE_ASPECT enchanted item.
|
||||||
|
* @return the Entity that set the combustee alight.
|
||||||
|
*/
|
||||||
|
public Entity getCombuster() {
|
||||||
|
return combuster;
|
||||||
|
}
|
||||||
|
}
|
@ -4,15 +4,17 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when an entity combusts due to the sun.
|
* Called when an entity combusts.
|
||||||
*<p />
|
*<p />
|
||||||
* If an Entity Combust event is cancelled, the entity will not combust.
|
* If an Entity Combust event is cancelled, the entity will not combust.
|
||||||
*/
|
*/
|
||||||
public class EntityCombustEvent extends EntityEvent implements Cancellable {
|
public class EntityCombustEvent extends EntityEvent implements Cancellable {
|
||||||
|
private int duration;
|
||||||
private boolean cancel;
|
private boolean cancel;
|
||||||
|
|
||||||
public EntityCombustEvent(Entity what) {
|
public EntityCombustEvent(Entity combustee, int duration) {
|
||||||
super(Type.ENTITY_COMBUST, what);
|
super(Type.ENTITY_COMBUST, combustee);
|
||||||
|
this.duration = duration;
|
||||||
this.cancel = false;
|
this.cancel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,4 +25,21 @@ public class EntityCombustEvent extends EntityEvent implements Cancellable {
|
|||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
this.cancel = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the amount of time (in seconds) the combustee should be alight for
|
||||||
|
*/
|
||||||
|
public int getDuration() {
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of seconds the combustee should be alight for.
|
||||||
|
*
|
||||||
|
* This value will only ever increase the combustion time, not decrease existing combustion times.
|
||||||
|
* @param duration the time in seconds to be alight for.
|
||||||
|
*/
|
||||||
|
public void setDuration(int duration) {
|
||||||
|
this.duration = duration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class EntityListener implements Listener {
|
|||||||
public void onItemSpawn(ItemSpawnEvent event) {}
|
public void onItemSpawn(ItemSpawnEvent event) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when an entity combusts due to the sun.
|
* Called when an entity combusts.
|
||||||
*<p />
|
*<p />
|
||||||
* If an Entity Combust event is cancelled, the entity will not combust.
|
* If an Entity Combust event is cancelled, the entity will not combust.
|
||||||
*
|
*
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren