First version of tunnelling enchant (#4)

* some work on tunnelling enchant

* first working version of tunnelling
This commit is contained in:
2026-09-27 21:20:27 +02:00
committed by GitHub
parent 85585b14d6
commit fdc7d21685
6 changed files with 375 additions and 0 deletions
@@ -2,12 +2,14 @@ package me.youhavetrouble.enchantio;
import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.TypedKey;
import io.papermc.paper.registry.keys.tags.BlockTypeTagKeys;
import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys;
import io.papermc.paper.registry.keys.tags.ItemTypeTagKeys;
import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.enchants.*;
import net.kyori.adventure.key.Key;
import org.bukkit.block.BlockType;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -78,6 +80,9 @@ public class EnchantioConfig {
ConfigurationSection wardSection = getConfigSection(enchantsSection, "ward");
WardEnchant.create(wardSection);
ConfigurationSection tunnellingSection = getConfigSection(enchantsSection, "tunnelling");
TunnellingEnchant.create(tunnellingSection);
ConfigurationSection cursesSection = getConfigSection(configuration, "curses");
migrateEnchantTags(cursesSection);
@@ -210,6 +215,32 @@ public class EnchantioConfig {
return enchantTagKeys;
}
public static Set<TagEntry<BlockType>> getBlockTagKeysFromList(@NotNull List<String> tags) {
Set<TagEntry<BlockType>> blockTagKeys = new HashSet<>();
for (String blockTag : tags) {
if (blockTag == null) continue;
if (blockTag.startsWith("#")) {
blockTag = blockTag.substring(1);
try {
Key key = Key.key(blockTag);
TagKey<BlockType> tagKey = BlockTypeTagKeys.create(key);
TagEntry<BlockType> tagEntry = TagEntry.tagEntry(tagKey);
blockTagKeys.add(tagEntry);
} catch (IllegalArgumentException e) {
}
continue;
}
try {
Key key = Key.key(blockTag);
TypedKey<BlockType> typedKey = TypedKey.create(RegistryKey.BLOCK, key);
TagEntry<BlockType> tagEntry = TagEntry.valueEntry(typedKey);
blockTagKeys.add(tagEntry);
} catch (IllegalArgumentException | NullPointerException e) {
}
}
return blockTagKeys;
}
public static ConfigurationSection getConfigSection(ConfigurationSection section, String key) {
ConfigurationSection value = section.getConfigurationSection(key);
if (value == null) {