mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-05-12 06:06:55 +00:00
adjust costs and make enchants available from enchantment table
This commit is contained in:
@@ -3,15 +3,22 @@ package me.youhavetrouble.enchantio;
|
||||
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
|
||||
import io.papermc.paper.plugin.bootstrap.PluginBootstrap;
|
||||
import io.papermc.paper.plugin.bootstrap.PluginProviderContext;
|
||||
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import io.papermc.paper.registry.event.RegistryEvents;
|
||||
import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys;
|
||||
import io.papermc.paper.tag.TagEntry;
|
||||
import me.youhavetrouble.enchantio.enchants.EnchantioEnchant;
|
||||
import me.youhavetrouble.enchantio.enchants.SoulboundEnchant;
|
||||
import me.youhavetrouble.enchantio.enchants.TelepathyEnchant;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public class EnchantioBootstrap implements PluginBootstrap {
|
||||
@Override
|
||||
@@ -36,6 +43,15 @@ public class EnchantioBootstrap implements PluginBootstrap {
|
||||
}
|
||||
}));
|
||||
|
||||
context.getLifecycleManager().registerEventHandler(LifecycleEvents.TAGS.preFlatten(RegistryKey.ENCHANTMENT).newHandler((event) -> {
|
||||
Set<TagEntry<Enchantment>> enchantTags = new HashSet<>(EnchantioEnchant.getEnchants().size());
|
||||
for (EnchantioEnchant enchant : EnchantioEnchant.getEnchants().values()) {
|
||||
if (!enchant.canGetFromEnchantingTable()) continue;
|
||||
enchantTags.add(enchant.getTagEntry());
|
||||
}
|
||||
event.registrar().addToTag(EnchantmentTagKeys.IN_ENCHANTING_TABLE, enchantTags);
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user