Add even more Enchantment API (#11115)

This commit is contained in:
Jake Potrebic
2024-08-17 13:58:36 -07:00
parent 0a041c951d
commit 0df31bdeb3
5 changed files with 154 additions and 26 deletions

View File

@@ -37,16 +37,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- return io.papermc.paper.adventure.PaperAdventure.asAdventure(getHandle().getFullname(level));
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(net.minecraft.world.item.enchantment.Enchantment.getFullname(this.handle, level));
}
// Paper end
@Override
public String translationKey() {
- return this.handle.getDescriptionId();
+ if (!(this.getHandle().description().getContents() instanceof final TranslatableContents translatableContents)) {
+ throw new UnsupportedOperationException("Description isn't translatable!"); // Paper
+ }
+ return translatableContents.getKey();
+ }
+
@@ -0,0 +0,0 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
throw new UnsupportedOperationException("Description isn't translatable!"); // Paper
}
return translatableContents.getKey();
-
}
// Paper end - add translationKey methods
+ // Paper start - more Enchantment API
+ @Override
+ public boolean isTradeable() {
+ return this.handle.is(EnchantmentTags.TRADEABLE);
@@ -96,6 +97,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return this.getHandle().definition().slots().stream()
+ .map(org.bukkit.craftbukkit.CraftEquipmentSlot::getSlot)
+ .collect(java.util.stream.Collectors.toSet());
}
// Paper end
+ }
+ // Paper end - more Enchantment API
+
@Override
public String getTranslationKey() {
return Util.makeDescriptionId("enchantment", this.handle.unwrapKey().get().location());