mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-07 16:57:42 +01:00
Added events for endermen pickup/placement blocks and methods to get/set the block that an enderman is holding. Thanks Wizjany
By: Wizjany <wizjany@gmail.com>
This commit is contained in:
parent
ae629bb348
commit
032a212512
@ -1,6 +1,23 @@
|
||||
package org.bukkit.entity;
|
||||
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
/**
|
||||
* Represents an Enderman.
|
||||
*/
|
||||
public interface Enderman extends Monster {}
|
||||
public interface Enderman extends Monster {
|
||||
|
||||
/**
|
||||
* Get the id and data of the block that the Enderman is carrying.
|
||||
*
|
||||
* @return MaterialData containing the id and data of the block
|
||||
*/
|
||||
public MaterialData getCarriedMaterial();
|
||||
|
||||
/**
|
||||
* Set the id and data of the block that the Enderman is carring.
|
||||
*
|
||||
* @param material data to set the carried block to
|
||||
*/
|
||||
public void setCarriedMaterial(MaterialData material);
|
||||
}
|
||||
|
@ -679,13 +679,24 @@ public abstract class Event implements Serializable {
|
||||
* @see org.bukkit.event.entity.ProjectileHitEvent
|
||||
*/
|
||||
PROJECTILE_HIT (Category.ENTITY),
|
||||
|
||||
/**
|
||||
* Called when a LivingEntity is regains health
|
||||
*
|
||||
* @see org.bukkit.event.entity.EntityRegainHealthEvent
|
||||
*/
|
||||
ENTITY_REGAIN_HEALTH (Category.LIVING_ENTITY),
|
||||
/**
|
||||
* Called when an Enderman picks a block up
|
||||
*
|
||||
* @see org.bukkit.event.entity.EndermanPickupEvent
|
||||
*/
|
||||
ENDERMAN_PICKUP (Category.LIVING_ENTITY),
|
||||
/**
|
||||
* Called when an Enderman places a block
|
||||
*
|
||||
* @see org.bukkit.event.entity.EndermanPlaceEvent
|
||||
*/
|
||||
ENDERMAN_PLACE (Category.LIVING_ENTITY),
|
||||
|
||||
/**
|
||||
* WEATHER EVENTS
|
||||
|
@ -0,0 +1,34 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
public class EndermanPickupEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private boolean cancel;
|
||||
private Block block;
|
||||
|
||||
public EndermanPickupEvent(Entity what, Block block) {
|
||||
super(Type.ENDERMAN_PICKUP, what);
|
||||
this.block = block;
|
||||
this.cancel = false;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block that the enderman is going to pick up.
|
||||
*
|
||||
* @return block the enderman is about to pick up
|
||||
*/
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
public class EndermanPlaceEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private boolean cancel;
|
||||
private Location location;
|
||||
|
||||
public EndermanPlaceEvent(Entity what, Location location) {
|
||||
super(Type.ENDERMAN_PLACE, what);
|
||||
this.location = location;
|
||||
this.cancel = false;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the location that is target of the enderman's placement.
|
||||
*
|
||||
* @return location where the enderman will place its block
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
}
|
@ -134,4 +134,18 @@ public class EntityListener implements Listener {
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
public void onProjectileHit(ProjectileHitEvent event) {}
|
||||
|
||||
/**
|
||||
* Called when an Enderman picks a block up
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
public void onEndermanPickup(EndermanPickupEvent event) {}
|
||||
|
||||
/**
|
||||
* Called when an Enderman places a block
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
public void onEndermanPlace(EndermanPlaceEvent event) {}
|
||||
}
|
||||
|
@ -762,6 +762,20 @@ public class JavaPluginLoader implements PluginLoader {
|
||||
}
|
||||
};
|
||||
|
||||
case ENDERMAN_PICKUP:
|
||||
return new EventExecutor() {
|
||||
public void execute(Listener listener, Event event) {
|
||||
((EntityListener) listener).onEndermanPickup((EndermanPickupEvent) event);
|
||||
}
|
||||
};
|
||||
|
||||
case ENDERMAN_PLACE:
|
||||
return new EventExecutor() {
|
||||
public void execute(Listener listener, Event event) {
|
||||
((EntityListener) listener).onEndermanPlace((EndermanPlaceEvent) event);
|
||||
}
|
||||
};
|
||||
|
||||
// Vehicle Events
|
||||
case VEHICLE_CREATE:
|
||||
return new EventExecutor() {
|
||||
|
Loading…
Reference in New Issue
Block a user