mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-28 03:19:15 +00:00
3.3.1.0
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import net.momirealms.customcrops.api.object.CCGrowingCrop;
|
||||
import net.momirealms.customcrops.api.object.CCPot;
|
||||
import net.momirealms.customcrops.api.object.CCSprinkler;
|
||||
import net.momirealms.customcrops.api.object.CCWorldSeason;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface CustomCropsAPI {
|
||||
|
||||
/**
|
||||
* Get the pot instance at the specified location
|
||||
* In order to reduce the memory usage, pot data would be removed
|
||||
* if it has no water and no fertilizer
|
||||
* But if "only-work-in-loaded-chunks" is true, pot data would not be removed
|
||||
* @param location location
|
||||
* @return pot
|
||||
*/
|
||||
@Nullable
|
||||
CCPot getPotAt(Location location);
|
||||
|
||||
/**
|
||||
* Get the on growing crop at the specified location
|
||||
* It would be null if the crop already comes to its final stage
|
||||
* @param location location
|
||||
* @return on growing crop
|
||||
*/
|
||||
@Nullable
|
||||
CCGrowingCrop getCropAt(Location location);
|
||||
|
||||
/**
|
||||
* If the block is a greenhouse glass in data
|
||||
* It would return false if your greenhouse glass lost due to server crash
|
||||
* @param location location
|
||||
* @return whether the block is greenhouse glass
|
||||
*/
|
||||
boolean isGreenhouseGlass(Location location);
|
||||
|
||||
/**
|
||||
* If the chunk has a scarecrow
|
||||
* @param location location
|
||||
* @return has scarecrow or not
|
||||
*/
|
||||
boolean hasScarecrowInChunk(Location location);
|
||||
|
||||
/**
|
||||
* Get the sprinkler at the specified location
|
||||
* It would be null if the sprinkler run out of water
|
||||
* @param location location
|
||||
* @return sprinkler
|
||||
*/
|
||||
@Nullable
|
||||
CCSprinkler getSprinklerAt(Location location);
|
||||
|
||||
/**
|
||||
* Set the world's season
|
||||
* @param world world
|
||||
* @param season season
|
||||
*/
|
||||
void setSeason(String world, String season);
|
||||
|
||||
/**
|
||||
* Set the world's date
|
||||
* @param world world
|
||||
* @param date date
|
||||
*/
|
||||
void setDate(String world, int date);
|
||||
|
||||
/**
|
||||
* Add a world's date
|
||||
* @param world world
|
||||
*/
|
||||
void addDate(String world);
|
||||
|
||||
/**
|
||||
* Get a world's season
|
||||
* @param world world
|
||||
* @return season
|
||||
*/
|
||||
@Nullable
|
||||
CCWorldSeason getSeason(String world);
|
||||
|
||||
/**
|
||||
* Force the crops to grow in specified seconds
|
||||
* @param world world
|
||||
* @param seconds time
|
||||
*/
|
||||
void grow(World world, int seconds);
|
||||
|
||||
/**
|
||||
* Force the sprinkler to work in specified seconds
|
||||
* @param world world
|
||||
* @param seconds time
|
||||
*/
|
||||
void sprinklerWork(World world, int seconds);
|
||||
|
||||
/**
|
||||
* Force the pots to reduce water and consume fertilizer in specified seconds
|
||||
* @param world world
|
||||
* @param seconds time
|
||||
*/
|
||||
void consume(World world, int seconds);
|
||||
|
||||
/**
|
||||
* Get the api instance
|
||||
* It would be null if the plugin is not enabled
|
||||
* @return api
|
||||
*/
|
||||
@Nullable
|
||||
static CustomCropsAPI getInstance() {
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin("CustomCrops");
|
||||
if (plugin instanceof CustomCropsPlugin cc) {
|
||||
return cc.getAPI();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class CustomCropsPlugin extends JavaPlugin {
|
||||
|
||||
protected CustomCropsAPI customCropsAPI;
|
||||
|
||||
public CustomCropsAPI getAPI() {
|
||||
return customCropsAPI;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* 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 org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* An event that triggered when breaking a crop
|
||||
*/
|
||||
public class CropBreakEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final String cropItemID;
|
||||
private final String cropKey;
|
||||
private final Location location;
|
||||
private final Entity entity;
|
||||
|
||||
public CropBreakEvent(
|
||||
@Nullable Entity entity,
|
||||
@NotNull String cropItemID,
|
||||
@NotNull String cropKey,
|
||||
@NotNull Location location
|
||||
) {
|
||||
this.entity = entity;
|
||||
this.cropItemID = cropItemID;
|
||||
this.location = location;
|
||||
this.cropKey = cropKey;
|
||||
}
|
||||
|
||||
@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 item id in IA/Oraxen
|
||||
* @return item id
|
||||
*/
|
||||
@NotNull
|
||||
public String getCropItemID() {
|
||||
return cropItemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the crop location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Would be null if the crop is not broken by an entity
|
||||
* @return entity
|
||||
*/
|
||||
@Nullable
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the crop config key
|
||||
* @return crop key
|
||||
*/
|
||||
@NotNull
|
||||
public String getCropKey() {
|
||||
return cropKey;
|
||||
}
|
||||
}
|
||||
@@ -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 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 a player interacts a crop
|
||||
*/
|
||||
public class CropInteractEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Location location;
|
||||
private final String cropItemID;
|
||||
private final String cropKey;
|
||||
private final ItemStack itemInHand;
|
||||
|
||||
public CropInteractEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull ItemStack itemInHand,
|
||||
@NotNull Location location,
|
||||
@NotNull String cropItemID,
|
||||
@NotNull String cropKey
|
||||
) {
|
||||
super(who);
|
||||
this.cropItemID = cropItemID;
|
||||
this.location = location;
|
||||
this.cropKey = cropKey;
|
||||
this.itemInHand = itemInHand;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the crop model item id
|
||||
* @return model item id
|
||||
*/
|
||||
@NotNull
|
||||
public String getCropItemID() {
|
||||
return cropItemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the crop config key
|
||||
* @return crop key
|
||||
*/
|
||||
@NotNull
|
||||
public String getCropKey() {
|
||||
return cropKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* 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 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 planting a crop
|
||||
*/
|
||||
public class CropPlantEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final ItemStack itemInHand;
|
||||
private final String cropKey;
|
||||
private final Location location;
|
||||
private int point;
|
||||
private String cropItemID;
|
||||
|
||||
public CropPlantEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull ItemStack itemInHand,
|
||||
@NotNull Location location,
|
||||
@NotNull String cropKey,
|
||||
int point,
|
||||
@NotNull String cropItemID
|
||||
) {
|
||||
super(who);
|
||||
this.itemInHand = itemInHand;
|
||||
this.location = location;
|
||||
this.cropKey = cropKey;
|
||||
this.point = point;
|
||||
this.cropItemID = cropItemID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the seed item
|
||||
* @return seed item
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getItemInHand() {
|
||||
return itemInHand;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the crop config key
|
||||
* @return crop key
|
||||
*/
|
||||
@NotNull
|
||||
public String getCropKey() {
|
||||
return cropKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the crop location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the initial point
|
||||
* It would be 0 when planting
|
||||
* but might be a value higher than 0 when replanting
|
||||
* @return point
|
||||
*/
|
||||
public int getPoint() {
|
||||
return point;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the initial point
|
||||
* @param point point
|
||||
*/
|
||||
public void setPoint(int point) {
|
||||
this.point = point;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the crop stage model item id
|
||||
* @return crop model
|
||||
*/
|
||||
@NotNull
|
||||
public String getCropModel() {
|
||||
return cropItemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the crop model item id
|
||||
* @param cropItemID crop model item id
|
||||
*/
|
||||
public void setCropModel(String cropItemID) {
|
||||
this.cropItemID = cropItemID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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 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 is using fertilizers
|
||||
*/
|
||||
public class FertilizerUseEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final ItemStack itemInHand;
|
||||
private final String fertilizerKey;
|
||||
private final Location location;
|
||||
|
||||
public FertilizerUseEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull ItemStack itemInHand,
|
||||
@NotNull String fertilizerKey,
|
||||
@NotNull Location location
|
||||
) {
|
||||
super(who);
|
||||
this.itemInHand = itemInHand;
|
||||
this.fertilizerKey = fertilizerKey;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fertilizer item in hand
|
||||
* @return fertilizer itemStack
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getItemInHand() {
|
||||
return itemInHand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fertilizer config key
|
||||
* @return fertilizer key
|
||||
*/
|
||||
@NotNull
|
||||
public String getFertilizerKey() {
|
||||
return fertilizerKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pot location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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 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.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* An event that triggered when breaking greenhouse glass
|
||||
*/
|
||||
public class GreenhouseGlassBreakEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Location location;
|
||||
|
||||
public GreenhouseGlassBreakEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull Location location
|
||||
) {
|
||||
super(who);
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@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 glass location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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 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.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* An event that triggered when placing greenhouse glass
|
||||
*/
|
||||
public class GreenhouseGlassPlaceEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Location location;
|
||||
|
||||
public GreenhouseGlassPlaceEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull Location location
|
||||
) {
|
||||
super(who);
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@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 glass location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@@ -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 org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* An event that triggered when breaking a pot
|
||||
*/
|
||||
public class PotBreakEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Location location;
|
||||
private final String potKey;
|
||||
private final Entity entity;
|
||||
|
||||
public PotBreakEvent(
|
||||
@Nullable Entity entity,
|
||||
@NotNull Location location,
|
||||
@NotNull String potKey
|
||||
) {
|
||||
this.entity = entity;
|
||||
this.location = location;
|
||||
this.potKey = potKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pot location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pot config key
|
||||
* @return pot key
|
||||
*/
|
||||
@NotNull
|
||||
public String getPotKey() {
|
||||
return potKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* It would be null if the event is not triggered by an entity
|
||||
* @return entity
|
||||
*/
|
||||
@Nullable
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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.object.CCFertilizer;
|
||||
import net.momirealms.customcrops.api.object.CCGrowingCrop;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* This event is called after a player interacted a pot
|
||||
* So the fertilizer/water would be updated
|
||||
*/
|
||||
public class PotInfoEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final CCFertilizer fertilizer;
|
||||
private final int water;
|
||||
private final CCGrowingCrop growingCrop;
|
||||
private final ItemStack itemInHand;
|
||||
private final Location location;
|
||||
|
||||
|
||||
public PotInfoEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull Location location,
|
||||
@NotNull ItemStack itemInHand,
|
||||
@Nullable CCFertilizer fertilizer,
|
||||
int water,
|
||||
@Nullable CCGrowingCrop growingCrop
|
||||
) {
|
||||
super(who);
|
||||
this.fertilizer = fertilizer;
|
||||
this.water = water;
|
||||
this.growingCrop = growingCrop;
|
||||
this.itemInHand = itemInHand;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fertilizer
|
||||
* @return fertilizer
|
||||
*/
|
||||
@Nullable
|
||||
public CCFertilizer getFertilizer() {
|
||||
return fertilizer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the water amount
|
||||
* @return water amount
|
||||
*/
|
||||
public int getWater() {
|
||||
return water;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the on growing crop above the pot
|
||||
* It would be null if there's no crop or the crop is already ripe
|
||||
* @return crop
|
||||
*/
|
||||
@Nullable
|
||||
public CCGrowingCrop getGrowingCrop() {
|
||||
return growingCrop;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pot location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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 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;
|
||||
|
||||
/**
|
||||
* This event is called when a player is interacting a pot
|
||||
*/
|
||||
public class PotInteractEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final ItemStack itemInHand;
|
||||
private final Location location;
|
||||
private final String potKey;
|
||||
|
||||
public PotInteractEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull ItemStack itemInHand,
|
||||
@NotNull Location location,
|
||||
@NotNull String potKey
|
||||
) {
|
||||
super(who);
|
||||
this.itemInHand = itemInHand;
|
||||
this.location = location;
|
||||
this.potKey = potKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancelling this event would cancel PotInfoEvent too
|
||||
* @param cancel true if you wish to cancel this event
|
||||
*/
|
||||
@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 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pot location
|
||||
* @return pot location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pot's config key
|
||||
* @return pot key
|
||||
*/
|
||||
@NotNull
|
||||
public String getPotKey() {
|
||||
return potKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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 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.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* An event that triggered when placing a pot
|
||||
*/
|
||||
public class PotPlaceEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Location location;
|
||||
private final String potKey;
|
||||
|
||||
public PotPlaceEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull Location location,
|
||||
@NotNull String potKey
|
||||
) {
|
||||
super(who);
|
||||
this.location = location;
|
||||
this.potKey = potKey;
|
||||
}
|
||||
|
||||
@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 pot location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the placed pot config key
|
||||
* @return pot key
|
||||
*/
|
||||
@NotNull
|
||||
public String getPotKey() {
|
||||
return potKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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 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 watering a pot
|
||||
*/
|
||||
public class PotWaterEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final ItemStack itemInHand;
|
||||
private int water;
|
||||
private final Location location;
|
||||
|
||||
public PotWaterEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull ItemStack itemInHand,
|
||||
int water,
|
||||
@NotNull Location location) {
|
||||
super(who);
|
||||
this.itemInHand = itemInHand;
|
||||
this.water = water;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@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 pot location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item in player's hand
|
||||
* @return item in hand
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getItemInHand() {
|
||||
return itemInHand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of water
|
||||
* @return the amount of water that added to the pot
|
||||
*/
|
||||
public int getWater() {
|
||||
return water;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the amount of water that added to the pot
|
||||
* @param water water
|
||||
*/
|
||||
public void setWater(int water) {
|
||||
this.water = water;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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 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.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* An event that triggered when breaking a scarecrow
|
||||
*/
|
||||
public class ScarecrowBreakEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Location location;
|
||||
|
||||
public ScarecrowBreakEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull Location location
|
||||
) {
|
||||
super(who);
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@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 scarecrow location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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 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.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* An event that triggered when placing a scarecrow
|
||||
*/
|
||||
public class ScarecrowPlaceEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Location location;
|
||||
|
||||
public ScarecrowPlaceEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull Location location
|
||||
) {
|
||||
super(who);
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@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 scarecrow location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.object.CCWorldSeason;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.world.WorldEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* An event that triggered when season changes
|
||||
*/
|
||||
public class SeasonChangeEvent extends WorldEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final CCWorldSeason season;
|
||||
|
||||
public SeasonChangeEvent(
|
||||
@NotNull World world,
|
||||
@NotNull CCWorldSeason season
|
||||
) {
|
||||
super(world);
|
||||
this.season = season;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the new season
|
||||
* @return season
|
||||
*/
|
||||
@NotNull
|
||||
public CCWorldSeason getSeason() {
|
||||
return season;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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 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.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* An event that triggered when breaking a sprinkler
|
||||
*/
|
||||
public class SprinklerBreakEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Location location;
|
||||
private final String sprinklerKey;
|
||||
|
||||
public SprinklerBreakEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull Location location,
|
||||
@NotNull String sprinklerKey
|
||||
) {
|
||||
super(who);
|
||||
this.location = location;
|
||||
this.sprinklerKey = sprinklerKey;
|
||||
}
|
||||
|
||||
@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 sprinkler location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sprinkler config key
|
||||
* @return sprinkler key
|
||||
*/
|
||||
@NotNull
|
||||
public String getSprinklerKey() {
|
||||
return sprinklerKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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 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 filling a sprinkler
|
||||
*/
|
||||
public class SprinklerFillEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final ItemStack itemInHand;
|
||||
private int water;
|
||||
private final Location location;
|
||||
private final String sprinklerKey;
|
||||
|
||||
public SprinklerFillEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull String sprinklerKey,
|
||||
@NotNull ItemStack itemInHand,
|
||||
int water,
|
||||
@NotNull Location location) {
|
||||
super(who);
|
||||
this.itemInHand = itemInHand;
|
||||
this.water = water;
|
||||
this.location = location;
|
||||
this.sprinklerKey = sprinklerKey;
|
||||
}
|
||||
|
||||
@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 item in player's hand
|
||||
* @return item in hand
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getItemInHand() {
|
||||
return itemInHand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sprinkler location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of water
|
||||
* @return the amount of water that added to the sprinkler
|
||||
*/
|
||||
public int getWater() {
|
||||
return water;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the water that added to the sprinkler
|
||||
* @param water water
|
||||
*/
|
||||
public void setWater(int water) {
|
||||
this.water = water;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sprinkler config key
|
||||
* @return sprinkler key
|
||||
*/
|
||||
@NotNull
|
||||
public String getSprinklerKey() {
|
||||
return sprinklerKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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 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 interacting a sprinkler
|
||||
*/
|
||||
public class SprinklerInteractEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Location location;
|
||||
private final String sprinklerKey;
|
||||
private final ItemStack itemInHand;
|
||||
|
||||
public SprinklerInteractEvent(
|
||||
@NotNull Player who,
|
||||
@NotNull ItemStack itemInHand,
|
||||
@NotNull Location location,
|
||||
@NotNull String sprinklerKey
|
||||
) {
|
||||
super(who);
|
||||
this.location = location;
|
||||
this.sprinklerKey = sprinklerKey;
|
||||
this.itemInHand = itemInHand;
|
||||
}
|
||||
|
||||
@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 sprinkler location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sprinkler config key
|
||||
* @return sprinkler key
|
||||
*/
|
||||
@NotNull
|
||||
public String getSprinklerKey() {
|
||||
return sprinklerKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item in player's hand
|
||||
* @return item in hand
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getItemInHand() {
|
||||
return itemInHand;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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 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 placing a sprinkler
|
||||
*/
|
||||
public class SprinklerPlaceEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final ItemStack itemInHand;
|
||||
private final Location location;
|
||||
private final String sprinklerKey;
|
||||
|
||||
public SprinklerPlaceEvent(@NotNull Player who, ItemStack itemInHand, Location location, String sprinklerKey) {
|
||||
super(who);
|
||||
this.itemInHand = itemInHand;
|
||||
this.location = location;
|
||||
this.sprinklerKey = sprinklerKey;
|
||||
}
|
||||
|
||||
@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 item in player's hand
|
||||
* @return item in hand
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getItemInHand() {
|
||||
return itemInHand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sprinkler location
|
||||
* @return location
|
||||
*/
|
||||
@NotNull
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sprinkler config key
|
||||
* @return sprinkler key
|
||||
*/
|
||||
@NotNull
|
||||
public String getSprinklerKey() {
|
||||
return sprinklerKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.object;
|
||||
|
||||
/**
|
||||
* Fertilizer
|
||||
*/
|
||||
public interface CCFertilizer {
|
||||
|
||||
/**
|
||||
* Reduce the fertilizer's usage times
|
||||
* @return whether the fertilizer is used up
|
||||
*/
|
||||
boolean reduceTimes();
|
||||
|
||||
/**
|
||||
* Get the fertilizer key in config
|
||||
* @return key
|
||||
*/
|
||||
String getKey();
|
||||
|
||||
/**
|
||||
* Get the remaining usage times
|
||||
* @return times
|
||||
*/
|
||||
int getLeftTimes();
|
||||
|
||||
/**
|
||||
* Set remaining usage times
|
||||
* @param times times
|
||||
*/
|
||||
void setTimes(int times);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.object;
|
||||
|
||||
/**
|
||||
* Crops
|
||||
*/
|
||||
public interface CCGrowingCrop {
|
||||
|
||||
/**
|
||||
* Get the crop growing point
|
||||
* @return point
|
||||
*/
|
||||
int getPoints();
|
||||
|
||||
/**
|
||||
* Set the growing point
|
||||
* @param points points
|
||||
*/
|
||||
void setPoints(int points);
|
||||
|
||||
/**
|
||||
* Get the crop config key
|
||||
* @return crop key
|
||||
*/
|
||||
String getKey();
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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.object;
|
||||
|
||||
/**
|
||||
* Pot
|
||||
*/
|
||||
public interface CCPot {
|
||||
|
||||
/**
|
||||
* Get the pot config key
|
||||
* @return key
|
||||
*/
|
||||
String getKey();
|
||||
|
||||
/**
|
||||
* Get the fertilizer inside the pot
|
||||
* @return fertilizer
|
||||
*/
|
||||
CCFertilizer getFertilizer();
|
||||
|
||||
/**
|
||||
* Set the fertilizer to the pot
|
||||
* @param fertilizer fertilizer
|
||||
*/
|
||||
void setFertilizer(CCFertilizer fertilizer);
|
||||
|
||||
/**
|
||||
* Get the water amount
|
||||
* @return water amount
|
||||
*/
|
||||
int getWater();
|
||||
|
||||
/**
|
||||
* Whether the pot is wet
|
||||
* @return wet or not
|
||||
*/
|
||||
boolean isWet();
|
||||
|
||||
/**
|
||||
* Add water to pot
|
||||
* @param amount water amount
|
||||
* @return whether the pot is previously dry
|
||||
*/
|
||||
boolean addWater(int amount);
|
||||
|
||||
/**
|
||||
* Set water amount
|
||||
* @param amount amount
|
||||
*/
|
||||
void setWater(int amount);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.object;
|
||||
|
||||
/**
|
||||
* Sprinkler
|
||||
*/
|
||||
public interface CCSprinkler {
|
||||
|
||||
/**
|
||||
* Get the remaining water
|
||||
* @return water amount
|
||||
*/
|
||||
int getWater();
|
||||
|
||||
/**
|
||||
* Set the remaining water
|
||||
* @param water water
|
||||
*/
|
||||
void setWater(int water);
|
||||
|
||||
/**
|
||||
* Get the sprinkler config key
|
||||
* @return sprinkler key
|
||||
*/
|
||||
String getKey();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.object;
|
||||
|
||||
/**
|
||||
* Season
|
||||
*/
|
||||
public interface CCWorldSeason {
|
||||
|
||||
/**
|
||||
* SPRING, SUMMER, AUTUMN, WINTER
|
||||
* @return season
|
||||
*/
|
||||
String getSeason();
|
||||
|
||||
/**
|
||||
* Get the season display name
|
||||
* @return display name
|
||||
*/
|
||||
String getDisplay();
|
||||
}
|
||||
Reference in New Issue
Block a user