Compare commits

..

2 Commits

Author SHA1 Message Date
f0222253df Merge branch 'master' of git.sillyangel.dev:angel/mse-paper
All checks were successful
Build / build (push) Successful in 2m17s
2026-01-19 09:36:48 -06:00
bd25bedacc translatable enchantment titles, and finally figured out how to add them to the enchantment table from server side 2026-01-19 09:32:38 -06:00
2 changed files with 32 additions and 6 deletions

View File

@@ -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!");
}
}

View File

@@ -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))