mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-09-18 21:45:12 +00:00
SPIGOT-5515: Add basic validation against creating non-item itemstacks
This commit is contained in:
parent
7dd1cfcdbc
commit
a11aad2134
1 changed files with 2 additions and 0 deletions
|
@ -68,6 +68,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
|||
@Deprecated
|
||||
public ItemStack(@NotNull final Material type, final int amount, final short damage, @Nullable final Byte data) {
|
||||
Validate.notNull(type, "Material cannot be null");
|
||||
Validate.isTrue(type.isItem(), "Material must be an item: ", type);
|
||||
this.type = type;
|
||||
this.amount = amount;
|
||||
if (damage != 0) {
|
||||
|
@ -116,6 +117,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
|||
@Utility
|
||||
public void setType(@NotNull Material type) {
|
||||
Validate.notNull(type, "Material cannot be null");
|
||||
Validate.isTrue(type.isItem(), "Material must be an item: ", type);
|
||||
this.type = type;
|
||||
if (this.meta != null) {
|
||||
this.meta = Bukkit.getItemFactory().asMetaFor(meta, type);
|
||||
|
|
Loading…
Add table
Reference in a new issue