FountainMC / FountainAPI

A 'simple but beautiful' Minecraft Server Plugin API
https://fountainmc.org/
MIT License
5 stars 5 forks source link

Inventory API #26

Open PizzaCrust opened 8 years ago

PizzaCrust commented 8 years ago

Possibly:

Fountain.getServer().newInventory("Microwave")
                                 .size(9)
                                 .item(Item.builder(server, Materials.TACO)
                                 .tasty(true)
                                 .addEnchantment(EnchantmentTypes.SUPER_YUMMY,  1)
                                 .build(),                            
                                 ,0)
                                 .itemRange(Materials.MICROWAVE_STUFF, 1, 8)
                                 .build();
phase commented 8 years ago

I don't know if I like going through the server to create them. An InventoryManager or another proxy class would make things cleaner.

I also think making a builder for everything is overkill. What if I want to create the inventory while iterating through a loop? I'd have to cache my items in an array and then add it to the builder.

PizzaCrust commented 8 years ago
Fountain.getInventoryBuilder("Microwave").build();

You don't have to cache, you could do this:

InventoryBuilder builder = Fountain.getInventoryBuilder("Microwave");
for (SomeItem item : itemList) {
     builder.item(item);
}
builder.build();
Techcable commented 8 years ago

Inventories shouldn't be immutable. Thats going to involve massive amounts of overhead and copying, and is pretty confusing.