9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-27 19:09:09 +00:00
This commit is contained in:
XiaoMoMi
2023-09-25 22:16:44 +08:00
parent 69cdadd704
commit 7854066a49
10 changed files with 63 additions and 21 deletions

View File

@@ -22,9 +22,11 @@ import com.comphenix.protocol.ProtocolManager;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.momirealms.customcrops.api.CustomCropsAPIImpl;
import net.momirealms.customcrops.api.CustomCropsPlugin;
import net.momirealms.customcrops.api.event.CropBreakEvent;
import net.momirealms.customcrops.api.object.basic.ConfigManager;
import net.momirealms.customcrops.api.object.basic.MessageManager;
import net.momirealms.customcrops.api.object.crop.CropManager;
import net.momirealms.customcrops.api.object.crop.GrowingCrop;
import net.momirealms.customcrops.api.object.fertilizer.FertilizerManager;
import net.momirealms.customcrops.api.object.hologram.HologramManager;
import net.momirealms.customcrops.api.object.pot.PotManager;
@@ -32,6 +34,7 @@ import net.momirealms.customcrops.api.object.scheduler.Scheduler;
import net.momirealms.customcrops.api.object.season.SeasonManager;
import net.momirealms.customcrops.api.object.sprinkler.SprinklerManager;
import net.momirealms.customcrops.api.object.wateringcan.WateringCanManager;
import net.momirealms.customcrops.api.object.world.SimpleLocation;
import net.momirealms.customcrops.api.object.world.WorldDataManager;
import net.momirealms.customcrops.command.CustomCropsCommand;
import net.momirealms.customcrops.customplugin.Platform;

View File

@@ -0,0 +1,44 @@
/*
* 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.requirement;
import net.momirealms.biomeapi.BiomeAPI;
import net.momirealms.customcrops.api.object.action.Action;
import org.jetbrains.annotations.Nullable;
import java.util.HashSet;
public class BlackBiomeImpl extends AbstractRequirement implements Requirement {
private final HashSet<String> biomes;
public BlackBiomeImpl(@Nullable String[] msg, @Nullable Action[] actions, HashSet<String> biomes) {
super(msg, actions);
this.biomes = biomes;
}
@Override
public boolean isConditionMet(CurrentState currentState) {
String currentBiome = BiomeAPI.getBiome(currentState.getLocation());
if (!biomes.contains(currentBiome)) {
return true;
}
notMetActions(currentState);
return false;
}
}

View File

@@ -19,19 +19,20 @@ package net.momirealms.customcrops.integration.quest;
import io.github.battlepass.BattlePlugin;
import io.github.battlepass.api.events.server.PluginReloadEvent;
import io.github.battlepass.quests.service.base.ExternalQuestContainer;
import io.github.battlepass.registry.quest.QuestRegistry;
import net.advancedplugins.bp.impl.actions.ActionRegistry;
import net.advancedplugins.bp.impl.actions.external.executor.ActionQuestExecutor;
import net.momirealms.customcrops.api.event.CropBreakEvent;
import net.momirealms.customcrops.api.event.CropPlantEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public class BattlePassCCQuest implements Listener {
public static void register() {
QuestRegistry questRegistry = BattlePlugin.getApi().getQuestRegistry();
questRegistry.hook("customcrops", CropQuest::new);
ActionRegistry actionRegistry = BattlePlugin.getPlugin().getActionRegistry();
actionRegistry.hook("customcrops", CropQuest::new);
}
@EventHandler(ignoreCancelled = true)
@@ -39,9 +40,9 @@ public class BattlePassCCQuest implements Listener {
register();
}
private static class CropQuest extends ExternalQuestContainer {
private static class CropQuest extends ActionQuestExecutor {
public CropQuest(BattlePlugin battlePlugin) {
public CropQuest(JavaPlugin battlePlugin) {
super(battlePlugin, "customcrops");
}

View File

@@ -208,6 +208,7 @@ public class ConfigUtils {
ConfigurationSection actionSec = innerSec.getConfigurationSection("actions");
switch (type) {
case "biome" -> requirements.add(new BiomeImpl(msg, getActions(actionSec), new HashSet<>(innerSec.getStringList("value"))));
case "!biome" -> requirements.add(new BlackBiomeImpl(msg, getActions(actionSec), new HashSet<>(innerSec.getStringList("value"))));
case "weather" -> requirements.add(new WeatherImpl(msg, getActions(actionSec), innerSec.getStringList("value").toArray(new String[0])));
case "ypos" -> requirements.add(new YPosImpl(msg, getActions(actionSec), innerSec.getStringList("value")));
case "season" -> {