SpongeAPI icon indicating copy to clipboard operation
SpongeAPI copied to clipboard

Shortcut method for cataloged classes

Open XakepSDK opened this issue 5 years ago • 2 comments

Maybe introduce something like class.builder() for registry requests? e.g. ItemType.of(String) or ItemTypes.of(String)

static Optional<ItemType> of(String id) {
    return Sponge.getRegistry().getType(ItemType.clsas, id);
}

XakepSDK avatar Feb 04 '19 22:02 XakepSDK

I really like the idea. This would make the class more enum like. Maybe also add a getAll() method .

ST-DDT avatar Feb 05 '19 06:02 ST-DDT

My vote is for ItemType as opposed to ItemTypes because ItemTypes is meant as a static registry of the vanilla types while ItemType knows about the dynamic registry by ID. Also, I think that .of implies construction and the method should instead be named getById or similar.

pie-flavor avatar Apr 11 '19 00:04 pie-flavor