Added painting events (thanks verrier and tanelsuurhans)

By: Stephen <stephen@jazer.com>
This commit is contained in:
Bukkit/Spigot
2011-04-11 23:06:34 -04:00
parent 314c53177e
commit 08decac14e
8 changed files with 232 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
package org.bukkit.event.painting;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Painting;
/**
* Triggered when a painting is removed by an entity
*
* @author Tanel Suurhans
*/
public class PaintingBreakByEntityEvent extends PaintingBreakEvent {
private Entity remover;
public PaintingBreakByEntityEvent(final Painting painting, final Entity remover) {
super(painting, RemoveCause.ENTITY);
this.remover = remover;
}
public Entity getRemover() {
return remover;
}
}

View File

@@ -0,0 +1,15 @@
package org.bukkit.event.painting;
import org.bukkit.entity.Painting;
/**
* Triggered when a painting is removed by the world (water flowing over it, block damaged behind it)
*
* @author Tanel Suurhans
*/
public class PaintingBreakByWorldEvent extends PaintingBreakEvent{
public PaintingBreakByWorldEvent(final Painting painting) {
super(painting, RemoveCause.WORLD);
}
}

View File

@@ -0,0 +1,52 @@
package org.bukkit.event.painting;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Painting;
import org.bukkit.event.Cancellable;
/**
* Triggered when a painting is removed
*
* @author Tanel Suurhans
*/
public class PaintingBreakEvent extends PaintingEvent implements Cancellable {
private boolean cancelled;
private RemoveCause cause;
public PaintingBreakEvent(final Painting painting, RemoveCause cause) {
super(Type.PAINTING_BREAK, painting);
this.cause = cause;
}
public RemoveCause getCause(){
return cause;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
/**
* An enum to specify the cause of the removal
*/
public enum RemoveCause {
/**
* Removed by an entity
*/
ENTITY,
/**
* Removed by the world - block destroyed behind, water flowing over etc
*/
WORLD
}
}

View File

@@ -0,0 +1,29 @@
package org.bukkit.event.painting;
import org.bukkit.entity.Painting;
import org.bukkit.event.Event;
/**
* Represents a painting-related event.
*
* @author Tanel Suurhans
*/
public class PaintingEvent extends Event {
protected Painting painting;
protected PaintingEvent(final Type type, final Painting painting) {
super(type);
this.painting = painting;
}
/**
* Get the painting.
*
* @return the painting
*/
public Painting getPainting() {
return painting;
}
}

View File

@@ -0,0 +1,65 @@
package org.bukkit.event.painting;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Painting;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
/**
* Triggered when a painting is created in the world
*
* @author Tanel Suurhans
*/
public class PaintingPlaceEvent extends PaintingEvent implements Cancellable {
private boolean cancelled;
private Player player;
private Block block;
private BlockFace blockFace;
public PaintingPlaceEvent(final Painting painting, final Player player, Block block, BlockFace blockFace) {
super(Event.Type.PAINTING_PLACE, painting);
this.player = player;
this.block = block;
this.blockFace = blockFace;
}
/**
* Returns the player placing the painting
*
* @return Entity returns the player placing the painting
*/
public Player getPlayer() {
return player;
}
/**
* Returns the block painting placed on
*
* @return Block returns the block painting placed on
*/
public Block getBlock() {
return block;
}
/**
* Returns the face of the block that the painting was placed on
*
* @return BlockFace returns the face of the block the painting was placed on
*/
public BlockFace getBlockFace() {
return blockFace;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
}