mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 16:39:36 +00:00
API improvement
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'net.momirealms'
|
group = 'net.momirealms'
|
||||||
version = '2.0-r9'
|
version = '2.0.1'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package net.momirealms.customcrops.api.crop;
|
package net.momirealms.customcrops.api.crop;
|
||||||
|
|
||||||
import net.momirealms.customcrops.integrations.season.CCSeason;
|
import net.momirealms.customcrops.api.utils.CCSeason;
|
||||||
import net.momirealms.customcrops.objects.GiganticCrop;
|
import net.momirealms.customcrops.objects.GiganticCrop;
|
||||||
import net.momirealms.customcrops.objects.OtherLoot;
|
import net.momirealms.customcrops.objects.OtherLoot;
|
||||||
import net.momirealms.customcrops.objects.QualityLoot;
|
import net.momirealms.customcrops.objects.QualityLoot;
|
||||||
|
|||||||
@@ -22,19 +22,22 @@ import net.momirealms.customcrops.api.crop.Crop;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class SeedPlantEvent extends PlayerEvent implements Cancellable {
|
public class SeedPlantEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
private final Location seedLoc;
|
private final Location seedLoc;
|
||||||
private final Crop crop;
|
private final Crop crop;
|
||||||
|
private final Player player;
|
||||||
|
|
||||||
public SeedPlantEvent(@NotNull Player who, Location seedLoc, Crop crop) {
|
public SeedPlantEvent(@Nullable Player who, Location seedLoc, Crop crop) {
|
||||||
super(who);
|
this.player = who;
|
||||||
this.cancelled = false;
|
this.cancelled = false;
|
||||||
this.seedLoc = seedLoc;
|
this.seedLoc = seedLoc;
|
||||||
this.crop = crop;
|
this.crop = crop;
|
||||||
@@ -62,4 +65,12 @@ public class SeedPlantEvent extends PlayerEvent implements Cancellable {
|
|||||||
public Crop getCrop() {
|
public Crop getCrop() {
|
||||||
return crop;
|
return crop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return null if this is not triggered by a player
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.momirealms.customcrops.integrations.season;
|
package net.momirealms.customcrops.api.utils;
|
||||||
|
|
||||||
public enum CCSeason {
|
public enum CCSeason {
|
||||||
|
|
||||||
@@ -17,8 +17,10 @@
|
|||||||
|
|
||||||
package net.momirealms.customcrops.api.utils;
|
package net.momirealms.customcrops.api.utils;
|
||||||
|
|
||||||
|
import net.momirealms.customcrops.CustomCrops;
|
||||||
import net.momirealms.customcrops.api.crop.Crop;
|
import net.momirealms.customcrops.api.crop.Crop;
|
||||||
import net.momirealms.customcrops.config.CropConfig;
|
import net.momirealms.customcrops.config.CropConfig;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class CropUtils {
|
public class CropUtils {
|
||||||
@@ -32,4 +34,14 @@ public class CropUtils {
|
|||||||
public static Crop getCrop(String crop) {
|
public static Crop getCrop(String crop) {
|
||||||
return CropConfig.CROPS.get(crop);
|
return CropConfig.CROPS.get(crop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* whether planting succeeds
|
||||||
|
* @param location location
|
||||||
|
* @param crop crop
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean plantCrop(Location location, String crop) {
|
||||||
|
return CustomCrops.plugin.getCropManager().getHandler().plantSeed(location, crop, null, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package net.momirealms.customcrops.api.utils;
|
package net.momirealms.customcrops.api.utils;
|
||||||
|
|
||||||
import net.momirealms.customcrops.CustomCrops;
|
import net.momirealms.customcrops.CustomCrops;
|
||||||
import net.momirealms.customcrops.integrations.season.CCSeason;
|
import net.momirealms.customcrops.config.MessageConfig;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -50,4 +50,14 @@ public class SeasonUtils {
|
|||||||
public static void unloadSeason(World world) {
|
public static void unloadSeason(World world) {
|
||||||
CustomCrops.plugin.getCropManager().getSeasonAPI().unloadWorld(world);
|
CustomCrops.plugin.getCropManager().getSeasonAPI().unloadWorld(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getSeasonText(CCSeason season) {
|
||||||
|
return switch (season) {
|
||||||
|
case SPRING -> MessageConfig.spring;
|
||||||
|
case SUMMER -> MessageConfig.summer;
|
||||||
|
case AUTUMN -> MessageConfig.autumn;
|
||||||
|
case WINTER -> MessageConfig.winter;
|
||||||
|
default -> throw new IllegalStateException("Unexpected value: " + season);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import net.momirealms.customcrops.commands.AbstractSubCommand;
|
|||||||
import net.momirealms.customcrops.commands.SubCommand;
|
import net.momirealms.customcrops.commands.SubCommand;
|
||||||
import net.momirealms.customcrops.config.MessageConfig;
|
import net.momirealms.customcrops.config.MessageConfig;
|
||||||
import net.momirealms.customcrops.config.SeasonConfig;
|
import net.momirealms.customcrops.config.SeasonConfig;
|
||||||
import net.momirealms.customcrops.integrations.season.CCSeason;
|
import net.momirealms.customcrops.api.utils.CCSeason;
|
||||||
import net.momirealms.customcrops.utils.AdventureUtil;
|
import net.momirealms.customcrops.utils.AdventureUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package net.momirealms.customcrops.config;
|
package net.momirealms.customcrops.config;
|
||||||
|
|
||||||
import net.momirealms.customcrops.api.crop.Crop;
|
import net.momirealms.customcrops.api.crop.Crop;
|
||||||
import net.momirealms.customcrops.integrations.season.CCSeason;
|
import net.momirealms.customcrops.api.utils.CCSeason;
|
||||||
import net.momirealms.customcrops.objects.CCCrop;
|
import net.momirealms.customcrops.objects.CCCrop;
|
||||||
import net.momirealms.customcrops.objects.GiganticCrop;
|
import net.momirealms.customcrops.objects.GiganticCrop;
|
||||||
import net.momirealms.customcrops.objects.OtherLoot;
|
import net.momirealms.customcrops.objects.OtherLoot;
|
||||||
|
|||||||
@@ -24,8 +24,9 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|||||||
import net.momirealms.customcrops.CustomCrops;
|
import net.momirealms.customcrops.CustomCrops;
|
||||||
import net.momirealms.customcrops.api.crop.Crop;
|
import net.momirealms.customcrops.api.crop.Crop;
|
||||||
import net.momirealms.customcrops.api.event.*;
|
import net.momirealms.customcrops.api.event.*;
|
||||||
|
import net.momirealms.customcrops.api.utils.SeasonUtils;
|
||||||
import net.momirealms.customcrops.config.*;
|
import net.momirealms.customcrops.config.*;
|
||||||
import net.momirealms.customcrops.integrations.season.CCSeason;
|
import net.momirealms.customcrops.api.utils.CCSeason;
|
||||||
import net.momirealms.customcrops.managers.CropManager;
|
import net.momirealms.customcrops.managers.CropManager;
|
||||||
import net.momirealms.customcrops.managers.CustomWorld;
|
import net.momirealms.customcrops.managers.CustomWorld;
|
||||||
import net.momirealms.customcrops.managers.listener.InteractListener;
|
import net.momirealms.customcrops.managers.listener.InteractListener;
|
||||||
@@ -535,53 +536,54 @@ public abstract class HandlerP extends Function {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void plantSeed(Location seedLoc, String cropName, Player player, ItemStack itemInHand, boolean isOraxen, boolean isWire) {
|
public boolean plantSeed(Location seedLoc, String cropName, @Nullable Player player, @Nullable ItemStack itemInHand) {
|
||||||
Crop crop = CropConfig.CROPS.get(cropName);
|
Crop crop = CropConfig.CROPS.get(cropName);
|
||||||
if (crop == null) return;
|
if (crop == null) return false;
|
||||||
|
|
||||||
CustomWorld customWorld = cropManager.getCustomWorld(seedLoc.getWorld());
|
CustomWorld customWorld = cropManager.getCustomWorld(seedLoc.getWorld());
|
||||||
if (customWorld == null) return;
|
if (customWorld == null) return false;
|
||||||
|
|
||||||
if (!isOraxen && FurnitureUtil.hasFurniture(seedLoc.clone().add(0.5,0.5,0.5))) return;
|
if (!MainConfig.OraxenHook && FurnitureUtil.hasFurniture(seedLoc.clone().add(0.5,0.5,0.5))) return false;
|
||||||
if (isOraxen && FurnitureUtil.hasFurniture(seedLoc.clone().add(0.5,0.03125,0.5))) return;
|
if (MainConfig.OraxenHook && FurnitureUtil.hasFurniture(seedLoc.clone().add(0.5,0.03125,0.5))) return false;
|
||||||
if (seedLoc.getBlock().getType() != Material.AIR) return;
|
if (seedLoc.getBlock().getType() != Material.AIR) return false;
|
||||||
|
|
||||||
PlantingCondition plantingCondition = new PlantingCondition(seedLoc, player);
|
|
||||||
|
|
||||||
CCSeason[] seasons = crop.getSeasons();
|
CCSeason[] seasons = crop.getSeasons();
|
||||||
if (SeasonConfig.enable && seasons != null) {
|
if (SeasonConfig.enable && seasons != null) {
|
||||||
if (cropManager.isWrongSeason(seedLoc, seasons)) {
|
if (cropManager.isWrongSeason(seedLoc, seasons)) {
|
||||||
if (MainConfig.notifyInWrongSeason) AdventureUtil.playerMessage(player, MessageConfig.prefix + MessageConfig.wrongSeason);
|
if (MainConfig.notifyInWrongSeason) AdventureUtil.playerMessage(player, MessageConfig.prefix + MessageConfig.wrongSeason.replace("{season}", SeasonUtils.getSeasonText(SeasonUtils.getSeason(seedLoc.getWorld()))));
|
||||||
if (MainConfig.preventInWrongSeason) return;
|
if (MainConfig.preventInWrongSeason) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crop.getRequirements() != null) {
|
if (player != null) {
|
||||||
for (RequirementInterface requirement : crop.getRequirements()) {
|
PlantingCondition plantingCondition = new PlantingCondition(seedLoc, player);
|
||||||
if (!requirement.isConditionMet(plantingCondition)) {
|
if (crop.getRequirements() != null) {
|
||||||
return;
|
for (RequirementInterface requirement : crop.getRequirements()) {
|
||||||
|
if (!requirement.isConditionMet(plantingCondition)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MainConfig.limitation ) {
|
if (MainConfig.limitation) {
|
||||||
if (isWire && LimitationUtil.reachWireLimit(seedLoc)) {
|
if (MainConfig.cropMode && LimitationUtil.reachWireLimit(seedLoc)) {
|
||||||
AdventureUtil.playerMessage(player, MessageConfig.prefix + MessageConfig.limitWire.replace("{max}", String.valueOf(MainConfig.wireAmount)));
|
if (player != null) AdventureUtil.playerMessage(player, MessageConfig.prefix + MessageConfig.limitWire.replace("{max}", String.valueOf(MainConfig.wireAmount)));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (!isWire && LimitationUtil.reachFrameLimit(seedLoc)) {
|
if (!MainConfig.cropMode && LimitationUtil.reachFrameLimit(seedLoc)) {
|
||||||
AdventureUtil.playerMessage(player, MessageConfig.prefix + MessageConfig.limitFrame.replace("{max}", String.valueOf(MainConfig.frameAmount)));
|
if (player != null) AdventureUtil.playerMessage(player, MessageConfig.prefix + MessageConfig.limitFrame.replace("{max}", String.valueOf(MainConfig.frameAmount)));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SeedPlantEvent seedPlantEvent = new SeedPlantEvent(player, seedLoc, crop);
|
SeedPlantEvent seedPlantEvent = new SeedPlantEvent(player, seedLoc, crop);
|
||||||
Bukkit.getPluginManager().callEvent(seedPlantEvent);
|
Bukkit.getPluginManager().callEvent(seedPlantEvent);
|
||||||
if (seedPlantEvent.isCancelled()) {
|
if (seedPlantEvent.isCancelled()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SoundConfig.plantSeed.isEnable()) {
|
if (SoundConfig.plantSeed.isEnable() && player != null) {
|
||||||
AdventureUtil.playerSound(
|
AdventureUtil.playerSound(
|
||||||
player,
|
player,
|
||||||
SoundConfig.plantSeed.getSource(),
|
SoundConfig.plantSeed.getSource(),
|
||||||
@@ -590,13 +592,14 @@ public abstract class HandlerP extends Function {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getGameMode() != GameMode.CREATIVE) itemInHand.setAmount(itemInHand.getAmount() - 1);
|
if (itemInHand != null && player != null && player.getGameMode() != GameMode.CREATIVE) itemInHand.setAmount(itemInHand.getAmount() - 1);
|
||||||
if (isWire) customInterface.placeWire(seedLoc, cropName + "_stage_1");
|
if (MainConfig.cropMode) customInterface.placeWire(seedLoc, cropName + "_stage_1");
|
||||||
else {
|
else {
|
||||||
ItemFrame itemFrame = customInterface.placeFurniture(seedLoc, cropName + "_stage_1");
|
ItemFrame itemFrame = customInterface.placeFurniture(seedLoc, cropName + "_stage_1");
|
||||||
if (itemFrame == null) return;
|
if (itemFrame == null) return false;
|
||||||
itemFrame.setRotation(FurnitureUtil.getRandomRotation());
|
itemFrame.setRotation(FurnitureUtil.getRandomRotation());
|
||||||
}
|
}
|
||||||
customWorld.addCrop(seedLoc, cropName);
|
customWorld.addCrop(seedLoc, cropName);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,13 +188,13 @@ public class ItemsAdderFrameHandler extends ItemsAdderHandler {
|
|||||||
String namespacedID = customStack.getNamespacedID();
|
String namespacedID = customStack.getNamespacedID();
|
||||||
if (namespacedID.endsWith("_seeds")) {
|
if (namespacedID.endsWith("_seeds")) {
|
||||||
String cropName = customStack.getId().substring(0, customStack.getId().length() - 6);
|
String cropName = customStack.getId().substring(0, customStack.getId().length() - 6);
|
||||||
plantSeed(seedLoc, cropName, player, itemInHand, false, false);
|
plantSeed(seedLoc, cropName, player, itemInHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (MainConfig.enableConvert) {
|
else if (MainConfig.enableConvert) {
|
||||||
String cropName = MainConfig.vanilla2Crops.get(itemInHand.getType());
|
String cropName = MainConfig.vanilla2Crops.get(itemInHand.getType());
|
||||||
if (cropName == null) return;
|
if (cropName == null) return;
|
||||||
plantSeed(seedLoc, cropName, player, itemInHand, false, false);
|
plantSeed(seedLoc, cropName, player, itemInHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,13 +163,13 @@ public class ItemsAdderWireHandler extends ItemsAdderHandler {
|
|||||||
String namespacedID = customStack.getNamespacedID();
|
String namespacedID = customStack.getNamespacedID();
|
||||||
if (namespacedID.endsWith("_seeds")) {
|
if (namespacedID.endsWith("_seeds")) {
|
||||||
String cropName = customStack.getId().substring(0, customStack.getId().length() - 6);
|
String cropName = customStack.getId().substring(0, customStack.getId().length() - 6);
|
||||||
plantSeed(seedLoc, cropName, player, itemInHand, false, true);
|
plantSeed(seedLoc, cropName, player, itemInHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (MainConfig.enableConvert) {
|
else if (MainConfig.enableConvert) {
|
||||||
String cropName = MainConfig.vanilla2Crops.get(itemInHand.getType());
|
String cropName = MainConfig.vanilla2Crops.get(itemInHand.getType());
|
||||||
if (cropName == null) return;
|
if (cropName == null) return;
|
||||||
plantSeed(seedLoc, cropName, player, itemInHand, false, true);
|
plantSeed(seedLoc, cropName, player, itemInHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,13 +142,13 @@ public class OraxenFrameHandler extends OraxenHandler {
|
|||||||
if (id != null) {
|
if (id != null) {
|
||||||
if (id.endsWith("_seeds")) {
|
if (id.endsWith("_seeds")) {
|
||||||
String cropName = id.substring(0, id.length() - 6);
|
String cropName = id.substring(0, id.length() - 6);
|
||||||
plantSeed(seedLoc, cropName, player, itemInHand, true, false);
|
plantSeed(seedLoc, cropName, player, itemInHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (MainConfig.enableConvert) {
|
else if (MainConfig.enableConvert) {
|
||||||
String cropName = MainConfig.vanilla2Crops.get(itemInHand.getType());
|
String cropName = MainConfig.vanilla2Crops.get(itemInHand.getType());
|
||||||
if (cropName == null) return;
|
if (cropName == null) return;
|
||||||
plantSeed(seedLoc, cropName, player, itemInHand, true, false);
|
plantSeed(seedLoc, cropName, player, itemInHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,13 +184,13 @@ public class OraxenWireHandler extends OraxenHandler{
|
|||||||
if (id != null) {
|
if (id != null) {
|
||||||
if (id.endsWith("_seeds")) {
|
if (id.endsWith("_seeds")) {
|
||||||
String cropName = id.substring(0, id.length() - 6);
|
String cropName = id.substring(0, id.length() - 6);
|
||||||
plantSeed(seedLoc, cropName, player, itemInHand, true, true);
|
plantSeed(seedLoc, cropName, player, itemInHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (MainConfig.enableConvert) {
|
else if (MainConfig.enableConvert) {
|
||||||
String cropName = MainConfig.vanilla2Crops.get(itemInHand.getType());
|
String cropName = MainConfig.vanilla2Crops.get(itemInHand.getType());
|
||||||
if (cropName == null) return;
|
if (cropName == null) return;
|
||||||
plantSeed(seedLoc, cropName, player, itemInHand, true, true);
|
plantSeed(seedLoc, cropName, player, itemInHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import net.momirealms.customcrops.api.utils.SeasonUtils;
|
|||||||
import net.momirealms.customcrops.config.MainConfig;
|
import net.momirealms.customcrops.config.MainConfig;
|
||||||
import net.momirealms.customcrops.config.MessageConfig;
|
import net.momirealms.customcrops.config.MessageConfig;
|
||||||
import net.momirealms.customcrops.config.SeasonConfig;
|
import net.momirealms.customcrops.config.SeasonConfig;
|
||||||
import net.momirealms.customcrops.integrations.season.CCSeason;
|
import net.momirealms.customcrops.api.utils.CCSeason;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -97,12 +97,6 @@ public class SeasonPapi extends PlaceholderExpansion {
|
|||||||
|
|
||||||
private String getSeasonText(World world) {
|
private String getSeasonText(World world) {
|
||||||
CCSeason season = SeasonUtils.getSeason(world);
|
CCSeason season = SeasonUtils.getSeason(world);
|
||||||
return switch (season) {
|
return SeasonUtils.getSeasonText(season);
|
||||||
case SPRING -> MessageConfig.spring;
|
|
||||||
case SUMMER -> MessageConfig.summer;
|
|
||||||
case AUTUMN -> MessageConfig.autumn;
|
|
||||||
case WINTER -> MessageConfig.winter;
|
|
||||||
default -> throw new IllegalStateException("Unexpected value: " + season);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package net.momirealms.customcrops.integrations.season;
|
package net.momirealms.customcrops.integrations.season;
|
||||||
|
|
||||||
import net.momirealms.customcrops.CustomCrops;
|
import net.momirealms.customcrops.CustomCrops;
|
||||||
|
import net.momirealms.customcrops.api.utils.CCSeason;
|
||||||
import net.momirealms.customcrops.config.MainConfig;
|
import net.momirealms.customcrops.config.MainConfig;
|
||||||
import net.momirealms.customcrops.config.SeasonConfig;
|
import net.momirealms.customcrops.config.SeasonConfig;
|
||||||
import net.momirealms.customcrops.objects.Function;
|
import net.momirealms.customcrops.objects.Function;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package net.momirealms.customcrops.integrations.season;
|
package net.momirealms.customcrops.integrations.season;
|
||||||
|
|
||||||
import me.casperge.realisticseasons.api.SeasonsAPI;
|
import me.casperge.realisticseasons.api.SeasonsAPI;
|
||||||
|
import net.momirealms.customcrops.api.utils.CCSeason;
|
||||||
import net.momirealms.customcrops.config.MainConfig;
|
import net.momirealms.customcrops.config.MainConfig;
|
||||||
import net.momirealms.customcrops.objects.Function;
|
import net.momirealms.customcrops.objects.Function;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@@ -28,6 +29,10 @@ public class RealisticSeasonsHook extends Function implements SeasonInterface {
|
|||||||
|
|
||||||
private SeasonsAPI api;
|
private SeasonsAPI api;
|
||||||
|
|
||||||
|
public RealisticSeasonsHook() {
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
super.load();
|
super.load();
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package net.momirealms.customcrops.integrations.season;
|
package net.momirealms.customcrops.integrations.season;
|
||||||
|
|
||||||
|
import net.momirealms.customcrops.api.utils.CCSeason;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
public interface SeasonInterface {
|
public interface SeasonInterface {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import net.momirealms.customcrops.integrations.customplugin.CustomInterface;
|
|||||||
import net.momirealms.customcrops.integrations.customplugin.HandlerP;
|
import net.momirealms.customcrops.integrations.customplugin.HandlerP;
|
||||||
import net.momirealms.customcrops.integrations.customplugin.itemsadder.*;
|
import net.momirealms.customcrops.integrations.customplugin.itemsadder.*;
|
||||||
import net.momirealms.customcrops.integrations.customplugin.oraxen.*;
|
import net.momirealms.customcrops.integrations.customplugin.oraxen.*;
|
||||||
import net.momirealms.customcrops.integrations.season.CCSeason;
|
import net.momirealms.customcrops.api.utils.CCSeason;
|
||||||
import net.momirealms.customcrops.integrations.season.InternalSeason;
|
import net.momirealms.customcrops.integrations.season.InternalSeason;
|
||||||
import net.momirealms.customcrops.integrations.season.RealisticSeasonsHook;
|
import net.momirealms.customcrops.integrations.season.RealisticSeasonsHook;
|
||||||
import net.momirealms.customcrops.integrations.season.SeasonInterface;
|
import net.momirealms.customcrops.integrations.season.SeasonInterface;
|
||||||
@@ -57,7 +57,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public class CropManager extends Function {
|
public class CropManager extends Function {
|
||||||
@@ -465,4 +464,8 @@ public class CropManager extends Function {
|
|||||||
public ArmorStandUtil getArmorStandUtil() {
|
public ArmorStandUtil getArmorStandUtil() {
|
||||||
return armorStandUtil;
|
return armorStandUtil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HandlerP getHandler() {
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ import net.momirealms.customcrops.CustomCrops;
|
|||||||
import net.momirealms.customcrops.api.event.CustomWorldEvent;
|
import net.momirealms.customcrops.api.event.CustomWorldEvent;
|
||||||
import net.momirealms.customcrops.api.utils.SeasonUtils;
|
import net.momirealms.customcrops.api.utils.SeasonUtils;
|
||||||
import net.momirealms.customcrops.config.*;
|
import net.momirealms.customcrops.config.*;
|
||||||
import net.momirealms.customcrops.integrations.season.CCSeason;
|
import net.momirealms.customcrops.api.utils.CCSeason;
|
||||||
import net.momirealms.customcrops.objects.SimpleLocation;
|
import net.momirealms.customcrops.objects.SimpleLocation;
|
||||||
import net.momirealms.customcrops.objects.Sprinkler;
|
import net.momirealms.customcrops.objects.Sprinkler;
|
||||||
import net.momirealms.customcrops.objects.WorldState;
|
import net.momirealms.customcrops.objects.WorldState;
|
||||||
@@ -59,7 +59,6 @@ public class CustomWorld {
|
|||||||
private final BukkitScheduler bukkitScheduler;
|
private final BukkitScheduler bukkitScheduler;
|
||||||
private final HashSet<SimpleLocation> plantedToday;
|
private final HashSet<SimpleLocation> plantedToday;
|
||||||
private final CropModeInterface cropMode;
|
private final CropModeInterface cropMode;
|
||||||
|
|
||||||
private YamlConfiguration cropData;
|
private YamlConfiguration cropData;
|
||||||
|
|
||||||
public CustomWorld(World world, CropManager cropManager) {
|
public CustomWorld(World world, CropManager cropManager) {
|
||||||
@@ -332,6 +331,7 @@ public class CustomWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void growWire(int cropTime, int sprinklerTime, int dryTime, boolean compensation, boolean force) {
|
public void growWire(int cropTime, int sprinklerTime, int dryTime, boolean compensation, boolean force) {
|
||||||
|
if (cropData == null) return;
|
||||||
|
|
||||||
Random randomGenerator = new Random();
|
Random randomGenerator = new Random();
|
||||||
if (force) {
|
if (force) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package net.momirealms.customcrops.objects;
|
package net.momirealms.customcrops.objects;
|
||||||
|
|
||||||
import net.momirealms.customcrops.api.crop.Crop;
|
import net.momirealms.customcrops.api.crop.Crop;
|
||||||
import net.momirealms.customcrops.integrations.season.CCSeason;
|
import net.momirealms.customcrops.api.utils.CCSeason;
|
||||||
import net.momirealms.customcrops.objects.actions.ActionInterface;
|
import net.momirealms.customcrops.objects.actions.ActionInterface;
|
||||||
import net.momirealms.customcrops.objects.requirements.RequirementInterface;
|
import net.momirealms.customcrops.objects.requirements.RequirementInterface;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ messages:
|
|||||||
grow-simulation: '<white>Growing simulation has started'
|
grow-simulation: '<white>Growing simulation has started'
|
||||||
set-season: '<white>Successfully set {world}''s season to {season}!'
|
set-season: '<white>Successfully set {world}''s season to {season}!'
|
||||||
before-plant: '<white>This fertilizer must be used before planting!'
|
before-plant: '<white>This fertilizer must be used before planting!'
|
||||||
wrong-season: '<white>Current season is not suitable for planting this seed'
|
wrong-season: '<white>Current season is not suitable for planting this seed. Suitable season: {season}'
|
||||||
|
|
||||||
no-season: 'No season'
|
no-season: 'No season'
|
||||||
season-disabled: 'Season is disabled'
|
season-disabled: 'Season is disabled'
|
||||||
|
|||||||
Reference in New Issue
Block a user