[Bleeding] Add new events for Hanging entities, deprecate old Painting
events. Adds BUKKIT-2754
This commit is contained in:
parent
57ea30e152
commit
4bd2bddc90
@ -0,0 +1,25 @@
|
|||||||
|
package org.bukkit.event.hanging;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Hanging;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered when a hanging entity is removed by an entity
|
||||||
|
*/
|
||||||
|
public class HangingBreakByEntityEvent extends HangingBreakEvent {
|
||||||
|
private final Entity remover;
|
||||||
|
|
||||||
|
public HangingBreakByEntityEvent(final Hanging hanging, final Entity remover) {
|
||||||
|
super(hanging, HangingBreakEvent.RemoveCause.ENTITY);
|
||||||
|
this.remover = remover;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the entity that removed the hanging entity
|
||||||
|
*
|
||||||
|
* @return the entity that removed the hanging entity
|
||||||
|
*/
|
||||||
|
public Entity getRemover() {
|
||||||
|
return remover;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package org.bukkit.event.hanging;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Hanging;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered when a hanging entity is removed
|
||||||
|
*/
|
||||||
|
public class HangingBreakEvent extends HangingEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancelled;
|
||||||
|
private final HangingBreakEvent.RemoveCause cause;
|
||||||
|
|
||||||
|
public HangingBreakEvent(final Hanging hanging, final HangingBreakEvent.RemoveCause cause) {
|
||||||
|
super(hanging);
|
||||||
|
this.cause = cause;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cause for the hanging entity's removal
|
||||||
|
*
|
||||||
|
* @return the RemoveCause for the hanging entity's removal
|
||||||
|
*/
|
||||||
|
public HangingBreakEvent.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 placing a block on it
|
||||||
|
*/
|
||||||
|
OBSTRUCTION,
|
||||||
|
/**
|
||||||
|
* Removed by destroying the block behind it, etc
|
||||||
|
*/
|
||||||
|
PHYSICS,
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
24
src/main/java/org/bukkit/event/hanging/HangingEvent.java
Normal file
24
src/main/java/org/bukkit/event/hanging/HangingEvent.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package org.bukkit.event.hanging;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Hanging;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a hanging entity-related event.
|
||||||
|
*/
|
||||||
|
public abstract class HangingEvent extends Event {
|
||||||
|
protected Hanging hanging;
|
||||||
|
|
||||||
|
protected HangingEvent(final Hanging painting) {
|
||||||
|
this.hanging = painting;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the hanging entity involved in this event.
|
||||||
|
*
|
||||||
|
* @return the hanging entity
|
||||||
|
*/
|
||||||
|
public Hanging getEntity() {
|
||||||
|
return hanging;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
package org.bukkit.event.hanging;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.entity.Hanging;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered when a hanging entity is created in the world
|
||||||
|
*/
|
||||||
|
public class HangingPlaceEvent extends HangingEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancelled;
|
||||||
|
private final Player player;
|
||||||
|
private final Block block;
|
||||||
|
private final BlockFace blockFace;
|
||||||
|
|
||||||
|
public HangingPlaceEvent(final Hanging hanging, final Player player, final Block block, final BlockFace blockFace) {
|
||||||
|
super(hanging);
|
||||||
|
this.player = player;
|
||||||
|
this.block = block;
|
||||||
|
this.blockFace = blockFace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the player placing the hanging entity
|
||||||
|
*
|
||||||
|
* @return the player placing the hanging entity
|
||||||
|
*/
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the block that the hanging entity was placed on
|
||||||
|
*
|
||||||
|
* @return the block that the hanging entity was placed on
|
||||||
|
*/
|
||||||
|
public Block getBlock() {
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the face of the block that the hanging entity was placed on
|
||||||
|
*
|
||||||
|
* @return the face of the block that the hanging entity was placed on
|
||||||
|
*/
|
||||||
|
public BlockFace getBlockFace() {
|
||||||
|
return blockFace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancelled = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,15 @@
|
|||||||
package org.bukkit.event.painting;
|
package org.bukkit.event.painting;
|
||||||
|
|
||||||
|
import org.bukkit.Warning;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Painting;
|
import org.bukkit.entity.Painting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggered when a painting is removed by an entity
|
* Triggered when a painting is removed by an entity
|
||||||
|
* @deprecated Use {@link org.bukkit.event.hanging.HangingBreakByEntityEvent} instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Warning(reason="This event has been replaced by HangingBreakByEntityEvent")
|
||||||
public class PaintingBreakByEntityEvent extends PaintingBreakEvent {
|
public class PaintingBreakByEntityEvent extends PaintingBreakEvent {
|
||||||
private final Entity remover;
|
private final Entity remover;
|
||||||
|
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
package org.bukkit.event.painting;
|
package org.bukkit.event.painting;
|
||||||
|
|
||||||
|
import org.bukkit.Warning;
|
||||||
import org.bukkit.entity.Painting;
|
import org.bukkit.entity.Painting;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggered when a painting is removed
|
* Triggered when a painting is removed
|
||||||
|
* @deprecated Use {@link org.bukkit.event.hanging.HangingBreakEvent} instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Warning(reason="This event has been replaced by HangingBreakEvent")
|
||||||
public class PaintingBreakEvent extends PaintingEvent implements Cancellable {
|
public class PaintingBreakEvent extends PaintingEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package org.bukkit.event.painting;
|
package org.bukkit.event.painting;
|
||||||
|
|
||||||
|
import org.bukkit.Warning;
|
||||||
import org.bukkit.entity.Painting;
|
import org.bukkit.entity.Painting;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a painting-related event.
|
* Represents a painting-related event.
|
||||||
|
* @deprecated Use {@link org.bukkit.event.hanging.HangingEvent} instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Warning(reason="This event has been replaced by HangingEvent")
|
||||||
public abstract class PaintingEvent extends Event {
|
public abstract class PaintingEvent extends Event {
|
||||||
protected Painting painting;
|
protected Painting painting;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.bukkit.event.painting;
|
package org.bukkit.event.painting;
|
||||||
|
|
||||||
|
import org.bukkit.Warning;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Painting;
|
import org.bukkit.entity.Painting;
|
||||||
@ -9,7 +10,10 @@ import org.bukkit.event.HandlerList;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggered when a painting is created in the world
|
* Triggered when a painting is created in the world
|
||||||
|
* @deprecated Use {@link org.bukkit.event.hanging.HangingPlaceEvent} instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Warning(reason="This event has been replaced by HangingPlaceEvent")
|
||||||
public class PaintingPlaceEvent extends PaintingEvent implements Cancellable {
|
public class PaintingPlaceEvent extends PaintingEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user