9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-20 15:39:21 +00:00

Refactor events

This commit is contained in:
XiaoMoMi
2024-09-04 22:26:27 +08:00
parent 14c3d0a338
commit 33cfd7deac
30 changed files with 143 additions and 157 deletions

View File

@@ -912,7 +912,7 @@ public abstract class AbstractActionManager<T> implements ActionManager<T> {
if (EventUtils.fireAndCheckCancel(plantEvent)) { if (EventUtils.fireAndCheckCancel(plantEvent)) {
return; return;
} }
cropBlock.point(state, plantEvent.getPoint()); cropBlock.point(state, plantEvent.point());
if (triggerAction) { if (triggerAction) {
ActionManager.trigger((Context<Player>) context, cropConfig.plantActions()); ActionManager.trigger((Context<Player>) context, cropConfig.plantActions());
} }

View File

@@ -100,7 +100,7 @@ public class SeedItem extends AbstractCustomCropsItem {
if (EventUtils.fireAndCheckCancel(plantEvent)) { if (EventUtils.fireAndCheckCancel(plantEvent)) {
return InteractionResult.COMPLETE; return InteractionResult.COMPLETE;
} }
int point = plantEvent.getPoint(); int point = plantEvent.point();
CropStageConfig stageConfig = cropConfig.stageWithModelByPoint(point); CropStageConfig stageConfig = cropConfig.stageWithModelByPoint(point);
if (stageConfig == null) { if (stageConfig == null) {
return InteractionResult.COMPLETE; return InteractionResult.COMPLETE;

View File

@@ -281,7 +281,7 @@ public class WateringCanItem extends AbstractCustomCropsItem {
context.arg(ContextKeys.CURRENT_WATER, waterInCan - 1); context.arg(ContextKeys.CURRENT_WATER, waterInCan - 1);
PotBlock potBlock = (PotBlock) BuiltInBlockMechanics.POT.mechanic(); PotBlock potBlock = (PotBlock) BuiltInBlockMechanics.POT.mechanic();
for (Pair<Pos3, String> pair : waterPotEvent.getPotWithIDs()) { for (Pair<Pos3, String> pair : waterPotEvent.pots()) {
CustomCropsBlockState potState = potBlock.fixOrGetState(world,pair.left(), potConfig, pair.right()); CustomCropsBlockState potState = potBlock.fixOrGetState(world,pair.left(), potConfig, pair.right());
Location temp = pair.left().toLocation(bukkitWorld); Location temp = pair.left().toLocation(bukkitWorld);
if (potBlock.addWater(potState, potConfig, wateringCanConfig.wateringAmount())) { if (potBlock.addWater(potState, potConfig, wateringCanConfig.wateringAmount())) {

View File

@@ -112,7 +112,7 @@ public class BoneMealDispenseEvent extends Event implements Cancellable {
* @return the location of the crop block. * @return the location of the crop block.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -122,7 +122,7 @@ public class BoneMealDispenseEvent extends Event implements Cancellable {
* @return the ItemStack of bone meal. * @return the ItemStack of bone meal.
*/ */
@NotNull @NotNull
public ItemStack getBoneMealItem() { public ItemStack boneMealItem() {
return boneMealItem; return boneMealItem;
} }
@@ -132,7 +132,7 @@ public class BoneMealDispenseEvent extends Event implements Cancellable {
* @return the block state of the crop. * @return the block state of the crop.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -142,7 +142,7 @@ public class BoneMealDispenseEvent extends Event implements Cancellable {
* @return the BoneMeal configuration. * @return the BoneMeal configuration.
*/ */
@NotNull @NotNull
public BoneMeal getBoneMeal() { public BoneMeal boneMeal() {
return boneMeal; return boneMeal;
} }
@@ -152,7 +152,7 @@ public class BoneMealDispenseEvent extends Event implements Cancellable {
* @return the dispenser block. * @return the dispenser block.
*/ */
@NotNull @NotNull
public Block getDispenser() { public Block dispenser() {
return dispenser; return dispenser;
} }
} }

View File

@@ -120,7 +120,7 @@ public class BoneMealUseEvent extends PlayerEvent implements Cancellable {
* @return the location of the crop block. * @return the location of the crop block.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -130,7 +130,7 @@ public class BoneMealUseEvent extends PlayerEvent implements Cancellable {
* @return the crop configuration. * @return the crop configuration.
*/ */
@NotNull @NotNull
public CropConfig getConfig() { public CropConfig cropConfig() {
return config; return config;
} }
@@ -141,7 +141,7 @@ public class BoneMealUseEvent extends PlayerEvent implements Cancellable {
* @return the ItemStack in hand. * @return the ItemStack in hand.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
@@ -151,7 +151,7 @@ public class BoneMealUseEvent extends PlayerEvent implements Cancellable {
* @return the block state of the crop. * @return the block state of the crop.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -161,7 +161,7 @@ public class BoneMealUseEvent extends PlayerEvent implements Cancellable {
* @return the equipment slot. * @return the equipment slot.
*/ */
@NotNull @NotNull
public EquipmentSlot getEquipmentSlot() { public EquipmentSlot hand() {
return equipmentSlot; return equipmentSlot;
} }
@@ -171,7 +171,7 @@ public class BoneMealUseEvent extends PlayerEvent implements Cancellable {
* @return the BoneMeal configuration. * @return the BoneMeal configuration.
*/ */
@NotNull @NotNull
public BoneMeal getBoneMeal() { public BoneMeal boneMeal() {
return boneMeal; return boneMeal;
} }
} }

View File

@@ -122,7 +122,7 @@ public class CropBreakEvent extends Event implements Cancellable {
* @return the location of the broken crop block. * @return the location of the broken crop block.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -132,7 +132,7 @@ public class CropBreakEvent extends Event implements Cancellable {
* @return the block that caused the break, or null if not applicable. * @return the block that caused the break, or null if not applicable.
*/ */
@Nullable @Nullable
public Block getBlockBreaker() { public Block blockBreaker() {
return blockBreaker; return blockBreaker;
} }
@@ -142,7 +142,7 @@ public class CropBreakEvent extends Event implements Cancellable {
* @return the entity that caused the break, or null if not applicable. * @return the entity that caused the break, or null if not applicable.
*/ */
@Nullable @Nullable
public Entity getEntityBreaker() { public Entity entityBreaker() {
return entityBreaker; return entityBreaker;
} }
@@ -152,7 +152,7 @@ public class CropBreakEvent extends Event implements Cancellable {
* @return the block state before breakage, or null if not applicable. * @return the block state before breakage, or null if not applicable.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -162,7 +162,7 @@ public class CropBreakEvent extends Event implements Cancellable {
* @return the stage item ID. * @return the stage item ID.
*/ */
@NotNull @NotNull
public String getStageItemID() { public String cropStageItemID() {
return stageItemID; return stageItemID;
} }
@@ -172,7 +172,7 @@ public class CropBreakEvent extends Event implements Cancellable {
* @return the crop configuration. * @return the crop configuration.
*/ */
@NotNull @NotNull
public CropConfig getCropConfig() { public CropConfig cropConfig() {
return config; return config;
} }
@@ -182,7 +182,7 @@ public class CropBreakEvent extends Event implements Cancellable {
* @return the reason for the break. * @return the reason for the break.
*/ */
@NotNull @NotNull
public BreakReason getReason() { public BreakReason reason() {
return reason; return reason;
} }
} }

View File

@@ -118,7 +118,7 @@ public class CropInteractEvent extends PlayerEvent implements Cancellable {
* @return the location of the crop block. * @return the location of the crop block.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -129,7 +129,7 @@ public class CropInteractEvent extends PlayerEvent implements Cancellable {
* @return the ItemStack in hand. * @return the ItemStack in hand.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
@@ -139,7 +139,7 @@ public class CropInteractEvent extends PlayerEvent implements Cancellable {
* @return the crop configuration. * @return the crop configuration.
*/ */
@NotNull @NotNull
public CropConfig getCropConfig() { public CropConfig cropConfig() {
return config; return config;
} }
@@ -149,7 +149,7 @@ public class CropInteractEvent extends PlayerEvent implements Cancellable {
* @return the block state of the crop. * @return the block state of the crop.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -159,7 +159,7 @@ public class CropInteractEvent extends PlayerEvent implements Cancellable {
* @return the equipment slot representing the hand used. * @return the equipment slot representing the hand used.
*/ */
@NotNull @NotNull
public EquipmentSlot getHand() { public EquipmentSlot hand() {
return hand; return hand;
} }
@@ -169,7 +169,7 @@ public class CropInteractEvent extends PlayerEvent implements Cancellable {
* @return the stage item ID. * @return the stage item ID.
*/ */
@NotNull @NotNull
public String getStageItemID() { public String cropStageItemID() {
return stageItemID; return stageItemID;
} }
} }

View File

@@ -97,7 +97,7 @@ public class CropPlantEvent extends PlayerEvent implements Cancellable {
* @return the seed item. * @return the seed item.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
@@ -128,7 +128,7 @@ public class CropPlantEvent extends PlayerEvent implements Cancellable {
* @return the block state of the crop. * @return the block state of the crop.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -138,7 +138,7 @@ public class CropPlantEvent extends PlayerEvent implements Cancellable {
* @return the equipment slot representing the hand used. * @return the equipment slot representing the hand used.
*/ */
@NotNull @NotNull
public EquipmentSlot getHand() { public EquipmentSlot hand() {
return hand; return hand;
} }
@@ -148,7 +148,7 @@ public class CropPlantEvent extends PlayerEvent implements Cancellable {
* @return the crop configuration. * @return the crop configuration.
*/ */
@NotNull @NotNull
public CropConfig getCropConfig() { public CropConfig cropConfig() {
return config; return config;
} }
@@ -158,7 +158,7 @@ public class CropPlantEvent extends PlayerEvent implements Cancellable {
* @return the location of the crop. * @return the location of the crop.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -168,7 +168,7 @@ public class CropPlantEvent extends PlayerEvent implements Cancellable {
* *
* @return the initial point. * @return the initial point.
*/ */
public int getPoint() { public int point() {
return point; return point;
} }
@@ -177,7 +177,7 @@ public class CropPlantEvent extends PlayerEvent implements Cancellable {
* *
* @param point the new initial point value. * @param point the new initial point value.
*/ */
public void setPoint(int point) { public void point(int point) {
this.point = point; this.point = point;
} }
} }

View File

@@ -64,7 +64,7 @@ public class CustomCropsReloadEvent extends Event {
* *
* @return the plugin instance. * @return the plugin instance.
*/ */
public BukkitCustomCropsPlugin getPluginInstance() { public BukkitCustomCropsPlugin plugin() {
return plugin; return plugin;
} }
} }

View File

@@ -119,7 +119,7 @@ public class FertilizerUseEvent extends PlayerEvent implements Cancellable {
* @return the item in hand. * @return the item in hand.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
@@ -129,7 +129,7 @@ public class FertilizerUseEvent extends PlayerEvent implements Cancellable {
* @return the location of the pot. * @return the location of the pot.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -139,7 +139,7 @@ public class FertilizerUseEvent extends PlayerEvent implements Cancellable {
* @return the block state of the pot. * @return the block state of the pot.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -149,7 +149,7 @@ public class FertilizerUseEvent extends PlayerEvent implements Cancellable {
* @return the equipment slot representing the hand used. * @return the equipment slot representing the hand used.
*/ */
@NotNull @NotNull
public EquipmentSlot getHand() { public EquipmentSlot hand() {
return hand; return hand;
} }
@@ -159,7 +159,7 @@ public class FertilizerUseEvent extends PlayerEvent implements Cancellable {
* @return the pot configuration. * @return the pot configuration.
*/ */
@NotNull @NotNull
public PotConfig getPotConfig() { public PotConfig potConfig() {
return config; return config;
} }
@@ -169,7 +169,7 @@ public class FertilizerUseEvent extends PlayerEvent implements Cancellable {
* @return the fertilizer configuration. * @return the fertilizer configuration.
*/ */
@NotNull @NotNull
public Fertilizer getFertilizer() { public Fertilizer fertilizer() {
return fertilizer; return fertilizer;
} }
} }

View File

@@ -115,7 +115,7 @@ public class GreenhouseGlassBreakEvent extends Event implements Cancellable {
* @return the location of the glass block. * @return the location of the glass block.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -125,7 +125,7 @@ public class GreenhouseGlassBreakEvent extends Event implements Cancellable {
* @return the entity that caused the break, or null if not applicable. * @return the entity that caused the break, or null if not applicable.
*/ */
@Nullable @Nullable
public Entity getEntityBreaker() { public Entity entityBreaker() {
return entityBreaker; return entityBreaker;
} }
@@ -135,7 +135,7 @@ public class GreenhouseGlassBreakEvent extends Event implements Cancellable {
* @return the block that caused the break, or null if not applicable. * @return the block that caused the break, or null if not applicable.
*/ */
@Nullable @Nullable
public Block getBlockBreaker() { public Block blockBreaker() {
return blockBreaker; return blockBreaker;
} }
@@ -145,7 +145,7 @@ public class GreenhouseGlassBreakEvent extends Event implements Cancellable {
* @return the reason for the break. * @return the reason for the break.
*/ */
@NotNull @NotNull
public BreakReason getReason() { public BreakReason reason() {
return reason; return reason;
} }
@@ -155,7 +155,7 @@ public class GreenhouseGlassBreakEvent extends Event implements Cancellable {
* @return the block state of the glass. * @return the block state of the glass.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -164,7 +164,7 @@ public class GreenhouseGlassBreakEvent extends Event implements Cancellable {
* *
* @return the glass item ID. * @return the glass item ID.
*/ */
public String getGlassItemID() { public String glassItemID() {
return glassItemID; return glassItemID;
} }
} }

View File

@@ -113,7 +113,7 @@ public class GreenhouseGlassInteractEvent extends PlayerEvent implements Cancell
* @return the location of the glass block. * @return the location of the glass block.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -123,7 +123,7 @@ public class GreenhouseGlassInteractEvent extends PlayerEvent implements Cancell
* @return the block state of the glass. * @return the block state of the glass.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -133,7 +133,7 @@ public class GreenhouseGlassInteractEvent extends PlayerEvent implements Cancell
* @return the equipment slot representing the hand used. * @return the equipment slot representing the hand used.
*/ */
@NotNull @NotNull
public EquipmentSlot getHand() { public EquipmentSlot hand() {
return hand; return hand;
} }
@@ -143,7 +143,7 @@ public class GreenhouseGlassInteractEvent extends PlayerEvent implements Cancell
* @return the glass item ID. * @return the glass item ID.
*/ */
@NotNull @NotNull
public String getGlassItemID() { public String glassItemID() {
return glassItemID; return glassItemID;
} }
@@ -153,7 +153,7 @@ public class GreenhouseGlassInteractEvent extends PlayerEvent implements Cancell
* @return the item in hand. * @return the item in hand.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
} }

View File

@@ -103,7 +103,7 @@ public class GreenhouseGlassPlaceEvent extends PlayerEvent implements Cancellabl
* @return the location of the glass block. * @return the location of the glass block.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -113,7 +113,7 @@ public class GreenhouseGlassPlaceEvent extends PlayerEvent implements Cancellabl
* @return the block state of the glass. * @return the block state of the glass.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -123,7 +123,7 @@ public class GreenhouseGlassPlaceEvent extends PlayerEvent implements Cancellabl
* @return the glass item ID. * @return the glass item ID.
*/ */
@NotNull @NotNull
public String getGlassItemID() { public String glassItemID() {
return glassItemID; return glassItemID;
} }
} }

View File

@@ -23,7 +23,6 @@ import net.momirealms.customcrops.api.core.world.CustomCropsBlockState;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@@ -117,7 +116,7 @@ public class PotBreakEvent extends Event implements Cancellable {
* @return the location of the pot block. * @return the location of the pot block.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -127,30 +126,17 @@ public class PotBreakEvent extends Event implements Cancellable {
* @return the entity that caused the break, or null if not applicable. * @return the entity that caused the break, or null if not applicable.
*/ */
@Nullable @Nullable
public Entity getEntityBreaker() { public Entity entityBreaker() {
return entityBreaker; return entityBreaker;
} }
/**
* Gets the player responsible for breaking the pot, if the breaker is a player.
*
* @return the player that caused the break, or null if not applicable.
*/
@Nullable
public Player getPlayer() {
if (entityBreaker instanceof Player player) {
return player;
}
return null;
}
/** /**
* Gets the reason for the pot breakage. * Gets the reason for the pot breakage.
* *
* @return the reason for the break. * @return the reason for the break.
*/ */
@NotNull @NotNull
public BreakReason getReason() { public BreakReason reason() {
return reason; return reason;
} }
@@ -160,7 +146,7 @@ public class PotBreakEvent extends Event implements Cancellable {
* @return the pot configuration. * @return the pot configuration.
*/ */
@NotNull @NotNull
public PotConfig getPotConfig() { public PotConfig potConfig() {
return config; return config;
} }
@@ -170,7 +156,7 @@ public class PotBreakEvent extends Event implements Cancellable {
* @return the block state of the pot. * @return the block state of the pot.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -180,7 +166,7 @@ public class PotBreakEvent extends Event implements Cancellable {
* @return the block that caused the break, or null if not applicable. * @return the block that caused the break, or null if not applicable.
*/ */
@Nullable @Nullable
public Block getBlockBreaker() { public Block blockBreaker() {
return blockBreaker; return blockBreaker;
} }
} }

View File

@@ -119,7 +119,7 @@ public class PotFillEvent extends PlayerEvent implements Cancellable {
* @return the location of the pot. * @return the location of the pot.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -129,7 +129,7 @@ public class PotFillEvent extends PlayerEvent implements Cancellable {
* @return the item in hand. * @return the item in hand.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
@@ -139,7 +139,7 @@ public class PotFillEvent extends PlayerEvent implements Cancellable {
* @return the pot configuration. * @return the pot configuration.
*/ */
@NotNull @NotNull
public PotConfig getPotConfig() { public PotConfig potConfig() {
return config; return config;
} }
@@ -149,7 +149,7 @@ public class PotFillEvent extends PlayerEvent implements Cancellable {
* @return the watering method. * @return the watering method.
*/ */
@NotNull @NotNull
public WateringMethod getWateringMethod() { public WateringMethod wateringMethod() {
return wateringMethod; return wateringMethod;
} }
@@ -159,7 +159,7 @@ public class PotFillEvent extends PlayerEvent implements Cancellable {
* @return the block state of the pot. * @return the block state of the pot.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -169,7 +169,7 @@ public class PotFillEvent extends PlayerEvent implements Cancellable {
* @return the equipment slot representing the hand used. * @return the equipment slot representing the hand used.
*/ */
@NotNull @NotNull
public EquipmentSlot getHand() { public EquipmentSlot hand() {
return hand; return hand;
} }
} }

View File

@@ -115,7 +115,7 @@ public class PotInteractEvent extends PlayerEvent implements Cancellable {
* @return the item in hand. * @return the item in hand.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
@@ -125,7 +125,7 @@ public class PotInteractEvent extends PlayerEvent implements Cancellable {
* @return the equipment slot representing the hand used. * @return the equipment slot representing the hand used.
*/ */
@NotNull @NotNull
public EquipmentSlot getHand() { public EquipmentSlot hand() {
return hand; return hand;
} }
@@ -135,7 +135,7 @@ public class PotInteractEvent extends PlayerEvent implements Cancellable {
* @return the location of the pot. * @return the location of the pot.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -145,7 +145,7 @@ public class PotInteractEvent extends PlayerEvent implements Cancellable {
* @return the block state of the pot. * @return the block state of the pot.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -155,7 +155,7 @@ public class PotInteractEvent extends PlayerEvent implements Cancellable {
* @return the pot configuration. * @return the pot configuration.
*/ */
@NotNull @NotNull
public PotConfig getPotConfig() { public PotConfig potConfig() {
return config; return config;
} }
} }

View File

@@ -37,7 +37,7 @@ public class PotPlaceEvent extends PlayerEvent implements Cancellable {
private boolean cancelled; private boolean cancelled;
private final Location location; private final Location location;
private final PotConfig config; private final PotConfig config;
private final CustomCropsBlockState state; private final CustomCropsBlockState blockState;
private final ItemStack itemInHand; private final ItemStack itemInHand;
private final EquipmentSlot hand; private final EquipmentSlot hand;
@@ -47,7 +47,7 @@ public class PotPlaceEvent extends PlayerEvent implements Cancellable {
* @param who The player who is placing the pot. * @param who The player who is placing the pot.
* @param location The location where the pot is being placed. * @param location The location where the pot is being placed.
* @param config The configuration of the pot being placed. * @param config The configuration of the pot being placed.
* @param state The state of the block where the pot is placed. * @param blockState The state of the block where the pot is placed.
* @param itemInHand The ItemStack representing the item in the player's hand. * @param itemInHand The ItemStack representing the item in the player's hand.
* @param hand The hand (main or offhand) used by the player for placing the pot. * @param hand The hand (main or offhand) used by the player for placing the pot.
*/ */
@@ -55,13 +55,13 @@ public class PotPlaceEvent extends PlayerEvent implements Cancellable {
@NotNull Player who, @NotNull Player who,
@NotNull Location location, @NotNull Location location,
@NotNull PotConfig config, @NotNull PotConfig config,
@NotNull CustomCropsBlockState state, @NotNull CustomCropsBlockState blockState,
@NotNull ItemStack itemInHand, @NotNull ItemStack itemInHand,
@NotNull EquipmentSlot hand @NotNull EquipmentSlot hand
) { ) {
super(who); super(who);
this.location = location; this.location = location;
this.state = state; this.blockState = blockState;
this.itemInHand = itemInHand; this.itemInHand = itemInHand;
this.hand = hand; this.hand = hand;
this.config = config; this.config = config;
@@ -114,7 +114,7 @@ public class PotPlaceEvent extends PlayerEvent implements Cancellable {
* @return the location of the pot. * @return the location of the pot.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -124,8 +124,8 @@ public class PotPlaceEvent extends PlayerEvent implements Cancellable {
* @return the block state of the pot. * @return the block state of the pot.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getState() { public CustomCropsBlockState blockState() {
return state; return blockState;
} }
/** /**
@@ -134,7 +134,7 @@ public class PotPlaceEvent extends PlayerEvent implements Cancellable {
* @return the item in hand. * @return the item in hand.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
@@ -144,7 +144,7 @@ public class PotPlaceEvent extends PlayerEvent implements Cancellable {
* @return the equipment slot representing the hand used. * @return the equipment slot representing the hand used.
*/ */
@NotNull @NotNull
public EquipmentSlot getHand() { public EquipmentSlot hand() {
return hand; return hand;
} }
@@ -154,7 +154,7 @@ public class PotPlaceEvent extends PlayerEvent implements Cancellable {
* @return the pot configuration. * @return the pot configuration.
*/ */
@NotNull @NotNull
public PotConfig getPotConfig() { public PotConfig potConfig() {
return config; return config;
} }
} }

View File

@@ -115,7 +115,7 @@ public class ScarecrowBreakEvent extends Event implements Cancellable {
* @return the location of the scarecrow. * @return the location of the scarecrow.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -125,7 +125,7 @@ public class ScarecrowBreakEvent extends Event implements Cancellable {
* @return the entity that caused the break, or null if not applicable. * @return the entity that caused the break, or null if not applicable.
*/ */
@Nullable @Nullable
public Entity getEntityBreaker() { public Entity entityBreaker() {
return entityBreaker; return entityBreaker;
} }
@@ -135,7 +135,7 @@ public class ScarecrowBreakEvent extends Event implements Cancellable {
* @return the block that caused the break, or null if not applicable. * @return the block that caused the break, or null if not applicable.
*/ */
@Nullable @Nullable
public Block getBlockBreaker() { public Block blockBreaker() {
return blockBreaker; return blockBreaker;
} }
@@ -145,7 +145,7 @@ public class ScarecrowBreakEvent extends Event implements Cancellable {
* @return the reason for the break. * @return the reason for the break.
*/ */
@NotNull @NotNull
public BreakReason getReason() { public BreakReason reason() {
return reason; return reason;
} }
@@ -155,7 +155,7 @@ public class ScarecrowBreakEvent extends Event implements Cancellable {
* @return the block state of the scarecrow. * @return the block state of the scarecrow.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -164,7 +164,7 @@ public class ScarecrowBreakEvent extends Event implements Cancellable {
* *
* @return the scarecrow item ID. * @return the scarecrow item ID.
*/ */
public String getScarecrowItemID() { public String scarecrowItemID() {
return scarecrowItemID; return scarecrowItemID;
} }
} }

View File

@@ -113,7 +113,7 @@ public class ScarecrowInteractEvent extends PlayerEvent implements Cancellable {
* @return the location of the scarecrow. * @return the location of the scarecrow.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -123,7 +123,7 @@ public class ScarecrowInteractEvent extends PlayerEvent implements Cancellable {
* @return the block state of the scarecrow. * @return the block state of the scarecrow.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -133,7 +133,7 @@ public class ScarecrowInteractEvent extends PlayerEvent implements Cancellable {
* @return the equipment slot representing the hand used. * @return the equipment slot representing the hand used.
*/ */
@NotNull @NotNull
public EquipmentSlot getHand() { public EquipmentSlot hand() {
return hand; return hand;
} }
@@ -143,7 +143,7 @@ public class ScarecrowInteractEvent extends PlayerEvent implements Cancellable {
* @return the scarecrow item ID. * @return the scarecrow item ID.
*/ */
@NotNull @NotNull
public String getScarecrowItemID() { public String scarecrowItemID() {
return scarecrowItemID; return scarecrowItemID;
} }
@@ -153,7 +153,7 @@ public class ScarecrowInteractEvent extends PlayerEvent implements Cancellable {
* @return the item in hand. * @return the item in hand.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
} }

View File

@@ -103,7 +103,7 @@ public class ScarecrowPlaceEvent extends PlayerEvent implements Cancellable {
* @return the scarecrow item ID. * @return the scarecrow item ID.
*/ */
@NotNull @NotNull
public String getScarecrowItemID() { public String scarecrowItemID() {
return scarecrowItemID; return scarecrowItemID;
} }
@@ -113,7 +113,7 @@ public class ScarecrowPlaceEvent extends PlayerEvent implements Cancellable {
* @return the location of the scarecrow. * @return the location of the scarecrow.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -123,7 +123,7 @@ public class ScarecrowPlaceEvent extends PlayerEvent implements Cancellable {
* @return the block state of the scarecrow. * @return the block state of the scarecrow.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
} }

View File

@@ -116,7 +116,7 @@ public class SprinklerBreakEvent extends Event implements Cancellable {
* @return the location of the sprinkler. * @return the location of the sprinkler.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -126,7 +126,7 @@ public class SprinklerBreakEvent extends Event implements Cancellable {
* @return the entity that caused the break, or null if not applicable. * @return the entity that caused the break, or null if not applicable.
*/ */
@Nullable @Nullable
public Entity getEntityBreaker() { public Entity entityBreaker() {
return entityBreaker; return entityBreaker;
} }
@@ -136,7 +136,7 @@ public class SprinklerBreakEvent extends Event implements Cancellable {
* @return the block state of the sprinkler. * @return the block state of the sprinkler.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -146,7 +146,7 @@ public class SprinklerBreakEvent extends Event implements Cancellable {
* @return the sprinkler configuration. * @return the sprinkler configuration.
*/ */
@NotNull @NotNull
public SprinklerConfig getSprinklerConfig() { public SprinklerConfig sprinklerConfig() {
return config; return config;
} }
@@ -156,7 +156,7 @@ public class SprinklerBreakEvent extends Event implements Cancellable {
* @return the block that caused the break, or null if not applicable. * @return the block that caused the break, or null if not applicable.
*/ */
@Nullable @Nullable
public Block getBlockBreaker() { public Block blockBreaker() {
return blockBreaker; return blockBreaker;
} }
@@ -166,7 +166,7 @@ public class SprinklerBreakEvent extends Event implements Cancellable {
* @return the reason for the break. * @return the reason for the break.
*/ */
@NotNull @NotNull
public BreakReason getReason() { public BreakReason reason() {
return reason; return reason;
} }
} }

View File

@@ -119,7 +119,7 @@ public class SprinklerFillEvent extends PlayerEvent implements Cancellable {
* @return the location of the sprinkler. * @return the location of the sprinkler.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -129,7 +129,7 @@ public class SprinklerFillEvent extends PlayerEvent implements Cancellable {
* @return the item in hand. * @return the item in hand.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
@@ -139,7 +139,7 @@ public class SprinklerFillEvent extends PlayerEvent implements Cancellable {
* @return the sprinkler configuration. * @return the sprinkler configuration.
*/ */
@NotNull @NotNull
public SprinklerConfig getSprinklerConfig() { public SprinklerConfig sprinklerConfig() {
return config; return config;
} }
@@ -149,7 +149,7 @@ public class SprinklerFillEvent extends PlayerEvent implements Cancellable {
* @return the watering method. * @return the watering method.
*/ */
@NotNull @NotNull
public WateringMethod getWateringMethod() { public WateringMethod wateringMethod() {
return wateringMethod; return wateringMethod;
} }
@@ -159,7 +159,7 @@ public class SprinklerFillEvent extends PlayerEvent implements Cancellable {
* @return the block state of the sprinkler. * @return the block state of the sprinkler.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -169,7 +169,7 @@ public class SprinklerFillEvent extends PlayerEvent implements Cancellable {
* @return the equipment slot representing the hand used. * @return the equipment slot representing the hand used.
*/ */
@NotNull @NotNull
public EquipmentSlot getHand() { public EquipmentSlot hand() {
return hand; return hand;
} }
} }

View File

@@ -114,7 +114,7 @@ public class SprinklerInteractEvent extends PlayerEvent implements Cancellable {
* @return the location of the sprinkler. * @return the location of the sprinkler.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -124,7 +124,7 @@ public class SprinklerInteractEvent extends PlayerEvent implements Cancellable {
* @return the block state of the sprinkler. * @return the block state of the sprinkler.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -134,7 +134,7 @@ public class SprinklerInteractEvent extends PlayerEvent implements Cancellable {
* @return the sprinkler configuration. * @return the sprinkler configuration.
*/ */
@NotNull @NotNull
public SprinklerConfig getSprinklerConfig() { public SprinklerConfig sprinklerConfig() {
return config; return config;
} }
@@ -144,7 +144,7 @@ public class SprinklerInteractEvent extends PlayerEvent implements Cancellable {
* @return the equipment slot representing the hand used. * @return the equipment slot representing the hand used.
*/ */
@NotNull @NotNull
public EquipmentSlot getHand() { public EquipmentSlot hand() {
return hand; return hand;
} }
@@ -154,7 +154,7 @@ public class SprinklerInteractEvent extends PlayerEvent implements Cancellable {
* @return the item in hand. * @return the item in hand.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
} }

View File

@@ -115,7 +115,7 @@ public class SprinklerPlaceEvent extends PlayerEvent implements Cancellable {
* @return the item in hand. * @return the item in hand.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
@@ -125,7 +125,7 @@ public class SprinklerPlaceEvent extends PlayerEvent implements Cancellable {
* @return the block state of the sprinkler. * @return the block state of the sprinkler.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -135,7 +135,7 @@ public class SprinklerPlaceEvent extends PlayerEvent implements Cancellable {
* @return the location of the sprinkler. * @return the location of the sprinkler.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
@@ -145,7 +145,7 @@ public class SprinklerPlaceEvent extends PlayerEvent implements Cancellable {
* @return the sprinkler configuration. * @return the sprinkler configuration.
*/ */
@NotNull @NotNull
public SprinklerConfig getSprinklerConfig() { public SprinklerConfig sprinklerConfig() {
return config; return config;
} }
@@ -155,7 +155,7 @@ public class SprinklerPlaceEvent extends PlayerEvent implements Cancellable {
* @return the equipment slot representing the hand used. * @return the equipment slot representing the hand used.
*/ */
@NotNull @NotNull
public EquipmentSlot getHand() { public EquipmentSlot hand() {
return hand; return hand;
} }
} }

View File

@@ -114,7 +114,7 @@ public class WateringCanFillEvent extends PlayerEvent implements Cancellable {
* @return the watering can item. * @return the watering can item.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
@@ -124,7 +124,7 @@ public class WateringCanFillEvent extends PlayerEvent implements Cancellable {
* @return the watering can configuration. * @return the watering can configuration.
*/ */
@NotNull @NotNull
public WateringCanConfig getConfig() { public WateringCanConfig wateringCanConfig() {
return config; return config;
} }
@@ -134,7 +134,7 @@ public class WateringCanFillEvent extends PlayerEvent implements Cancellable {
* @return the fill method. * @return the fill method.
*/ */
@NotNull @NotNull
public FillMethod getFillMethod() { public FillMethod fillMethod() {
return fillMethod; return fillMethod;
} }
@@ -144,7 +144,7 @@ public class WateringCanFillEvent extends PlayerEvent implements Cancellable {
* @return the equipment slot representing the hand used. * @return the equipment slot representing the hand used.
*/ */
@NotNull @NotNull
public EquipmentSlot getHand() { public EquipmentSlot hand() {
return hand; return hand;
} }
@@ -154,7 +154,7 @@ public class WateringCanFillEvent extends PlayerEvent implements Cancellable {
* @return the location of the action. * @return the location of the action.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
} }

View File

@@ -117,7 +117,7 @@ public class WateringCanWaterPotEvent extends PlayerEvent implements Cancellable
* @return the watering can item. * @return the watering can item.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
@@ -127,7 +127,7 @@ public class WateringCanWaterPotEvent extends PlayerEvent implements Cancellable
* @return the equipment slot representing the hand used. * @return the equipment slot representing the hand used.
*/ */
@NotNull @NotNull
public EquipmentSlot getHand() { public EquipmentSlot hand() {
return hand; return hand;
} }
@@ -137,7 +137,7 @@ public class WateringCanWaterPotEvent extends PlayerEvent implements Cancellable
* @return the watering can configuration. * @return the watering can configuration.
*/ */
@NotNull @NotNull
public WateringCanConfig getWateringCanConfig() { public WateringCanConfig wateringCanConfig() {
return wateringCanConfig; return wateringCanConfig;
} }
@@ -147,7 +147,7 @@ public class WateringCanWaterPotEvent extends PlayerEvent implements Cancellable
* @return the pot configuration. * @return the pot configuration.
*/ */
@NotNull @NotNull
public PotConfig getPotConfig() { public PotConfig potConfig() {
return potConfig; return potConfig;
} }
@@ -157,7 +157,7 @@ public class WateringCanWaterPotEvent extends PlayerEvent implements Cancellable
* @return the list of pots with positions and IDs. * @return the list of pots with positions and IDs.
*/ */
@NotNull @NotNull
public List<Pair<Pos3, String>> getPotWithIDs() { public List<Pair<Pos3, String>> pots() {
return potWithIDs; return potWithIDs;
} }
} }

View File

@@ -119,7 +119,7 @@ public class WateringCanWaterSprinklerEvent extends PlayerEvent implements Cance
* @return the watering can item. * @return the watering can item.
*/ */
@NotNull @NotNull
public ItemStack getItemInHand() { public ItemStack itemInHand() {
return itemInHand; return itemInHand;
} }
@@ -129,7 +129,7 @@ public class WateringCanWaterSprinklerEvent extends PlayerEvent implements Cance
* @return the equipment slot representing the hand used. * @return the equipment slot representing the hand used.
*/ */
@NotNull @NotNull
public EquipmentSlot getHand() { public EquipmentSlot hand() {
return hand; return hand;
} }
@@ -139,7 +139,7 @@ public class WateringCanWaterSprinklerEvent extends PlayerEvent implements Cance
* @return the watering can configuration. * @return the watering can configuration.
*/ */
@NotNull @NotNull
public WateringCanConfig getWateringCanConfig() { public WateringCanConfig wateringCanConfig() {
return wateringCanConfig; return wateringCanConfig;
} }
@@ -149,7 +149,7 @@ public class WateringCanWaterSprinklerEvent extends PlayerEvent implements Cance
* @return the sprinkler configuration. * @return the sprinkler configuration.
*/ */
@NotNull @NotNull
public SprinklerConfig getSprinklerConfig() { public SprinklerConfig sprinklerConfig() {
return sprinklerConfig; return sprinklerConfig;
} }
@@ -159,7 +159,7 @@ public class WateringCanWaterSprinklerEvent extends PlayerEvent implements Cance
* @return the block state of the sprinkler. * @return the block state of the sprinkler.
*/ */
@NotNull @NotNull
public CustomCropsBlockState getBlockState() { public CustomCropsBlockState blockState() {
return blockState; return blockState;
} }
@@ -169,7 +169,7 @@ public class WateringCanWaterSprinklerEvent extends PlayerEvent implements Cance
* @return the location of the sprinkler. * @return the location of the sprinkler.
*/ */
@NotNull @NotNull
public Location getLocation() { public Location location() {
return location; return location;
} }
} }

View File

@@ -55,9 +55,9 @@ public class BattlePassQuest implements Listener {
@EventHandler (ignoreCancelled = true) @EventHandler (ignoreCancelled = true)
public void onBreakCrop(CropBreakEvent event) { public void onBreakCrop(CropBreakEvent event) {
Entity entity = event.getEntityBreaker(); Entity entity = event.entityBreaker();
if (!(entity instanceof Player player)) return; if (!(entity instanceof Player player)) return;
String id = event.getStageItemID(); String id = event.cropStageItemID();
// remove namespace // remove namespace
if (id.contains(":")) { if (id.contains(":")) {
id = id.split(":")[1]; id = id.split(":")[1];
@@ -76,7 +76,7 @@ public class BattlePassQuest implements Listener {
// Plant crops // Plant crops
this.executionBuilder("plant") this.executionBuilder("plant")
.player(player) .player(player)
.root(event.getCropConfig().id()) .root(event.cropConfig().id())
.progress(1) .progress(1)
.buildAndExecute(); .buildAndExecute();
} }

View File

@@ -73,10 +73,10 @@ public class BetonQuestQuest {
@EventHandler (ignoreCancelled = true) @EventHandler (ignoreCancelled = true)
public void onBreakCrop(CropBreakEvent event) { public void onBreakCrop(CropBreakEvent event) {
if (!(event.getEntityBreaker() instanceof Player player)) { if (!(event.entityBreaker() instanceof Player player)) {
return; return;
} }
String id = event.getStageItemID(); String id = event.cropStageItemID();
OnlineProfile onlineProfile = PlayerConverter.getID(player); OnlineProfile onlineProfile = PlayerConverter.getID(player);
if (!containsPlayer(onlineProfile)) { if (!containsPlayer(onlineProfile)) {
@@ -155,7 +155,7 @@ public class BetonQuestQuest {
if (isInvalidLocation(event.getPlayer(), onlineProfile)) { if (isInvalidLocation(event.getPlayer(), onlineProfile)) {
return; return;
} }
if (this.crops.contains(event.getCropConfig().id()) && this.checkConditions(onlineProfile)) { if (this.crops.contains(event.cropConfig().id()) && this.checkConditions(onlineProfile)) {
getCountingData(onlineProfile).progress(1); getCountingData(onlineProfile).progress(1);
completeIfDoneOrNotify(onlineProfile); completeIfDoneOrNotify(onlineProfile);
} }

View File

@@ -42,11 +42,11 @@ public class ClueScrollsQuest implements Listener {
@EventHandler (ignoreCancelled = true) @EventHandler (ignoreCancelled = true)
public void onBreakCrop(CropBreakEvent event) { public void onBreakCrop(CropBreakEvent event) {
if (!(event.getEntityBreaker() instanceof Player player)) return; if (!(event.entityBreaker() instanceof Player player)) return;
harvestClue.handle( harvestClue.handle(
player, player,
1, 1,
new ClueDataPair("id", event.getStageItemID()) new ClueDataPair("id", event.cropStageItemID())
); );
} }
@@ -55,7 +55,7 @@ public class ClueScrollsQuest implements Listener {
plantClue.handle( plantClue.handle(
event.getPlayer(), event.getPlayer(),
1, 1,
new ClueDataPair("id", event.getCropConfig().id()) new ClueDataPair("id", event.cropConfig().id())
); );
} }
} }