geforkt von Mirrors/Paper
Validate title for custom inventories. Fixes BUKKIT-4616, BUKKIT-4663
Custom inventories currently do not validate the titles provided. Null values cause NPEs when writing packets. Values longer than 32 characters disconnect clients. This change throws and IllegalArgumentException for null titles or titles longer than 32 characters. By: Wesley Wolfe <weswolf@aol.com>
Dieser Commit ist enthalten in:
Ursprung
6f3af92b3d
Commit
33c7445582
@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.inventory;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
@ -43,6 +44,8 @@ public class CraftInventoryCustom extends CraftInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MinecraftInventory(InventoryHolder owner, int size, String title) {
|
public MinecraftInventory(InventoryHolder owner, int size, String title) {
|
||||||
|
Validate.notNull(title, "Title cannot be null");
|
||||||
|
Validate.isTrue(title.length() <= 32, "Title cannot be longer than 32 characters");
|
||||||
this.items = new ItemStack[size];
|
this.items = new ItemStack[size];
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.viewers = new ArrayList<HumanEntity>();
|
this.viewers = new ArrayList<HumanEntity>();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren