@@ -0,0 +1,74 @@
|
||||
package org.bukkit.event.block;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when an ItemStack is successfully cooked in a block.
|
||||
*/
|
||||
public class BlockCookEvent extends BlockEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final ItemStack source;
|
||||
private ItemStack result;
|
||||
private boolean cancelled;
|
||||
|
||||
public BlockCookEvent(@NotNull final Block block, @NotNull final ItemStack source, @NotNull final ItemStack result) {
|
||||
super(block);
|
||||
this.source = source;
|
||||
this.result = result;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the smelted ItemStack for this event
|
||||
*
|
||||
* @return smelting source ItemStack
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the resultant ItemStack for this event
|
||||
*
|
||||
* @return smelting result ItemStack
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the resultant ItemStack for this event
|
||||
*
|
||||
* @param result new result ItemStack
|
||||
*/
|
||||
public void setResult(@NotNull ItemStack result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@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,7 +1,6 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.TravelAgent;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -15,63 +14,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public class EntityPortalEvent extends EntityTeleportEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
protected boolean useTravelAgent = true;
|
||||
protected TravelAgent travelAgent;
|
||||
|
||||
public EntityPortalEvent(@NotNull final Entity entity, @NotNull final Location from, @Nullable final Location to, @NotNull final TravelAgent pta) {
|
||||
public EntityPortalEvent(@NotNull final Entity entity, @NotNull final Location from, @Nullable final Location to) {
|
||||
super(entity, from, to);
|
||||
this.travelAgent = pta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not the Travel Agent will be used.
|
||||
* <p>
|
||||
* If this is set to true, the TravelAgent will try to find a Portal at
|
||||
* the {@link #getTo()} Location, and will try to create one if there is
|
||||
* none.
|
||||
* <p>
|
||||
* If this is set to false, the {@link #getEntity()} will only be
|
||||
* teleported to the {@link #getTo()} Location.
|
||||
*
|
||||
* @param useTravelAgent whether to use the Travel Agent
|
||||
*/
|
||||
public void useTravelAgent(boolean useTravelAgent) {
|
||||
this.useTravelAgent = useTravelAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether or not the Travel Agent will be used.
|
||||
* <p>
|
||||
* If this is set to true, the TravelAgent will try to find a Portal at
|
||||
* the {@link #getTo()} Location, and will try to create one if there is
|
||||
* none.
|
||||
* <p>
|
||||
* If this is set to false, the {@link #getEntity()} will only be
|
||||
* teleported to the {@link #getTo()} Location.
|
||||
*
|
||||
* @return whether to use the Travel Agent
|
||||
*/
|
||||
public boolean useTravelAgent() {
|
||||
return useTravelAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Travel Agent used (or not) in this event.
|
||||
*
|
||||
* @return the Travel Agent used (or not) in this event
|
||||
*/
|
||||
@NotNull
|
||||
public TravelAgent getPortalTravelAgent() {
|
||||
return this.travelAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Travel Agent used (or not) in this event.
|
||||
*
|
||||
* @param travelAgent the Travel Agent used (or not) in this event
|
||||
*/
|
||||
public void setPortalTravelAgent(@NotNull TravelAgent travelAgent) {
|
||||
this.travelAgent = travelAgent;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -19,7 +18,7 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable {
|
||||
private final float force;
|
||||
private boolean cancelled;
|
||||
|
||||
public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull final Projectile projectile, final float force) {
|
||||
public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull final Entity projectile, final float force) {
|
||||
super(shooter);
|
||||
this.bow = bow;
|
||||
this.projectile = projectile;
|
||||
|
||||
@@ -151,6 +151,10 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable {
|
||||
* entity
|
||||
*/
|
||||
CLOSEST_ENTITY,
|
||||
/**
|
||||
* When a raiding entity selects the same target as one of its compatriots.
|
||||
*/
|
||||
FOLLOW_LEADER,
|
||||
/**
|
||||
* When another entity tempts this entity by having a desired item such
|
||||
* as wheat in it's hand.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.AbstractVillager;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.MerchantRecipe;
|
||||
@@ -16,7 +16,7 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl
|
||||
//
|
||||
private MerchantRecipe recipe;
|
||||
|
||||
public VillagerAcquireTradeEvent(@NotNull Villager what, @NotNull MerchantRecipe recipe) {
|
||||
public VillagerAcquireTradeEvent(@NotNull AbstractVillager what, @NotNull MerchantRecipe recipe) {
|
||||
super(what);
|
||||
this.recipe = recipe;
|
||||
}
|
||||
@@ -52,8 +52,8 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Villager getEntity() {
|
||||
return (Villager) super.getEntity();
|
||||
public AbstractVillager getEntity() {
|
||||
return (AbstractVillager) super.getEntity();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.AbstractVillager;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.MerchantRecipe;
|
||||
@@ -20,7 +20,7 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella
|
||||
private MerchantRecipe recipe;
|
||||
private int bonus;
|
||||
|
||||
public VillagerReplenishTradeEvent(@NotNull Villager what, @NotNull MerchantRecipe recipe, int bonus) {
|
||||
public VillagerReplenishTradeEvent(@NotNull AbstractVillager what, @NotNull MerchantRecipe recipe, int bonus) {
|
||||
super(what);
|
||||
this.recipe = recipe;
|
||||
this.bonus = bonus;
|
||||
@@ -77,8 +77,8 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Villager getEntity() {
|
||||
return (Villager) super.getEntity();
|
||||
public AbstractVillager getEntity() {
|
||||
return (AbstractVillager) super.getEntity();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1,73 +1,16 @@
|
||||
package org.bukkit.event.inventory;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.bukkit.event.block.BlockCookEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when an ItemStack is successfully smelted in a furnace.
|
||||
*/
|
||||
public class FurnaceSmeltEvent extends BlockEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final ItemStack source;
|
||||
private ItemStack result;
|
||||
private boolean cancelled;
|
||||
public class FurnaceSmeltEvent extends BlockCookEvent {
|
||||
|
||||
public FurnaceSmeltEvent(@NotNull final Block furnace, @NotNull final ItemStack source, @NotNull final ItemStack result) {
|
||||
super(furnace);
|
||||
this.source = source;
|
||||
this.result = result;
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the smelted ItemStack for this event
|
||||
*
|
||||
* @return smelting source ItemStack
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the resultant ItemStack for this event
|
||||
*
|
||||
* @return smelting result ItemStack
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the resultant ItemStack for this event
|
||||
*
|
||||
* @param result new result ItemStack
|
||||
*/
|
||||
public void setResult(@NotNull ItemStack result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
super(furnace, source, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,39 @@ public enum InventoryType {
|
||||
* A shulker box inventory, with 27 slots of type CONTAINER.
|
||||
*/
|
||||
SHULKER_BOX(27, "Shulker Box"),
|
||||
/**
|
||||
* A barrel box inventory, with 27 slots of type CONTAINER.
|
||||
*/
|
||||
BARREL(27, "Barrel"),
|
||||
/**
|
||||
* A blast furnace inventory, with a RESULT slot, a CRAFTING slot, and a
|
||||
* FUEL slot.
|
||||
*/
|
||||
BLAST_FURNACE(3, "Blast Furnace"),
|
||||
/**
|
||||
* A lectern inventory, with 1 BOOK slot.
|
||||
*/
|
||||
LECTERN(1, "Lectern", false),
|
||||
/**
|
||||
* A smoker inventory, with a RESULT slot, a CRAFTING slot, and a FUEL slot.
|
||||
*/
|
||||
SMOKER(3, "Smoker"),
|
||||
/**
|
||||
* Loom inventory, with 3 INPUT slots, and 1 RESULT slot.
|
||||
*/
|
||||
LOOM(4, "Loom"),
|
||||
/**
|
||||
* Cartography inventory with 2 INPUT slots, and 1 RESULT slot.
|
||||
*/
|
||||
CARTOGRAPHY(3, "Cartography Table"),
|
||||
/**
|
||||
* Grindstone inventory with 2 INPUT slots, and 1 RESULT slot.
|
||||
*/
|
||||
GRINDSTONE(3, "Repair & Disenchant"),
|
||||
/**
|
||||
* Stonecutter inventory with 1 INPUT slot, and 1 RESULT slot.
|
||||
*/
|
||||
STONECUTTER(2, "Stonecutter")
|
||||
;
|
||||
|
||||
private final int size;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.bukkit.event.player;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.TravelAgent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -15,68 +14,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public class PlayerPortalEvent extends PlayerTeleportEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
protected boolean useTravelAgent = true;
|
||||
protected TravelAgent travelAgent;
|
||||
|
||||
public PlayerPortalEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to, @NotNull final TravelAgent pta) {
|
||||
public PlayerPortalEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to) {
|
||||
super(player, from, to);
|
||||
this.travelAgent = pta;
|
||||
}
|
||||
|
||||
public PlayerPortalEvent(@NotNull Player player, @NotNull Location from, @Nullable Location to, @NotNull TravelAgent pta, @NotNull TeleportCause cause) {
|
||||
public PlayerPortalEvent(@NotNull Player player, @NotNull Location from, @Nullable Location to, @NotNull TeleportCause cause) {
|
||||
super(player, from, to, cause);
|
||||
this.travelAgent = pta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not the Travel Agent will be used.
|
||||
* <p>
|
||||
* If this is set to true, the TravelAgent will try to find a Portal at
|
||||
* the {@link #getTo()} Location, and will try to create one if there is
|
||||
* none.
|
||||
* <p>
|
||||
* If this is set to false, the {@link #getPlayer()} will only be
|
||||
* teleported to the {@link #getTo()} Location.
|
||||
*
|
||||
* @param useTravelAgent whether to use the Travel Agent
|
||||
*/
|
||||
public void useTravelAgent(boolean useTravelAgent) {
|
||||
this.useTravelAgent = useTravelAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether or not the Travel Agent will be used.
|
||||
* <p>
|
||||
* If this is set to true, the TravelAgent will try to find a Portal at
|
||||
* the {@link #getTo()} Location, and will try to create one if there is
|
||||
* none.
|
||||
* <p>
|
||||
* If this is set to false, the {@link #getPlayer()}} will only be
|
||||
* teleported to the {@link #getTo()} Location.
|
||||
*
|
||||
* @return whether to use the Travel Agent
|
||||
*/
|
||||
public boolean useTravelAgent() {
|
||||
return useTravelAgent && travelAgent != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Travel Agent used (or not) in this event.
|
||||
*
|
||||
* @return the Travel Agent used (or not) in this event
|
||||
*/
|
||||
@NotNull
|
||||
public TravelAgent getPortalTravelAgent() {
|
||||
return this.travelAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Travel Agent used (or not) in this event.
|
||||
*
|
||||
* @param travelAgent the Travel Agent used (or not) in this event
|
||||
*/
|
||||
public void setPortalTravelAgent(@NotNull TravelAgent travelAgent) {
|
||||
this.travelAgent = travelAgent;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -6,4 +6,12 @@ import org.bukkit.event.Event;
|
||||
* Miscellaneous server events
|
||||
*/
|
||||
public abstract class ServerEvent extends Event {
|
||||
|
||||
public ServerEvent() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ServerEvent(boolean isAsync) {
|
||||
super(isAsync);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
||||
private int maxPlayers;
|
||||
|
||||
public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int numPlayers, final int maxPlayers) {
|
||||
super(true);
|
||||
Validate.isTrue(numPlayers >= 0, "Cannot have negative number of players online", numPlayers);
|
||||
this.address = address;
|
||||
this.motd = motd;
|
||||
@@ -40,6 +41,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
||||
* @param maxPlayers the max number of players
|
||||
*/
|
||||
protected ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int maxPlayers) {
|
||||
super(true);
|
||||
this.numPlayers = MAGIC_PLAYER_COUNT;
|
||||
this.address = address;
|
||||
this.motd = motd;
|
||||
|
||||
Reference in New Issue
Block a user