mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-28 03:19:15 +00:00
3.4.2.0
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.api.event;
|
||||
|
||||
import net.momirealms.customcrops.api.mechanic.item.BoneMeal;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldCrop;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* An event that triggered when a player interacts a crop with a bone meal
|
||||
*/
|
||||
public class BoneMealDispenseEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Location location;
|
||||
private final BoneMeal boneMeal;
|
||||
private final WorldCrop crop;
|
||||
private final ItemStack boneMealItem;
|
||||
private final Block dispenser;
|
||||
|
||||
public BoneMealDispenseEvent(
|
||||
@NotNull Block dispenser,
|
||||
@NotNull ItemStack boneMealItem,
|
||||
@NotNull Location location,
|
||||
@NotNull BoneMeal boneMeal,
|
||||
@NotNull WorldCrop crop
|
||||
) {
|
||||
this.location = location;
|
||||
this.crop = crop;
|
||||
this.boneMeal = boneMeal;
|
||||
this.boneMealItem = boneMealItem;
|
||||
this.dispenser = dispenser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the crop location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item in player's hand
|
||||
* If there's nothing in hand, it would return AIR
|
||||
* @return item in hand
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getBoneMealItem() {
|
||||
return boneMealItem;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WorldCrop getCrop() {
|
||||
return crop;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BoneMeal getBoneMeal() {
|
||||
return boneMeal;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Block getDispenser() {
|
||||
return dispenser;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.api.event;
|
||||
|
||||
import net.momirealms.customcrops.api.mechanic.item.BoneMeal;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldCrop;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* An event that triggered when a player interacts a crop with a bone meal
|
||||
*/
|
||||
public class BoneMealUseEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Location location;
|
||||
private final BoneMeal boneMeal;
|
||||
private final WorldCrop crop;
|
||||
private final ItemStack itemInHand;
|
||||
private final Player player;
|
||||
|
||||
public BoneMealUseEvent(
|
||||
@NotNull Player player,
|
||||
@NotNull ItemStack itemInHand,
|
||||
@NotNull Location location,
|
||||
@NotNull BoneMeal boneMeal,
|
||||
@NotNull WorldCrop crop
|
||||
) {
|
||||
this.location = location;
|
||||
this.crop = crop;
|
||||
this.boneMeal = boneMeal;
|
||||
this.itemInHand = itemInHand;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the crop location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item in player's hand
|
||||
* If there's nothing in hand, it would return AIR
|
||||
* @return item in hand
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getItemInHand() {
|
||||
return itemInHand;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WorldCrop getCrop() {
|
||||
return crop;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BoneMeal getBoneMeal() {
|
||||
return boneMeal;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package net.momirealms.customcrops.api.event;
|
||||
|
||||
import net.momirealms.customcrops.api.mechanic.misc.Reason;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldCrop;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -37,15 +38,18 @@ public class CropBreakEvent extends Event implements Cancellable {
|
||||
private final Location location;
|
||||
private final WorldCrop worldCrop;
|
||||
private final Entity entity;
|
||||
private final Reason reason;
|
||||
|
||||
public CropBreakEvent(
|
||||
@Nullable Entity entity,
|
||||
@NotNull Location location,
|
||||
@Nullable WorldCrop worldCrop
|
||||
@NotNull WorldCrop worldCrop,
|
||||
@NotNull Reason reason
|
||||
) {
|
||||
this.entity = entity;
|
||||
this.location = location;
|
||||
this.worldCrop = worldCrop;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,4 +103,9 @@ public class CropBreakEvent extends Event implements Cancellable {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Reason getReason() {
|
||||
return reason;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.api.event;
|
||||
|
||||
import net.momirealms.customcrops.api.mechanic.item.Fertilizer;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldPot;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* An event that triggered when player tries adding fertilizer to pot
|
||||
*/
|
||||
public class FertilizerUseEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final ItemStack itemInHand;
|
||||
private final Location location;
|
||||
private final WorldPot pot;
|
||||
private final Fertilizer fertilizer;
|
||||
|
||||
public FertilizerUseEvent(
|
||||
@NotNull Player player,
|
||||
@NotNull ItemStack itemInHand,
|
||||
@NotNull Fertilizer fertilizer,
|
||||
@NotNull Location location,
|
||||
@NotNull WorldPot pot
|
||||
) {
|
||||
super(player);
|
||||
this.cancelled = false;
|
||||
this.itemInHand = itemInHand;
|
||||
this.fertilizer = fertilizer;
|
||||
this.location = location;
|
||||
this.pot = pot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemStack getItemInHand() {
|
||||
return itemInHand;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WorldPot getPot() {
|
||||
return pot;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Fertilizer getFertilizer() {
|
||||
return fertilizer;
|
||||
}
|
||||
}
|
||||
@@ -17,28 +17,39 @@
|
||||
|
||||
package net.momirealms.customcrops.api.event;
|
||||
|
||||
import net.momirealms.customcrops.api.mechanic.misc.Reason;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldGlass;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* An event that triggered when breaking greenhouse glass
|
||||
*/
|
||||
public class GreenhouseGlassBreakEvent extends PlayerEvent implements Cancellable {
|
||||
public class GreenhouseGlassBreakEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Location location;
|
||||
private final Entity entity;
|
||||
private final Reason reason;
|
||||
private final WorldGlass glass;
|
||||
|
||||
public GreenhouseGlassBreakEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull Location location
|
||||
@Nullable Entity entity,
|
||||
@NotNull Location location,
|
||||
@NotNull WorldGlass glass,
|
||||
@NotNull Reason reason
|
||||
) {
|
||||
super(who);
|
||||
this.entity = entity;
|
||||
this.location = location;
|
||||
this.reason = reason;
|
||||
this.glass = glass;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,4 +81,27 @@ public class GreenhouseGlassBreakEvent extends PlayerEvent implements Cancellabl
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Player getPlayer() {
|
||||
if (entity instanceof Player player) {
|
||||
return player;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Reason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WorldGlass getGlass() {
|
||||
return glass;
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,11 @@
|
||||
|
||||
package net.momirealms.customcrops.api.event;
|
||||
|
||||
import net.momirealms.customcrops.api.mechanic.misc.Reason;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldPot;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@@ -36,15 +38,18 @@ public class PotBreakEvent extends Event implements Cancellable {
|
||||
private final Location location;
|
||||
private final WorldPot pot;
|
||||
private final Entity entity;
|
||||
private final Reason reason;
|
||||
|
||||
public PotBreakEvent(
|
||||
@Nullable Entity entity,
|
||||
@NotNull Location location,
|
||||
@NotNull WorldPot pot
|
||||
@NotNull WorldPot pot,
|
||||
@NotNull Reason reason
|
||||
) {
|
||||
this.entity = entity;
|
||||
this.location = location;
|
||||
this.pot = pot;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,12 +92,21 @@ public class PotBreakEvent extends Event implements Cancellable {
|
||||
return pot;
|
||||
}
|
||||
|
||||
/**
|
||||
* It would be null if the event is not triggered by an entity
|
||||
* @return entity
|
||||
*/
|
||||
@Nullable
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Player getPlayer() {
|
||||
if (entity instanceof Player player) {
|
||||
return player;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Reason getReason() {
|
||||
return reason;
|
||||
}
|
||||
}
|
||||
@@ -17,28 +17,39 @@
|
||||
|
||||
package net.momirealms.customcrops.api.event;
|
||||
|
||||
import net.momirealms.customcrops.api.mechanic.misc.Reason;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldScarecrow;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* An event that triggered when breaking a scarecrow
|
||||
*/
|
||||
public class ScarecrowBreakEvent extends PlayerEvent implements Cancellable {
|
||||
public class ScarecrowBreakEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Location location;
|
||||
private final Entity entity;
|
||||
private final Reason reason;
|
||||
private final WorldScarecrow scarecrow;
|
||||
|
||||
public ScarecrowBreakEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull Location location
|
||||
@Nullable Entity entity,
|
||||
@NotNull Location location,
|
||||
@NotNull WorldScarecrow scarecrow,
|
||||
@NotNull Reason reason
|
||||
) {
|
||||
super(who);
|
||||
this.location = location;
|
||||
this.reason = reason;
|
||||
this.entity = entity;
|
||||
this.scarecrow = scarecrow;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,4 +81,27 @@ public class ScarecrowBreakEvent extends PlayerEvent implements Cancellable {
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Player getPlayer() {
|
||||
if (entity instanceof Player player) {
|
||||
return player;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Reason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public WorldScarecrow getScarecrow() {
|
||||
return scarecrow;
|
||||
}
|
||||
}
|
||||
@@ -17,31 +17,38 @@
|
||||
|
||||
package net.momirealms.customcrops.api.event;
|
||||
|
||||
import net.momirealms.customcrops.api.mechanic.misc.Reason;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldSprinkler;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* An event that triggered when breaking a sprinkler
|
||||
*/
|
||||
public class SprinklerBreakEvent extends PlayerEvent implements Cancellable {
|
||||
public class SprinklerBreakEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Location location;
|
||||
private final WorldSprinkler sprinkler;
|
||||
private final Entity entity;
|
||||
private final Reason reason;
|
||||
|
||||
public SprinklerBreakEvent(
|
||||
@NotNull Player who,
|
||||
@Nullable Entity entity,
|
||||
@NotNull Location location,
|
||||
@NotNull WorldSprinkler sprinkler
|
||||
@NotNull WorldSprinkler sprinkler,
|
||||
@NotNull Reason reason
|
||||
) {
|
||||
super(who);
|
||||
this.entity = entity;
|
||||
this.location = location;
|
||||
this.reason = reason;
|
||||
this.sprinkler = sprinkler;
|
||||
}
|
||||
|
||||
@@ -83,4 +90,22 @@ public class SprinklerBreakEvent extends PlayerEvent implements Cancellable {
|
||||
public WorldSprinkler getSprinkler() {
|
||||
return sprinkler;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Player getPlayer() {
|
||||
if (entity instanceof Player player) {
|
||||
return player;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Reason getReason() {
|
||||
return reason;
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,12 @@ public class SprinklerPlaceEvent extends PlayerEvent implements Cancellable {
|
||||
private final Location location;
|
||||
private final Sprinkler sprinkler;
|
||||
|
||||
public SprinklerPlaceEvent(@NotNull Player who, ItemStack itemInHand, Location location, Sprinkler sprinkler) {
|
||||
public SprinklerPlaceEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull ItemStack itemInHand,
|
||||
@NotNull Location location,
|
||||
@NotNull Sprinkler sprinkler
|
||||
) {
|
||||
super(who);
|
||||
this.itemInHand = itemInHand;
|
||||
this.location = location;
|
||||
|
||||
@@ -42,8 +42,8 @@ public class WateringCanFillEvent extends PlayerEvent implements Cancellable {
|
||||
public WateringCanFillEvent(
|
||||
@NotNull Player player,
|
||||
@NotNull ItemStack itemInHand,
|
||||
@NotNull WateringCan wateringCan,
|
||||
@NotNull Location location,
|
||||
@NotNull WateringCan wateringCan,
|
||||
@NotNull PositiveFillMethod fillMethod
|
||||
) {
|
||||
super(player);
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
package net.momirealms.customcrops.api.event;
|
||||
|
||||
import net.momirealms.customcrops.api.common.item.KeyItem;
|
||||
import net.momirealms.customcrops.api.mechanic.item.WateringCan;
|
||||
import net.momirealms.customcrops.api.mechanic.world.CustomCropsBlock;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
@@ -27,6 +27,8 @@ import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* An event that triggered when player tries to use watering-can to add water to pots/sprinklers
|
||||
*/
|
||||
@@ -36,15 +38,15 @@ public class WateringCanWaterEvent extends PlayerEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
private final ItemStack itemInHand;
|
||||
private final WateringCan wateringCan;
|
||||
private final KeyItem potOrSprinkler;
|
||||
private final Location location;
|
||||
private final CustomCropsBlock potOrSprinkler;
|
||||
private final Set<Location> location;
|
||||
|
||||
public WateringCanWaterEvent(
|
||||
@NotNull Player player,
|
||||
@NotNull ItemStack itemInHand,
|
||||
@NotNull Set<Location> location,
|
||||
@NotNull WateringCan wateringCan,
|
||||
@NotNull Location location,
|
||||
@NotNull KeyItem potOrSprinkler
|
||||
@NotNull CustomCropsBlock potOrSprinkler
|
||||
) {
|
||||
super(player);
|
||||
this.cancelled = false;
|
||||
@@ -85,12 +87,12 @@ public class WateringCanWaterEvent extends PlayerEvent implements Cancellable {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
public Set<Location> getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public KeyItem getPotOrSprinkler() {
|
||||
public CustomCropsBlock getPotOrSprinkler() {
|
||||
return potOrSprinkler;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,4 +38,20 @@ public interface SeasonInterface {
|
||||
* @return date
|
||||
*/
|
||||
int getDate(World world);
|
||||
|
||||
/**
|
||||
* Set a world's season
|
||||
*
|
||||
* @param world world
|
||||
* @param season season
|
||||
*/
|
||||
void setSeason(World world, Season season);
|
||||
|
||||
/**
|
||||
* Set a world's date
|
||||
*
|
||||
* @param world world
|
||||
* @param date date
|
||||
*/
|
||||
void setDate(World world, int date);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import net.momirealms.customcrops.api.integration.LevelInterface;
|
||||
import net.momirealms.customcrops.api.integration.SeasonInterface;
|
||||
import net.momirealms.customcrops.api.mechanic.world.season.Season;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface IntegrationManager extends Initable {
|
||||
@@ -57,6 +56,4 @@ public interface IntegrationManager extends Initable {
|
||||
Season getSeason(World world);
|
||||
|
||||
int getDate(World world);
|
||||
|
||||
ItemStack build(String itemID);
|
||||
}
|
||||
|
||||
@@ -32,14 +32,24 @@ public class BoneMeal {
|
||||
private final int returnedAmount;
|
||||
private final List<Pair<Double, Integer>> pointGainList;
|
||||
private final Action[] actions;
|
||||
private final boolean dispenserAllowed;
|
||||
|
||||
public BoneMeal(String item, int usedAmount, String returned, int returnedAmount, List<Pair<Double, Integer>> pointGainList, Action[] actions) {
|
||||
public BoneMeal(
|
||||
String item,
|
||||
int usedAmount,
|
||||
String returned,
|
||||
int returnedAmount,
|
||||
boolean dispenserAllowed,
|
||||
List<Pair<Double, Integer>> pointGainList,
|
||||
Action[] actions
|
||||
) {
|
||||
this.item = item;
|
||||
this.returned = returned;
|
||||
this.pointGainList = pointGainList;
|
||||
this.actions = actions;
|
||||
this.usedAmount = usedAmount;
|
||||
this.returnedAmount = returnedAmount;
|
||||
this.dispenserAllowed = dispenserAllowed;
|
||||
}
|
||||
|
||||
public String getItem() {
|
||||
@@ -70,4 +80,8 @@ public class BoneMeal {
|
||||
public int getReturnedAmount() {
|
||||
return returnedAmount;
|
||||
}
|
||||
|
||||
public boolean isDispenserAllowed() {
|
||||
return dispenserAllowed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.api.mechanic.misc;
|
||||
|
||||
public enum Reason {
|
||||
// Player break
|
||||
BREAK,
|
||||
// Trampling
|
||||
TRAMPLE,
|
||||
// Block explosion and entity explosion
|
||||
EXPLODE,
|
||||
// Action "break"
|
||||
ACTION
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class WorldSetting implements Cloneable {
|
||||
);
|
||||
}
|
||||
|
||||
public boolean isEnableScheduler() {
|
||||
public boolean isSchedulerEnabled() {
|
||||
return enableScheduler;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user