mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 11:45:52 -07:00
#1002: Improve documentation and implementation of getMaxStackSize
By: 2008Choco <hawkeboyz2@hotmail.com>
This commit is contained in:
@@ -116,6 +116,8 @@ import org.bukkit.block.data.type.WallHangingSign;
|
|||||||
import org.bukkit.block.data.type.WallSign;
|
import org.bukkit.block.data.type.WallSign;
|
||||||
import org.bukkit.inventory.CreativeCategory;
|
import org.bukkit.inventory.CreativeCategory;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -4753,7 +4755,12 @@ public enum Material implements Keyed, Translatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the maximum amount of this material that can be held in a stack
|
* Gets the maximum amount of this material that can be held in a stack.
|
||||||
|
* <p>
|
||||||
|
* Note that this is the <strong>default</strong> maximum size for this Material.
|
||||||
|
* {@link ItemStack ItemStacks} are able to change their maximum stack size per
|
||||||
|
* stack with {@link ItemMeta#setMaxStackSize(Integer)}. If an ItemStack instance
|
||||||
|
* is available, {@link ItemStack#getMaxStackSize()} may be preferred.
|
||||||
*
|
*
|
||||||
* @return Maximum stack size for this material
|
* @return Maximum stack size for this material
|
||||||
*/
|
*/
|
||||||
|
@@ -231,18 +231,21 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the maximum stacksize for the material hold in this ItemStack.
|
* Get the maximum stack size for this item. If this item has a max stack
|
||||||
* (Returns -1 if it has no idea)
|
* size component ({@link ItemMeta#hasMaxStackSize()}), the value of that
|
||||||
|
* component will be returned. Otherwise, this item's Material's {@link
|
||||||
|
* Material#getMaxStackSize() default maximum stack size} will be returned
|
||||||
|
* instead.
|
||||||
*
|
*
|
||||||
* @return The maximum you can stack this material to.
|
* @return The maximum you can stack this item to.
|
||||||
*/
|
*/
|
||||||
@Utility
|
@Utility
|
||||||
public int getMaxStackSize() {
|
public int getMaxStackSize() {
|
||||||
Material material = getType();
|
if (meta != null && meta.hasMaxStackSize()) {
|
||||||
if (material != null) {
|
return meta.getMaxStackSize();
|
||||||
return material.getMaxStackSize();
|
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
|
return getType().getMaxStackSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createData(final byte data) {
|
private void createData(final byte data) {
|
||||||
|
Reference in New Issue
Block a user