mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-31 04:02:06 -07:00
Remove ItemFactory#enchantWithLevels range check for vanilla parity (#12209)
This commit is contained in:
@@ -327,7 +327,7 @@ public interface ItemFactory {
|
||||
*
|
||||
* <p>If the provided ItemStack is already enchanted, the existing enchants will be removed before enchanting.</p>
|
||||
*
|
||||
* <p>Levels must be in range {@code [1, 30]}.</p>
|
||||
* <p>Enchantment tables use levels in the range {@code [1, 30]}.</p>
|
||||
*
|
||||
* @param itemStack ItemStack to enchant
|
||||
* @param levels levels to use for enchanting
|
||||
@@ -336,7 +336,7 @@ public interface ItemFactory {
|
||||
* @return enchanted copy of the provided ItemStack
|
||||
* @throws IllegalArgumentException on bad arguments
|
||||
*/
|
||||
@NotNull ItemStack enchantWithLevels(@NotNull ItemStack itemStack, @org.jetbrains.annotations.Range(from = 1, to = 30) int levels, boolean allowTreasure, @NotNull java.util.Random random);
|
||||
@NotNull ItemStack enchantWithLevels(@NotNull ItemStack itemStack, int levels, boolean allowTreasure, @NotNull java.util.Random random);
|
||||
// Paper end - enchantWithLevels API
|
||||
// Paper start - enchantWithLevels with tag specification
|
||||
/**
|
||||
@@ -344,7 +344,7 @@ public interface ItemFactory {
|
||||
*
|
||||
* <p>If the provided ItemStack is already enchanted, the existing enchants will be removed before enchanting.</p>
|
||||
*
|
||||
* <p>Levels must be in range {@code [1, 30]}.</p>
|
||||
* <p>Enchantment tables use levels in the range {@code [1, 30]}.</p>
|
||||
*
|
||||
* @param itemStack ItemStack to enchant
|
||||
* @param levels levels to use for enchanting
|
||||
@@ -353,6 +353,6 @@ public interface ItemFactory {
|
||||
* @return enchanted copy of the provided ItemStack
|
||||
* @throws IllegalArgumentException on bad arguments
|
||||
*/
|
||||
@NotNull ItemStack enchantWithLevels(@NotNull ItemStack itemStack, @org.jetbrains.annotations.Range(from = 1, to = 30) int levels, @NotNull io.papermc.paper.registry.set.RegistryKeySet<@NotNull Enchantment> keySet, @NotNull java.util.Random random);
|
||||
@NotNull ItemStack enchantWithLevels(@NotNull ItemStack itemStack, int levels, @NotNull io.papermc.paper.registry.set.RegistryKeySet<@NotNull Enchantment> keySet, @NotNull java.util.Random random);
|
||||
// Paper end - enchantWithLevels with tag specification
|
||||
}
|
||||
|
@@ -683,7 +683,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
*
|
||||
* <p>If this ItemStack is already enchanted, the existing enchants will be removed before enchanting.</p>
|
||||
*
|
||||
* <p>Levels must be in range {@code [1, 30]}.</p>
|
||||
* <p>Enchantment tables use levels in the range {@code [1, 30]}.</p>
|
||||
*
|
||||
* @param levels levels to use for enchanting
|
||||
* @param allowTreasure whether to allow enchantments where {@link org.bukkit.enchantments.Enchantment#isTreasure()} returns true
|
||||
@@ -692,7 +692,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
* @throws IllegalArgumentException on bad arguments
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack enchantWithLevels(final @org.jetbrains.annotations.Range(from = 1, to = 30) int levels, final boolean allowTreasure, final @NotNull java.util.Random random) {
|
||||
public ItemStack enchantWithLevels(final int levels, final boolean allowTreasure, final @NotNull java.util.Random random) {
|
||||
return Bukkit.getServer().getItemFactory().enchantWithLevels(this, levels, allowTreasure, random);
|
||||
}
|
||||
|
||||
@@ -701,7 +701,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
*
|
||||
* <p>If the provided ItemStack is already enchanted, the existing enchants will be removed before enchanting.</p>
|
||||
*
|
||||
* <p>Levels must be in range {@code [1, 30]}.</p>
|
||||
* <p>Enchantment tables use levels in the range {@code [1, 30]}.</p>
|
||||
*
|
||||
* @param levels levels to use for enchanting
|
||||
* @param keySet registry key set defining the set of possible enchantments, e.g. {@link io.papermc.paper.registry.keys.tags.EnchantmentTagKeys#IN_ENCHANTING_TABLE}.
|
||||
@@ -709,7 +709,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
* @return enchanted copy of the provided ItemStack
|
||||
* @throws IllegalArgumentException on bad arguments
|
||||
*/
|
||||
public @NotNull ItemStack enchantWithLevels(final @org.jetbrains.annotations.Range(from = 1, to = 30) int levels, final @NotNull io.papermc.paper.registry.set.RegistryKeySet<@NotNull Enchantment> keySet, final @NotNull java.util.Random random) {
|
||||
public @NotNull ItemStack enchantWithLevels(final int levels, final @NotNull io.papermc.paper.registry.set.RegistryKeySet<@NotNull Enchantment> keySet, final @NotNull java.util.Random random) {
|
||||
return Bukkit.getItemFactory().enchantWithLevels(this, levels, keySet, random);
|
||||
}
|
||||
|
||||
|
@@ -349,7 +349,6 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
) {
|
||||
Preconditions.checkArgument(itemStack != null, "Argument 'itemStack' must not be null");
|
||||
Preconditions.checkArgument(!itemStack.isEmpty(), "Argument 'itemStack' cannot be empty");
|
||||
Preconditions.checkArgument(levels > 0 && levels <= 30, "Argument 'levels' must be in range [1, 30] (attempted " + levels + ")");
|
||||
Preconditions.checkArgument(random != null, "Argument 'random' must not be null");
|
||||
final net.minecraft.world.item.ItemStack internalStack = CraftItemStack.asNMSCopy(itemStack);
|
||||
if (internalStack.isEnchanted()) {
|
||||
|
Reference in New Issue
Block a user