mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-22 15:31:45 +01:00
[Bleeding] Add new events for Hanging entities, deprecate old Painting
events. Adds BUKKIT-2754 By: h31ix <effectsdude@gmail.com>
This commit is contained in:
parent
a51de65933
commit
397b53dad5
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
import org.bukkit.Warning;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Painting;
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
private final Entity remover;
|
||||
|
||||
|
@ -1,12 +1,16 @@
|
||||
package org.bukkit.event.painting;
|
||||
|
||||
import org.bukkit.Warning;
|
||||
import org.bukkit.entity.Painting;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
|
@ -1,11 +1,15 @@
|
||||
package org.bukkit.event.painting;
|
||||
|
||||
import org.bukkit.Warning;
|
||||
import org.bukkit.entity.Painting;
|
||||
import org.bukkit.event.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 {
|
||||
protected Painting painting;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.bukkit.event.painting;
|
||||
|
||||
import org.bukkit.Warning;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Painting;
|
||||
@ -9,7 +10,10 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
|
Loading…
Reference in New Issue
Block a user