diff --git a/api/src/main/java/net/momirealms/customcrops/api/core/AbstractCustomEventListener.java b/api/src/main/java/net/momirealms/customcrops/api/core/AbstractCustomEventListener.java index bacc68a..75d7c9a 100644 --- a/api/src/main/java/net/momirealms/customcrops/api/core/AbstractCustomEventListener.java +++ b/api/src/main/java/net/momirealms/customcrops/api/core/AbstractCustomEventListener.java @@ -114,7 +114,11 @@ public abstract class AbstractCustomEventListener implements Listener { return; } ItemStack itemStack = event.getItem(); - if (itemStack != null && itemStack.getType() == Material.BONE_MEAL && ConfigManager.overriddenCrops().contains(type)) { + // Paper API + // prevents player from using bone meals + if (itemStack != null && itemStack.getType() == Material.BONE_MEAL + && ConfigManager.overriddenCrops().contains(type) + && ConfigManager.VANILLA_CROPS.contains(type)) { event.setUseItemInHand(Event.Result.DENY); } this.itemManager.handlePlayerInteractBlock( diff --git a/api/src/main/java/net/momirealms/customcrops/api/core/ConfigManager.java b/api/src/main/java/net/momirealms/customcrops/api/core/ConfigManager.java index 4ca0f78..eaa480c 100644 --- a/api/src/main/java/net/momirealms/customcrops/api/core/ConfigManager.java +++ b/api/src/main/java/net/momirealms/customcrops/api/core/ConfigManager.java @@ -26,6 +26,7 @@ import net.momirealms.customcrops.api.misc.water.FillMethod; import net.momirealms.customcrops.api.misc.water.WateringMethod; import net.momirealms.customcrops.api.util.PluginUtils; import net.momirealms.customcrops.common.config.ConfigLoader; +import net.momirealms.customcrops.common.helper.VersionHelper; import net.momirealms.customcrops.common.plugin.feature.Reloadable; import net.momirealms.customcrops.common.util.Pair; import org.bukkit.Material; @@ -39,6 +40,23 @@ import java.util.*; public abstract class ConfigManager implements ConfigLoader, Reloadable { + public static final Set VANILLA_CROPS; + + static { + HashSet set = new HashSet<>( + List.of(Material.WHEAT, Material.CARROTS, Material.POTATOES, Material.BEETROOTS, Material.SWEET_BERRY_BUSH, + Material.MELON_STEM, Material.PUMPKIN_STEM) + ); + if (VersionHelper.isVersionNewerThan1_19_4()) { + set.add(Material.TORCHFLOWER_CROP); + } + if (VersionHelper.isVersionNewerThan1_20()) { + set.add(Material.PITCHER_CROP); + } + VANILLA_CROPS = Collections.unmodifiableSet(set); + } + + private static ConfigManager instance; protected final BukkitCustomCropsPlugin plugin; diff --git a/plugin/src/main/java/net/momirealms/customcrops/bukkit/config/BukkitConfigManager.java b/plugin/src/main/java/net/momirealms/customcrops/bukkit/config/BukkitConfigManager.java index d499eca..d666c7a 100644 --- a/plugin/src/main/java/net/momirealms/customcrops/bukkit/config/BukkitConfigManager.java +++ b/plugin/src/main/java/net/momirealms/customcrops/bukkit/config/BukkitConfigManager.java @@ -38,7 +38,6 @@ import net.momirealms.customcrops.api.core.mechanic.pot.PotConfig; import net.momirealms.customcrops.api.core.mechanic.sprinkler.SprinklerConfig; import net.momirealms.customcrops.api.core.mechanic.wateringcan.WateringCanConfig; import net.momirealms.customcrops.common.helper.AdventureHelper; -import net.momirealms.customcrops.common.helper.VersionHelper; import net.momirealms.customcrops.common.locale.TranslationManager; import net.momirealms.customcrops.common.plugin.CustomCropsProperties; import net.momirealms.customcrops.common.util.ListUtils; @@ -52,10 +51,6 @@ import java.util.*; public class BukkitConfigManager extends ConfigManager { - private static final Set VANILLA_CROPS = new HashSet<>( - List.of(Material.WHEAT, Material.CARROTS, Material.POTATOES, Material.BEETROOTS, Material.SWEET_BERRY_BUSH, - Material.MELON_STEM, Material.PUMPKIN_STEM) - ); private static YamlDocument MAIN_CONFIG; public static YamlDocument getMainConfig() { return MAIN_CONFIG; @@ -63,12 +58,6 @@ public class BukkitConfigManager extends ConfigManager { public BukkitConfigManager(BukkitCustomCropsPlugin plugin) { super(plugin); - if (VersionHelper.isVersionNewerThan1_19_4()) { - VANILLA_CROPS.add(Material.TORCHFLOWER_CROP); - } - if (VersionHelper.isVersionNewerThan1_20()) { - VANILLA_CROPS.add(Material.PITCHER_CROP); - } } @Override @@ -168,7 +157,7 @@ public class BukkitConfigManager extends ConfigManager { } overriddenCrops.clear(); - overriddenCrops.addAll(config.getStringList("mechanics.override-vanilla-crops") + overriddenCrops.addAll(config.getStringList("mechanics.override-vanilla-blocks") .stream() .map(it -> { try { @@ -180,11 +169,7 @@ public class BukkitConfigManager extends ConfigManager { }) .filter(it -> { if (it == Material.AIR) return false; - boolean allow = VANILLA_CROPS.contains(it); - if (!allow) { - plugin.getPluginLogger().warn(it.name() + " is not a supported vanilla crop type"); - } - return allow; + return it.isBlock(); }) .toList()); } diff --git a/plugin/src/main/resources/config.yml b/plugin/src/main/resources/config.yml index 07c8994..123a6b3 100644 --- a/plugin/src/main/resources/config.yml +++ b/plugin/src/main/resources/config.yml @@ -125,8 +125,8 @@ mechanics: # Set hologram offset correction for other blocks hologram-offset-correction: "{0}crop_stage_death": 0 - # Set the crop types that would be overridden - override-vanilla-crops: [] + # Set the block types that would be overridden + override-vanilla-blocks: [] other-settings: # It's recommended to use MiniMessage format. If you insist on using legacy color code "&", enable the support below. # Disable this would improve performance