9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-27 19:09:09 +00:00

improve compatibility with CraftEngine

This commit is contained in:
XiaoMoMi
2025-03-30 04:51:09 +08:00
parent c8bf4a88ab
commit 9db4cdee13
8 changed files with 26 additions and 9 deletions

View File

@@ -21,8 +21,10 @@ import dev.dejvokep.boostedyaml.block.implementation.Section;
import net.momirealms.customcrops.api.BukkitCustomCropsPlugin;
import net.momirealms.customcrops.api.context.Context;
import net.momirealms.customcrops.api.context.ContextKeys;
import net.momirealms.customcrops.api.core.ConfigManager;
import net.momirealms.customcrops.api.misc.value.MathValue;
import net.momirealms.customcrops.api.util.LocationUtils;
import net.momirealms.customcrops.api.util.PluginUtils;
import net.momirealms.customcrops.common.helper.VersionHelper;
import net.momirealms.sparrow.heart.SparrowHeart;
import net.momirealms.sparrow.heart.feature.entity.FakeEntity;
@@ -58,7 +60,7 @@ public class ActionFakeItem<T> extends AbstractBuiltInAction<T> {
super(plugin, chance);
String itemID = section.getString("item", "");
String[] split = itemID.split(":");
if (split.length >= 2) itemID = split[split.length - 1];
if (split.length >= 2 && !ConfigManager.hasNamespace()) itemID = split[split.length - 1];
this.itemID = itemID;
this.duration = MathValue.auto(section.get("duration", 20));
this.other = section.getString("position", "other").equals("other");

View File

@@ -57,7 +57,6 @@ import org.bukkit.inventory.ItemStack;
import java.util.*;
public abstract class AbstractCustomEventListener implements Listener {
private final HashSet<EntityType> entities = new HashSet<>();
private final HashSet<Material> blocks = new HashSet<>();

View File

@@ -485,8 +485,12 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
return conditions.toArray(new GrowCondition[0]);
}
public static boolean hasNamespace() {
return PluginUtils.isEnabled("ItemsAdder") || PluginUtils.isEnabled("CraftEngine");
}
protected void addDefaultNamespace(File file) {
boolean hasNamespace = PluginUtils.isEnabled("ItemsAdder") || PluginUtils.isEnabled("CraftEngine");
boolean hasNamespace = hasNamespace();
String line;
StringBuilder sb = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {