compile fixes
This commit is contained in:
@@ -4,7 +4,7 @@ Date: Thu, 6 May 2021 19:57:58 -0700
|
||||
Subject: [PATCH] More Enchantment API
|
||||
|
||||
== AT ==
|
||||
public net.minecraft.world.item.enchantment.Enchantment slots
|
||||
public net.minecraft.world.item.enchantment.Enchantment definition
|
||||
|
||||
Co-authored-by: Luis <luisc99@icloud.com>
|
||||
|
||||
@@ -48,7 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ @Override
|
||||
+ public io.papermc.paper.enchantments.EnchantmentRarity getRarity() {
|
||||
+ return fromNMSRarity(handle.getRarity());
|
||||
+ throw new UnsupportedOperationException("Enchantments don't have a rarity anymore in 1.20.5+.");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
@@ -80,49 +80,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ @Override
|
||||
+ public java.util.Set<org.bukkit.inventory.EquipmentSlot> getActiveSlots() {
|
||||
+ return java.util.stream.Stream.of(handle.slots).map(org.bukkit.craftbukkit.CraftEquipmentSlot::getSlot).collect(java.util.stream.Collectors.toSet());
|
||||
+ }
|
||||
+
|
||||
+ public static io.papermc.paper.enchantments.EnchantmentRarity fromNMSRarity(net.minecraft.world.item.enchantment.Enchantment.Rarity nmsRarity) {
|
||||
+ if (nmsRarity == net.minecraft.world.item.enchantment.Enchantment.Rarity.COMMON) {
|
||||
+ return io.papermc.paper.enchantments.EnchantmentRarity.COMMON;
|
||||
+ } else if (nmsRarity == net.minecraft.world.item.enchantment.Enchantment.Rarity.UNCOMMON) {
|
||||
+ return io.papermc.paper.enchantments.EnchantmentRarity.UNCOMMON;
|
||||
+ } else if (nmsRarity == net.minecraft.world.item.enchantment.Enchantment.Rarity.RARE) {
|
||||
+ return io.papermc.paper.enchantments.EnchantmentRarity.RARE;
|
||||
+ } else if (nmsRarity == net.minecraft.world.item.enchantment.Enchantment.Rarity.VERY_RARE) {
|
||||
+ return io.papermc.paper.enchantments.EnchantmentRarity.VERY_RARE;
|
||||
+ }
|
||||
+
|
||||
+ throw new IllegalArgumentException(String.format("Unable to convert %s to a enum value of %s.", nmsRarity, io.papermc.paper.enchantments.EnchantmentRarity.class));
|
||||
+ return java.util.stream.Stream.of(handle.definition.slots()).map(org.bukkit.craftbukkit.CraftEquipmentSlot::getSlot).collect(java.util.stream.Collectors.toSet());
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
diff --git a/src/test/java/io/papermc/paper/enchantments/EnchantmentRarityTest.java b/src/test/java/io/papermc/paper/enchantments/EnchantmentRarityTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/enchantments/EnchantmentRarityTest.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.enchantments;
|
||||
+
|
||||
+import net.minecraft.world.item.enchantment.Enchantment.Rarity;
|
||||
+import org.bukkit.craftbukkit.enchantments.CraftEnchantment;
|
||||
+import org.junit.jupiter.api.Test;
|
||||
+
|
||||
+import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
+
|
||||
+public class EnchantmentRarityTest {
|
||||
+
|
||||
+ @Test
|
||||
+ public void test() {
|
||||
+ for (Rarity nmsRarity : Rarity.values()) {
|
||||
+ // Will throw exception if a bukkit counterpart is not found
|
||||
+ CraftEnchantment.fromNMSRarity(nmsRarity);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/test/java/io/papermc/paper/entity/EntityCategoryTest.java b/src/test/java/io/papermc/paper/entity/EntityCategoryTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
|
||||
Reference in New Issue
Block a user