mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-24 01:19:28 +00:00
3.2.4.0
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'net.momirealms'
|
||||
version = '3.2.3.3'
|
||||
version = '3.2.4.0'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -30,7 +30,7 @@ dependencies {
|
||||
compileOnly ('dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT')
|
||||
compileOnly ('io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT')
|
||||
compileOnly ('me.clip:placeholderapi:2.11.3')
|
||||
compileOnly ('com.github.LoneDev6:api-itemsadder:3.4.1-r4')
|
||||
compileOnly ('com.github.LoneDev6:api-itemsadder:3.4.1e')
|
||||
compileOnly ('io.lumine:Mythic-Dist:5.0.3-SNAPSHOT')
|
||||
//compileOnly ('com.willfp:EcoSkills:3.0.0-b2') No read access
|
||||
compileOnly ('com.willfp:eco:6.60.0')
|
||||
|
||||
Binary file not shown.
@@ -804,6 +804,15 @@ public class PlatformManager extends Function {
|
||||
FertilizerConfig fertilizerConfig = plugin.getFertilizerManager().getConfigByItemID(item_in_hand_id);
|
||||
if (fertilizerConfig != null) {
|
||||
|
||||
if (fertilizerConfig.getRequirements() != null) {
|
||||
CurrentState currentState = new CurrentState(location, player);
|
||||
for (Requirement requirement : fertilizerConfig.getRequirements()) {
|
||||
if (!requirement.isConditionMet(currentState)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FertilizerUseEvent fertilizerUseEvent = new FertilizerUseEvent(player, item_in_hand, fertilizerConfig, location);
|
||||
Bukkit.getPluginManager().callEvent(fertilizerUseEvent);
|
||||
if (fertilizerUseEvent.isCancelled()) {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package net.momirealms.customcrops.api.object.fertilizer;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customcrops.api.object.requirement.Requirement;
|
||||
import org.bukkit.Particle;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -32,8 +33,9 @@ public abstract class FertilizerConfig {
|
||||
private final Particle particle;
|
||||
private final Sound sound;
|
||||
private final String icon;
|
||||
private final Requirement[] requirements;
|
||||
|
||||
public FertilizerConfig(String key, FertilizerType fertilizerType, int times, double chance, @Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound, @Nullable String icon) {
|
||||
public FertilizerConfig(String key, FertilizerType fertilizerType, int times, double chance, @Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound, @Nullable String icon, Requirement[] requirements) {
|
||||
this.times = times;
|
||||
this.chance = chance;
|
||||
this.key = key;
|
||||
@@ -43,6 +45,7 @@ public abstract class FertilizerConfig {
|
||||
this.particle = particle;
|
||||
this.sound = sound;
|
||||
this.icon = icon;
|
||||
this.requirements = requirements;
|
||||
}
|
||||
|
||||
public int getTimes() {
|
||||
@@ -87,4 +90,8 @@ public abstract class FertilizerConfig {
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public Requirement[] getRequirements() {
|
||||
return requirements;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.Function;
|
||||
import net.momirealms.customcrops.api.object.Pair;
|
||||
import net.momirealms.customcrops.api.object.requirement.Requirement;
|
||||
import net.momirealms.customcrops.api.util.AdventureUtils;
|
||||
import net.momirealms.customcrops.api.util.ConfigUtils;
|
||||
import org.bukkit.Particle;
|
||||
@@ -102,12 +103,13 @@ public class FertilizerManager extends Function {
|
||||
@Subst("namespace:key") String soundKey = fertilizerSec.getString("sound", "minecraft:item.hoe.till");
|
||||
Sound sound = fertilizerSec.contains("sound") ? Sound.sound(Key.key(soundKey), Sound.Source.PLAYER, 1, 1) : null;
|
||||
String icon = fertilizerSec.getString("icon");
|
||||
Requirement[] requirements = ConfigUtils.getRequirementsWithMsg(fertilizerSec.getConfigurationSection("requirements"));
|
||||
switch (fertilizerType) {
|
||||
case SPEED_GROW -> fertilizerConfig = new SpeedGrow(key, fertilizerType, times, getChancePair(fertilizerSec), pot_whitelist, beforePlant, particle, sound, icon);
|
||||
case YIELD_INCREASE -> fertilizerConfig = new YieldIncrease(key, fertilizerType, times, fertilizerSec.getDouble("chance"), getChancePair(fertilizerSec), pot_whitelist, beforePlant, particle, sound, icon);
|
||||
case VARIATION -> fertilizerConfig = new Variation(key, fertilizerType, times, fertilizerSec.getDouble("chance"), pot_whitelist, beforePlant, particle, sound, icon);
|
||||
case QUALITY -> fertilizerConfig = new Quality(key, fertilizerType, times, fertilizerSec.getDouble("chance"), ConfigUtils.getQualityRatio(fertilizerSec.getString("ratio", "2/2/1")), pot_whitelist, beforePlant, particle, sound, icon);
|
||||
case SOIL_RETAIN -> fertilizerConfig = new SoilRetain(key, fertilizerType, times, fertilizerSec.getDouble("chance"), pot_whitelist, beforePlant, particle, sound, icon);
|
||||
case SPEED_GROW -> fertilizerConfig = new SpeedGrow(key, fertilizerType, times, getChancePair(fertilizerSec), pot_whitelist, beforePlant, particle, sound, icon, requirements);
|
||||
case YIELD_INCREASE -> fertilizerConfig = new YieldIncrease(key, fertilizerType, times, fertilizerSec.getDouble("chance"), getChancePair(fertilizerSec), pot_whitelist, beforePlant, particle, sound, icon, requirements);
|
||||
case VARIATION -> fertilizerConfig = new Variation(key, fertilizerType, times, fertilizerSec.getDouble("chance"), pot_whitelist, beforePlant, particle, sound, icon, requirements);
|
||||
case QUALITY -> fertilizerConfig = new Quality(key, fertilizerType, times, fertilizerSec.getDouble("chance"), ConfigUtils.getQualityRatio(fertilizerSec.getString("ratio", "2/2/1")), pot_whitelist, beforePlant, particle, sound, icon, requirements);
|
||||
case SOIL_RETAIN -> fertilizerConfig = new SoilRetain(key, fertilizerType, times, fertilizerSec.getDouble("chance"), pot_whitelist, beforePlant, particle, sound, icon, requirements);
|
||||
default -> fertilizerConfig = null;
|
||||
}
|
||||
String item = fertilizerSec.getString("item");
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package net.momirealms.customcrops.api.object.fertilizer;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customcrops.api.object.requirement.Requirement;
|
||||
import org.bukkit.Particle;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -26,8 +27,8 @@ public class Quality extends FertilizerConfig {
|
||||
private final double[] ratio;
|
||||
|
||||
public Quality(String key, FertilizerType fertilizerType, int times, double chance, double[] ratio,
|
||||
@Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound, @Nullable String icon) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound, icon);
|
||||
@Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound, @Nullable String icon, Requirement[] requirements) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound, icon, requirements);
|
||||
this.ratio = ratio;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,14 @@
|
||||
package net.momirealms.customcrops.api.object.fertilizer;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customcrops.api.object.requirement.Requirement;
|
||||
import org.bukkit.Particle;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SoilRetain extends FertilizerConfig {
|
||||
|
||||
public SoilRetain(String key, FertilizerType fertilizerType, int times, double chance,
|
||||
@Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound, String icon) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound, icon);
|
||||
@Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound, String icon, Requirement[] requirements) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound, icon, requirements);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package net.momirealms.customcrops.api.object.fertilizer;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customcrops.api.object.Pair;
|
||||
import net.momirealms.customcrops.api.object.requirement.Requirement;
|
||||
import org.bukkit.Particle;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -29,8 +30,8 @@ public class SpeedGrow extends FertilizerConfig {
|
||||
private final List<Pair<Double, Integer>> pairs;
|
||||
|
||||
public SpeedGrow(String key, FertilizerType fertilizerType, int times, List<Pair<Double, Integer>> pairs,
|
||||
@Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound, String icon) {
|
||||
super(key, fertilizerType, times, 1, pot_whitelist, beforePlant, particle, sound, icon);
|
||||
@Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound, String icon, Requirement[] requirements) {
|
||||
super(key, fertilizerType, times, 1, pot_whitelist, beforePlant, particle, sound, icon, requirements);
|
||||
this.pairs = pairs;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package net.momirealms.customcrops.api.object.fertilizer;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customcrops.api.object.requirement.Requirement;
|
||||
import org.bukkit.Particle;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -25,7 +26,7 @@ public class Variation extends FertilizerConfig {
|
||||
|
||||
public Variation(String key, FertilizerType fertilizerType, int times, double chance,
|
||||
@Nullable String[] pot_whitelist, boolean beforePlant,
|
||||
@Nullable Particle particle, @Nullable Sound sound, String icon) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound, icon);
|
||||
@Nullable Particle particle, @Nullable Sound sound, String icon, Requirement[] requirements) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound, icon, requirements);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package net.momirealms.customcrops.api.object.fertilizer;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customcrops.api.object.Pair;
|
||||
import net.momirealms.customcrops.api.object.requirement.Requirement;
|
||||
import org.bukkit.Particle;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -30,8 +31,8 @@ public class YieldIncrease extends FertilizerConfig {
|
||||
|
||||
public YieldIncrease(String key, FertilizerType fertilizerType, int times, double chance,
|
||||
List<Pair<Double, Integer>> pairs, @Nullable String[] pot_whitelist, boolean beforePlant,
|
||||
@Nullable Particle particle, @Nullable Sound sound, String icon) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound, icon);
|
||||
@Nullable Particle particle, @Nullable Sound sound, String icon, Requirement[] requirements) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound, icon, requirements);
|
||||
this.pairs = pairs;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
package net.momirealms.customcrops.api.object.requirement;
|
||||
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
import net.momirealms.customcrops.api.util.AdventureUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -24,16 +26,24 @@ import org.jetbrains.annotations.Nullable;
|
||||
public abstract class AbstractRequirement {
|
||||
|
||||
protected String[] msg;
|
||||
protected Action[] actions;
|
||||
|
||||
protected AbstractRequirement(@Nullable String[] msg) {
|
||||
protected AbstractRequirement(@Nullable String[] msg, @Nullable Action[] actions) {
|
||||
this.msg = msg;
|
||||
this.actions = actions;
|
||||
}
|
||||
|
||||
public void notMetMessage(Player player) {
|
||||
public void notMetMessage(CurrentState currentState) {
|
||||
Player player = currentState.getPlayer();
|
||||
if (msg != null && player != null) {
|
||||
for (String str : msg) {
|
||||
AdventureUtils.playerMessage(player, str);
|
||||
}
|
||||
}
|
||||
if (actions != null) {
|
||||
for (Action action : actions) {
|
||||
action.doOn(player, SimpleLocation.getByBukkitLocation(currentState.getLocation()), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
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;
|
||||
@@ -26,8 +27,8 @@ public class BiomeImpl extends AbstractRequirement implements Requirement {
|
||||
|
||||
private final HashSet<String> biomes;
|
||||
|
||||
public BiomeImpl(@Nullable String[] msg, HashSet<String> biomes) {
|
||||
super(msg);
|
||||
public BiomeImpl(@Nullable String[] msg, @Nullable Action[] actions, HashSet<String> biomes) {
|
||||
super(msg, actions);
|
||||
this.biomes = biomes;
|
||||
}
|
||||
|
||||
@@ -37,7 +38,7 @@ public class BiomeImpl extends AbstractRequirement implements Requirement {
|
||||
if (biomes.contains(currentBiome)) {
|
||||
return true;
|
||||
}
|
||||
notMetMessage(currentState.getPlayer());
|
||||
notMetMessage(currentState);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ public class CurrentState {
|
||||
private final Location location;
|
||||
private final Player player;
|
||||
|
||||
public CurrentState(Location crop_loc, Player player) {
|
||||
this.location = crop_loc;
|
||||
public CurrentState(Location location, Player player) {
|
||||
this.location = location;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
|
||||
package net.momirealms.customcrops.api.object.requirement;
|
||||
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import net.momirealms.customcrops.api.object.requirement.papi.*;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -29,8 +31,8 @@ public class CustomPapi extends AbstractRequirement implements Requirement {
|
||||
|
||||
private final List<PapiRequirement> papiRequirement;
|
||||
|
||||
public CustomPapi(String[] msg, Map<String, Object> expressions){
|
||||
super(msg);
|
||||
public CustomPapi(String[] msg, @Nullable Action[] actions, Map<String, Object> expressions){
|
||||
super(msg, actions);
|
||||
papiRequirement = getRequirements(expressions);
|
||||
}
|
||||
|
||||
@@ -40,7 +42,7 @@ public class CustomPapi extends AbstractRequirement implements Requirement {
|
||||
if (currentState.getPlayer() == null) return true;
|
||||
for (PapiRequirement requirement : papiRequirement) {
|
||||
if (!requirement.isMet(player)) {
|
||||
notMetMessage(player);
|
||||
notMetMessage(currentState);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
|
||||
package net.momirealms.customcrops.api.object.requirement;
|
||||
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -24,8 +27,8 @@ public class DateImpl extends AbstractRequirement implements Requirement {
|
||||
|
||||
private final HashSet<String> dates;
|
||||
|
||||
public DateImpl(String[] msg, HashSet<String> dates) {
|
||||
super(msg);
|
||||
public DateImpl(String[] msg, @Nullable Action[] actions, HashSet<String> dates) {
|
||||
super(msg, actions);
|
||||
this.dates = dates;
|
||||
}
|
||||
|
||||
@@ -36,7 +39,7 @@ public class DateImpl extends AbstractRequirement implements Requirement {
|
||||
if (dates.contains(current)) {
|
||||
return true;
|
||||
}
|
||||
notMetMessage(currentState.getPlayer());
|
||||
notMetMessage(currentState);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package net.momirealms.customcrops.api.object.requirement;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import net.momirealms.customcrops.integration.JobInterface;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -26,8 +27,8 @@ public class JobLevelImpl extends AbstractRequirement implements Requirement {
|
||||
private final int level;
|
||||
private final String jobName;
|
||||
|
||||
public JobLevelImpl(@Nullable String[] msg, int level, String jobName) {
|
||||
super(msg);
|
||||
public JobLevelImpl(@Nullable String[] msg, @Nullable Action[] actions, int level, String jobName) {
|
||||
super(msg, actions);
|
||||
this.level = level;
|
||||
this.jobName = jobName;
|
||||
}
|
||||
@@ -39,7 +40,7 @@ public class JobLevelImpl extends AbstractRequirement implements Requirement {
|
||||
if (jobInterface.getLevel(currentState.getPlayer(), jobName) >= level) {
|
||||
return true;
|
||||
}
|
||||
notMetMessage(currentState.getPlayer());
|
||||
notMetMessage(currentState);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,15 @@
|
||||
|
||||
package net.momirealms.customcrops.api.object.requirement;
|
||||
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PermissionImpl extends AbstractRequirement implements Requirement {
|
||||
|
||||
private final String permission;
|
||||
|
||||
public PermissionImpl(@Nullable String[] msg, String permission) {
|
||||
super(msg);
|
||||
public PermissionImpl(@Nullable String[] msg, @Nullable Action[] actions, String permission) {
|
||||
super(msg, actions);
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@@ -37,7 +38,7 @@ public class PermissionImpl extends AbstractRequirement implements Requirement {
|
||||
if (currentState.getPlayer() == null || currentState.getPlayer().hasPermission(permission)) {
|
||||
return true;
|
||||
}
|
||||
notMetMessage(currentState.getPlayer());
|
||||
notMetMessage(currentState);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
package net.momirealms.customcrops.api.object.requirement;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import net.momirealms.customcrops.api.object.season.CCSeason;
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
@@ -31,8 +32,8 @@ public class SeasonImpl extends AbstractRequirement implements Requirement {
|
||||
|
||||
private final List<CCSeason> seasons;
|
||||
|
||||
public SeasonImpl(@Nullable String[] msg, List<CCSeason> seasons) {
|
||||
super(msg);
|
||||
public SeasonImpl(@Nullable String[] msg, @Nullable Action[] actions, List<CCSeason> seasons) {
|
||||
super(msg, actions);
|
||||
this.seasons = seasons;
|
||||
}
|
||||
|
||||
@@ -53,7 +54,7 @@ public class SeasonImpl extends AbstractRequirement implements Requirement {
|
||||
}
|
||||
}
|
||||
}
|
||||
notMetMessage(currentState.getPlayer());
|
||||
notMetMessage(currentState);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
package net.momirealms.customcrops.api.object.requirement;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import net.momirealms.customcrops.integration.SkillInterface;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -25,8 +26,8 @@ public class SkillLevelImpl extends AbstractRequirement implements Requirement {
|
||||
|
||||
private final int level;
|
||||
|
||||
public SkillLevelImpl(@Nullable String[] msg, int level) {
|
||||
super(msg);
|
||||
public SkillLevelImpl(@Nullable String[] msg, @Nullable Action[] actions, int level) {
|
||||
super(msg, actions);
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@@ -37,7 +38,7 @@ public class SkillLevelImpl extends AbstractRequirement implements Requirement {
|
||||
if (skillInterface.getLevel(currentState.getPlayer()) >= level) {
|
||||
return true;
|
||||
}
|
||||
notMetMessage(currentState.getPlayer());
|
||||
notMetMessage(currentState);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package net.momirealms.customcrops.api.object.requirement;
|
||||
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
@@ -25,8 +26,8 @@ public class TimeImpl extends AbstractRequirement implements Requirement {
|
||||
|
||||
private final List<String> times;
|
||||
|
||||
public TimeImpl(@Nullable String[] msg, List<String> times) {
|
||||
super(msg);
|
||||
public TimeImpl(@Nullable String[] msg, @Nullable Action[] actions, List<String> times) {
|
||||
super(msg, actions);
|
||||
this.times = times;
|
||||
}
|
||||
|
||||
@@ -39,7 +40,7 @@ public class TimeImpl extends AbstractRequirement implements Requirement {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
notMetMessage(currentState.getPlayer());
|
||||
notMetMessage(currentState);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package net.momirealms.customcrops.api.object.requirement;
|
||||
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -24,8 +25,8 @@ public class WeatherImpl extends AbstractRequirement implements Requirement {
|
||||
|
||||
private final String[] weathers;
|
||||
|
||||
public WeatherImpl(@Nullable String[] msg, String[] weathers) {
|
||||
super(msg);
|
||||
public WeatherImpl(@Nullable String[] msg, @Nullable Action[] actions, String[] weathers) {
|
||||
super(msg, actions);
|
||||
this.weathers = weathers;
|
||||
}
|
||||
|
||||
@@ -41,7 +42,7 @@ public class WeatherImpl extends AbstractRequirement implements Requirement {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
notMetMessage(currentState.getPlayer());
|
||||
notMetMessage(currentState);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package net.momirealms.customcrops.api.object.requirement;
|
||||
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -26,8 +27,8 @@ public class WorldImpl extends AbstractRequirement implements Requirement {
|
||||
|
||||
private final List<String> worlds;
|
||||
|
||||
public WorldImpl(@Nullable String[] msg, List<String> worlds) {
|
||||
super(msg);
|
||||
public WorldImpl(@Nullable String[] msg, @Nullable Action[] actions, List<String> worlds) {
|
||||
super(msg, actions);
|
||||
this.worlds = worlds;
|
||||
}
|
||||
|
||||
@@ -37,7 +38,7 @@ public class WorldImpl extends AbstractRequirement implements Requirement {
|
||||
if (worlds.contains(world.getName())) {
|
||||
return true;
|
||||
}
|
||||
notMetMessage(currentState.getPlayer());
|
||||
notMetMessage(currentState);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package net.momirealms.customcrops.api.object.requirement;
|
||||
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
@@ -25,8 +26,8 @@ public class YPosImpl extends AbstractRequirement implements Requirement {
|
||||
|
||||
private final List<String> yPos;
|
||||
|
||||
public YPosImpl(@Nullable String[] msg, List<String> yPos) {
|
||||
super(msg);
|
||||
public YPosImpl(@Nullable String[] msg, @Nullable Action[] actions, List<String> yPos) {
|
||||
super(msg, actions);
|
||||
this.yPos = yPos;
|
||||
}
|
||||
|
||||
@@ -39,7 +40,7 @@ public class YPosImpl extends AbstractRequirement implements Requirement {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
notMetMessage(currentState.getPlayer());
|
||||
notMetMessage(currentState);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ import org.bukkit.configuration.MemorySection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.checkerframework.checker.units.qual.N;
|
||||
import org.intellij.lang.annotations.Subst;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -205,21 +206,22 @@ public class ConfigUtils {
|
||||
String type = innerSec.getString("type");
|
||||
if (type == null) continue;
|
||||
String[] msg = innerSec.getStringList("message").size() == 0 ? (innerSec.getString("message") == null ? null : new String[]{innerSec.getString("message")}) : innerSec.getStringList("message").toArray(new String[0]);
|
||||
ConfigurationSection actionSec = innerSec.getConfigurationSection("actions");
|
||||
switch (type) {
|
||||
case "biome" -> requirements.add(new BiomeImpl(msg, new HashSet<>(innerSec.getStringList("value"))));
|
||||
case "weather" -> requirements.add(new WeatherImpl(msg, innerSec.getStringList("value").toArray(new String[0])));
|
||||
case "ypos" -> requirements.add(new YPosImpl(msg, innerSec.getStringList("value")));
|
||||
case "biome" -> requirements.add(new BiomeImpl(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" -> {
|
||||
if (!ConfigManager.enableSeason) continue;
|
||||
requirements.add(new SeasonImpl(msg, innerSec.getStringList("value").stream().map(str -> CCSeason.valueOf(str.toUpperCase(Locale.ENGLISH))).collect(Collectors.toList())));
|
||||
requirements.add(new SeasonImpl(msg, getActions(actionSec), innerSec.getStringList("value").stream().map(str -> CCSeason.valueOf(str.toUpperCase(Locale.ENGLISH))).collect(Collectors.toList())));
|
||||
}
|
||||
case "world" -> requirements.add(new WorldImpl(msg, innerSec.getStringList("value")));
|
||||
case "permission" -> requirements.add(new PermissionImpl(msg, innerSec.getString("value")));
|
||||
case "time" -> requirements.add(new TimeImpl(msg, innerSec.getStringList("value")));
|
||||
case "skill-level" -> requirements.add(new SkillLevelImpl(msg, innerSec.getInt("value")));
|
||||
case "job-level" -> requirements.add(new JobLevelImpl(msg, innerSec.getInt("value.level"), innerSec.getString("value.job")));
|
||||
case "date" -> requirements.add(new DateImpl(msg, new HashSet<>(innerSec.getStringList("value"))));
|
||||
case "papi-condition" -> requirements.add(new CustomPapi(msg, Objects.requireNonNull(innerSec.getConfigurationSection("value")).getValues(false)));
|
||||
case "world" -> requirements.add(new WorldImpl(msg, getActions(actionSec), innerSec.getStringList("value")));
|
||||
case "permission" -> requirements.add(new PermissionImpl(msg, getActions(actionSec), innerSec.getString("value")));
|
||||
case "time" -> requirements.add(new TimeImpl(msg, getActions(actionSec), innerSec.getStringList("value")));
|
||||
case "skill-level" -> requirements.add(new SkillLevelImpl(msg, getActions(actionSec), innerSec.getInt("value")));
|
||||
case "job-level" -> requirements.add(new JobLevelImpl(msg, getActions(actionSec), innerSec.getInt("value.level"), innerSec.getString("value.job")));
|
||||
case "date" -> requirements.add(new DateImpl(msg, getActions(actionSec), new HashSet<>(innerSec.getStringList("value"))));
|
||||
case "papi-condition" -> requirements.add(new CustomPapi(msg, getActions(actionSec), Objects.requireNonNull(innerSec.getConfigurationSection("value")).getValues(false)));
|
||||
}
|
||||
}
|
||||
return requirements.toArray(new Requirement[0]);
|
||||
@@ -227,6 +229,11 @@ public class ConfigUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Action[] getActions(ConfigurationSection section) {
|
||||
return getActions(section, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Action[] getActions(ConfigurationSection section, String model_id) {
|
||||
if (section != null) {
|
||||
|
||||
Reference in New Issue
Block a user