13
0
geforkt von Mirrors/Paper

#1002: Improve documentation and implementation of getMaxStackSize

By: 2008Choco <hawkeboyz2@hotmail.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2024-04-28 09:11:30 +10:00
Ursprung d89271b470
Commit 74cf79c267
2 geänderte Dateien mit 18 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -116,6 +116,8 @@ import org.bukkit.block.data.type.WallHangingSign;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.inventory.CreativeCategory;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData;
import org.jetbrains.annotations.NotNull;
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
*/

Datei anzeigen

@ -231,18 +231,21 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
}
/**
* Get the maximum stacksize for the material hold in this ItemStack.
* (Returns -1 if it has no idea)
* Get the maximum stack size for this item. If this item has a max stack
* 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
public int getMaxStackSize() {
Material material = getType();
if (material != null) {
return material.getMaxStackSize();
if (meta != null && meta.hasMaxStackSize()) {
return meta.getMaxStackSize();
}
return -1;
return getType().getMaxStackSize();
}
private void createData(final byte data) {