Loosen restrictions on inventory sizing

Allows creating (but not opening) inventories created eg via Bukkit.createInventory(..., InventoryType.PLAYER);
Dieser Commit ist enthalten in:
md_5 2019-04-27 12:50:43 +10:00
Ursprung 6606cd88d2
Commit 6bb1f087e7
3 geänderte Dateien mit 3 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -1503,13 +1503,13 @@ public final class CraftServer implements Server {
@Override @Override
public Inventory createInventory(InventoryHolder owner, int size) throws IllegalArgumentException { public Inventory createInventory(InventoryHolder owner, int size) throws IllegalArgumentException {
Validate.isTrue(size % 9 == 0, "Chests must have a size that is a multiple of 9!"); Validate.isTrue(9 <= size && size <= 54 && size % 9 == 0, "Size for custom inventory must be a multiple of 9 between 9 and 54 slots");
return CraftInventoryCreator.INSTANCE.createInventory(owner, size); return CraftInventoryCreator.INSTANCE.createInventory(owner, size);
} }
@Override @Override
public Inventory createInventory(InventoryHolder owner, int size, String title) throws IllegalArgumentException { public Inventory createInventory(InventoryHolder owner, int size, String title) throws IllegalArgumentException {
Validate.isTrue(size % 9 == 0, "Chests must have a size that is a multiple of 9!"); Validate.isTrue(9 <= size && size <= 54 && size % 9 == 0, "Size for custom inventory must be a multiple of 9 between 9 and 54 slots");
return CraftInventoryCreator.INSTANCE.createInventory(owner, size, title); return CraftInventoryCreator.INSTANCE.createInventory(owner, size, title);
} }

Datei anzeigen

@ -333,7 +333,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
customSize = Containers.GENERIC_9X6; customSize = Containers.GENERIC_9X6;
break; break;
default: default:
throw new IllegalArgumentException("Unsupported custom size " + inventory.getSize()); throw new IllegalArgumentException("Unsupported custom inventory size " + inventory.getSize());
} }
openCustomInventory(inventory, player, customSize); openCustomInventory(inventory, player, customSize);
break; break;

Datei anzeigen

@ -55,7 +55,6 @@ 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.notNull(title, "Title cannot be null");
Validate.isTrue(9 <= size && size <= 54 && size % 9 == 0, "Size for custom inventory must be a multiple of 9 between 9 and 54 slots");
this.items = NonNullList.a(size, ItemStack.a); this.items = NonNullList.a(size, ItemStack.a);
this.title = title; this.title = title;
this.viewers = new ArrayList<HumanEntity>(); this.viewers = new ArrayList<HumanEntity>();