mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-31 21:37:39 +01:00
#613: Add PlayerBucketEntityEvent and make PlayerBucketFishEvent deprecated in favor of the newer, more generic event
By: DiamondDagger590 <diamonddagger590@gmail.com>
This commit is contained in:
parent
b21ce6d13a
commit
3d74697e24
@ -0,0 +1,84 @@
|
||||
package org.bukkit.event.player;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This event is called whenever a player captures an entity in a bucket.
|
||||
*/
|
||||
public class PlayerBucketEntityEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Entity entity;
|
||||
private final ItemStack originalBucket;
|
||||
private final ItemStack entityBucket;
|
||||
|
||||
public PlayerBucketEntityEvent(@NotNull Player player, @NotNull Entity entity, @NotNull ItemStack originalBucket, @NotNull ItemStack entityBucket) {
|
||||
super(player);
|
||||
this.entity = entity;
|
||||
this.originalBucket = originalBucket;
|
||||
this.entityBucket = entityBucket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Entity} being put into the bucket.
|
||||
*
|
||||
* @return The {@link Entity} being put into the bucket
|
||||
*/
|
||||
@NotNull
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bucket used to capture the {@link Entity}.
|
||||
*
|
||||
* This refers to the bucket clicked with, eg {@link Material#WATER_BUCKET}.
|
||||
*
|
||||
* @return The used bucket
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getOriginalBucket() {
|
||||
return originalBucket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bucket that the {@link Entity} will be put into.
|
||||
*
|
||||
* This refers to the bucket with the entity, eg
|
||||
* {@link Material#PUFFERFISH_BUCKET}.
|
||||
*
|
||||
* @return The bucket that the {@link Entity} will be put into
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getEntityBucket() {
|
||||
return entityBucket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1,29 +1,23 @@
|
||||
package org.bukkit.event.player;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Warning;
|
||||
import org.bukkit.entity.Fish;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This event is called whenever a player attempts to put a fish in a bucket.
|
||||
*
|
||||
* @deprecated Use the more generic {@link PlayerBucketEntityEvent}
|
||||
*/
|
||||
public class PlayerBucketFishEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancalled;
|
||||
private final Fish fish;
|
||||
private final ItemStack waterBucket;
|
||||
private final ItemStack fishBucket;
|
||||
@Deprecated
|
||||
@Warning(false)
|
||||
public class PlayerBucketFishEvent extends PlayerBucketEntityEvent {
|
||||
|
||||
public PlayerBucketFishEvent(@NotNull Player player, @NotNull Fish fish, @NotNull ItemStack waterBucket, @NotNull ItemStack fishBucket) {
|
||||
super(player);
|
||||
this.fish = fish;
|
||||
this.waterBucket = waterBucket;
|
||||
this.fishBucket = fishBucket;
|
||||
super(player, fish, waterBucket, fishBucket);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,8 +26,9 @@ public class PlayerBucketFishEvent extends PlayerEvent implements Cancellable {
|
||||
* @return The fish involved with this event
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public Fish getEntity() {
|
||||
return fish;
|
||||
return (Fish) super.getEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,10 +37,12 @@ public class PlayerBucketFishEvent extends PlayerEvent implements Cancellable {
|
||||
* This refers to the bucket clicked with, ie {@link Material#WATER_BUCKET}.
|
||||
*
|
||||
* @return The used bucket
|
||||
* @deprecated Use {@link #getOriginalBucket()}
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public ItemStack getWaterBucket() {
|
||||
return waterBucket;
|
||||
return getOriginalBucket();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,30 +52,11 @@ public class PlayerBucketFishEvent extends PlayerEvent implements Cancellable {
|
||||
* {@link Material#PUFFERFISH_BUCKET}.
|
||||
*
|
||||
* @return The bucket that the fish will be put into
|
||||
* @deprecated Use {@link #getEntityBucket()}
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public ItemStack getFishBucket() {
|
||||
return fishBucket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancalled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancalled = cancel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
return getEntityBucket();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user