13
0
geforkt von Mirrors/Paper

[Bleeding] Added Sheep, Shear and EntityChangeBlock API. Thanks tips48! Closes BUKKIT-512

By: Aidan Matzko <amatzko48@gmail.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2012-01-21 21:20:49 -05:00
Ursprung 05b6ad92d1
Commit 7e5c1baee9
6 geänderte Dateien mit 232 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -8,13 +8,11 @@ import org.bukkit.material.Colorable;
public interface Sheep extends Animals, Colorable {
/**
* @author Celtic Minstrel
* @return Whether the sheep is sheared.
*/
public boolean isSheared();
/**
* @author Celtic Minstrel
* @param flag Whether to shear the sheep
*/
public void setSheared(boolean flag);

Datei anzeigen

@ -375,6 +375,12 @@ public abstract class Event implements Serializable {
* @see org.bukkit.event.player.PlayerExpChangeEvent
*/
PLAYER_EXP_CHANGE(Category.PLAYER, PlayerExpChangeEvent.class),
/**
* Called when a player shears an entity
*
* @see org.bukkit.event.player.PlayerShearEntityEvent
*/
PLAYER_SHEAR_ENTITY(Category.LIVING_ENTITY, PlayerShearEntityEvent.class),
/**
* BLOCK EVENTS
@ -738,6 +744,18 @@ public abstract class Event implements Serializable {
* @see org.bukkit.event.entity.EntityTargetEvent
*/
ENTITY_TARGET(Category.LIVING_ENTITY, EntityTargetEvent.class),
/**
* Called when a sheep regrows its wool
*
* @see org.bukkit.event.entity.SheepRegrowWoolEvent
*/
SHEEP_REGROW_WOOL(Category.LIVING_ENTITY, SheepRegrowWoolEvent.class),
/**
* Called when a sheep's wool is dyed
*
* @see org.bukkit.event.entity.SheepDyeWoolEvent
*/
SHEEP_DYE_WOOL(Category.LIVING_ENTITY, SheepDyeWoolEvent.class),
/**
* Called when an entity interacts with a block
* This event specifically excludes player entities
@ -763,6 +781,14 @@ public abstract class Event implements Serializable {
* @see org.bukkit.event.entity.EntityTameEvent
*/
ENTITY_TAME(Category.LIVING_ENTITY, EntityTameEvent.class),
/**
* Called when a LivingEntity changes a block
*
* This event specifically excludes player entities
*
* @see org.bukkit.event.entity.EntityChangeBlockEvent
*/
ENTITY_CHANGE_BLOCK(Category.LIVING_ENTITY, EntityChangeBlockEvent.class),
/**
* Called when a {@link Projectile} hits something
*

Datei anzeigen

@ -0,0 +1,62 @@
package org.bukkit.event.entity;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@SuppressWarnings("serial")
/**
* Called when a LivingEntity changes a block
*
* This event specifically excludes player entities
*/
public class EntityChangeBlockEvent extends EntityEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private Block block;
private boolean cancel;
private Material to;
public EntityChangeBlockEvent(Entity what, Block block, Material to) {
super(Type.ENTITY_CHANGE_BLOCK, what);
this.block = block;
this.cancel = false;
this.to = to;
}
/**
* Gets the block the entity is changing
*
* @return the block that is changing
*/
public Block getBlock() {
return block;
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
/**
* Gets the Material that the block is changing into
*
* @return the material that the block is changing into
*/
public Material getTo() {
return to;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

Datei anzeigen

@ -0,0 +1,58 @@
package org.bukkit.event.entity;
import org.bukkit.DyeColor;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@SuppressWarnings("serial")
/**
* Called when a sheep's wool is dyed
*/
public class SheepDyeWoolEvent extends EntityEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel;
private DyeColor color;
public SheepDyeWoolEvent(Entity what, DyeColor color) {
super(Type.SHEEP_DYE_WOOL, what);
this.cancel = false;
this.color = color;
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
/**
* Gets the DyeColor the sheep is being dyed
*
* @return the DyeColor the sheep is being dyed
*/
public DyeColor getColor() {
return color;
}
/**
* Sets the DyeColor the sheep is being dyed
*
* @param color the DyeColor the sheep will be dyed
*/
public void setColor(DyeColor color) {
this.color = color;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

Datei anzeigen

@ -0,0 +1,37 @@
package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@SuppressWarnings("serial")
/**
* Called when a sheep regrows its wool
*/
public class SheepRegrowWoolEvent extends EntityEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel;
public SheepRegrowWoolEvent(Entity what) {
super(Type.SHEEP_REGROW_WOOL, what);
this.cancel = false;
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

Datei anzeigen

@ -0,0 +1,49 @@
package org.bukkit.event.player;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@SuppressWarnings("serial")
/**
* Called when a player shears an entity
*/
public class PlayerShearEntityEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel;
private Entity what;
public PlayerShearEntityEvent(Player who, Entity what) {
super(Type.PLAYER_SHEAR_ENTITY, who);
this.cancel = false;
this.what = what;
}
public boolean isCancelled() {
return cancel;
}
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
/**
* Gets the entity the player is shearing
*
* @return the entity the player is shearing
*/
public Entity getEntity() {
return what;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}