SpongePowered / SpongeAPI

A Minecraft plugin API
http://www.spongepowered.org/
MIT License
1.14k stars 342 forks source link

Generify Location's Extent #788

Closed DDoS closed 9 years ago

DDoS commented 9 years ago

Location should have type Location<T extends Extent>. This would allow T getExtent() to return a concrete type, such as World. This would fix the common case of (World) object.getLocation().getExtent(). Currently it returns Extent which isn't all that useful.

zml2008 commented 9 years ago

This seems pretty useful -- probably wouldn't have to increase verbosity much in most places too.

DDoS commented 9 years ago

I think the verbosity saved from casts and instanceof checks would compensate for the slightly longer type name.

DDoS commented 9 years ago

Here's what the API looks like with generic locations.

@SpongePowered/developers Yes or no? Should we just replace Extent by World in Location, since that seems to be the most used type by far?

kashike commented 9 years ago

This seems pretty helpful, I think it is worth the verbosity?

zml2008 commented 9 years ago

yeah, I think generifying Location is probably the best way to go. Would be great for stuff to use Extent wherever possible too, rather than World, so that we can do things like what WE does with treegen on bukkit -- sticking an Extent in between that allows capturing changes occurring.

DDoS commented 9 years ago

Well currently Extent is way too big of an interface to actually be useful, but that's another issue.

DDoS commented 9 years ago

Closing this, follow in the PR.