translatable enchantment titles, and finally figured out how to add them to the enchantment table from server side
This commit is contained in:
@@ -4,12 +4,30 @@ import dev.sillyangel.more_spear_enchantments.enchantment.SpearEnchantments;
|
||||
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
|
||||
import io.papermc.paper.plugin.bootstrap.PluginBootstrap;
|
||||
import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager;
|
||||
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.PostFlattenTagRegistrar;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class SpearEnchantmentsBootstrap implements PluginBootstrap {
|
||||
|
||||
// Define all enchantments in one place for easy management
|
||||
private static final Set<TypedKey<Enchantment>> ALL_ENCHANTMENTS = Set.of(
|
||||
SpearEnchantments.VAMPIRIC,
|
||||
SpearEnchantments.EXPLOSIVE,
|
||||
SpearEnchantments.LIGHTNING,
|
||||
SpearEnchantments.CRIPPLING,
|
||||
SpearEnchantments.POISON,
|
||||
SpearEnchantments.WITHERING
|
||||
);
|
||||
|
||||
@Override
|
||||
public void bootstrap(@NotNull BootstrapContext context) {
|
||||
context.getLogger().info("MoreSpearEnchantments bootstrap starting...");
|
||||
@@ -21,6 +39,14 @@ public class SpearEnchantmentsBootstrap implements PluginBootstrap {
|
||||
SpearEnchantments.registerEnchantments(event.registry());
|
||||
}));
|
||||
|
||||
// Add all enchantments to the appropriate tags
|
||||
manager.registerEventHandler(LifecycleEvents.TAGS.postFlatten(RegistryKey.ENCHANTMENT), event -> {
|
||||
final PostFlattenTagRegistrar<Enchantment> registrar = event.registrar();
|
||||
registrar.addToTag(EnchantmentTagKeys.TRADEABLE, ALL_ENCHANTMENTS);
|
||||
registrar.addToTag(EnchantmentTagKeys.NON_TREASURE, ALL_ENCHANTMENTS);
|
||||
registrar.addToTag(EnchantmentTagKeys.IN_ENCHANTING_TABLE, ALL_ENCHANTMENTS);
|
||||
});
|
||||
|
||||
context.getLogger().info("MoreSpearEnchantments bootstrap complete!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SpearEnchantments {
|
||||
registry.register(
|
||||
VAMPIRIC,
|
||||
builder -> builder
|
||||
.description(Component.text("Vampiric"))
|
||||
.description(Component.translatable("enchantment.more_spear_enchantments.vampiric", "Vampiric"))
|
||||
.maxLevel(3)
|
||||
.weight(2)
|
||||
.minimumCost(EnchantmentRegistryEntry.EnchantmentCost.of(10, 8))
|
||||
@@ -80,7 +80,7 @@ public class SpearEnchantments {
|
||||
registry.register(
|
||||
EXPLOSIVE,
|
||||
builder -> builder
|
||||
.description(Component.text("Explosive"))
|
||||
.description(Component.translatable("enchantment.more_spear_enchantments.explosive", "Explosive"))
|
||||
.maxLevel(3)
|
||||
.weight(1)
|
||||
.minimumCost(EnchantmentRegistryEntry.EnchantmentCost.of(20, 10))
|
||||
@@ -95,7 +95,7 @@ public class SpearEnchantments {
|
||||
registry.register(
|
||||
LIGHTNING,
|
||||
builder -> builder
|
||||
.description(Component.text("Lightning"))
|
||||
.description(Component.translatable("enchantment.more_spear_enchantments.lightning", "Lightning"))
|
||||
.maxLevel(3)
|
||||
.weight(2)
|
||||
.minimumCost(EnchantmentRegistryEntry.EnchantmentCost.of(15, 9))
|
||||
@@ -110,7 +110,7 @@ public class SpearEnchantments {
|
||||
registry.register(
|
||||
CRIPPLING,
|
||||
builder -> builder
|
||||
.description(Component.text("Crippling"))
|
||||
.description(Component.translatable("enchantment.more_spear_enchantments.crippling", "Crippling"))
|
||||
.maxLevel(3)
|
||||
.weight(2)
|
||||
.minimumCost(EnchantmentRegistryEntry.EnchantmentCost.of(10, 8))
|
||||
@@ -125,7 +125,7 @@ public class SpearEnchantments {
|
||||
registry.register(
|
||||
POISON,
|
||||
builder -> builder
|
||||
.description(Component.text("Poison"))
|
||||
.description(Component.translatable("enchantment.more_spear_enchantments.poison", "Poison"))
|
||||
.maxLevel(3)
|
||||
.weight(2)
|
||||
.minimumCost(EnchantmentRegistryEntry.EnchantmentCost.of(10, 8))
|
||||
@@ -140,7 +140,7 @@ public class SpearEnchantments {
|
||||
registry.register(
|
||||
WITHERING,
|
||||
builder -> builder
|
||||
.description(Component.text("Withering"))
|
||||
.description(Component.translatable("enchantment.more_spear_enchantments.withering", "Withering"))
|
||||
.maxLevel(3)
|
||||
.weight(1)
|
||||
.minimumCost(EnchantmentRegistryEntry.EnchantmentCost.of(15, 9))
|
||||
|
||||
Reference in New Issue
Block a user