[WIP] 🌐 RegionsAPI [API:6.x]

:globe_with_meridians: RegionsAPI

This will provide an API as addition to the SpongeAPI for the use of regions with different plugins. More will coming soon…

Interfaces / AbstractClasses

RegionsAPI will possibly contain the following Interfaces/AbstractClasses ready for implementation for any Regions-Plugin:

  • RegionService
  • Region
  • RegionBuilder
  • RegionFlag
  • RegionShape
  • RegionEntityEvent (for events related to entites)
  • RegionShapeEvent (for events related to edit a region’s shape)
  • RegionFlagEvent (for events related to edit a region’s flags)
  • (PluginRelatable)
  • (RegionParentable)

:mortar_board: Basc idea

A Region contains:

  • a RegionShape object which defines the boundaries of the region
  • a id as String for easy identification
  • optional multiple Region objects as parents for inheritance of flags
  • optional multiple RegionFlag objects

So any plugin can see if there are regions or create/modify them. Regions and flags can be marked as related to a specific plugin.

How to build a Region: You can either make your very own factory class for this or you can implement/use the RegionBuilder. The builder allows you to create a region over some time, so there are no unfinished regions registered in the RegionService.

Very basic RegionShape: Because of the simpleness of the shapes, everything can be implemented as a region shape, you could implement many shapes like chunk-based shapes or vertice-based shapes. A region can always change its shape, for example convert it from a chunk region to a vertice region or vice versa.

You can get the current class diagramm here: :chart_with_upwards_trend: RegionsAPI classes

##:zap:Events
These events are triggered by any entity that are in triggering range. This should include mobs, players, etc.

Entering a region:

  • APPROACHING_BORDER_FROM_OUTSIDE
  • ENTERING
  • ENTERED (This should also be triggered if entitys are teleported, warped or spawned into the region)

Leaving a region:

  • APPROACHING_BORDER_FROM_INSIDE
  • LEAVING
  • LEFT

Shapes/Flags

  • SHAPE_CREATED/REMOVED/EDITED
  • FLAG_CREATED/REMOVED/EDITED

:gift: Features

:hammer: Source

You can view the current source code here: RegionsAPI GitHub

Info

So, yeah. I thought someone has to do this :smiley:
Idea and opinions are welcomend at every time, The developing of the base structure is still in progress and far from finished.

Your part!

How would you want to use it? What do you need?

  • Your help is appreciated!

You want to implement/use the API?

2 Likes

This might be interesting:

1 Like

Thanks, @RandomByte!
I’ll definitely look into that. There are some good suggestions in there :slight_smile:

I think stuff like ownership can completly be handled with flags, like a flag that is related to any plugin and contains the uuid of the player owner or something. Same thing goes for welcome-messages in my opinion. So the plugins using the API can handle the information given about the region (thruogh flags) in their way.

no SpongeVanilla?

I made a mistake in the description, it’s developed with the SpongeAPI, so there is no limitation to SpongeForge :slight_smile:

Maybe this is out of scope of the API, but a method to check if a Location<World> is in a Region or vice versa would be nice.

In fact, the method you mentioned is already placed in the API in the Region-interface as containsLocation(Location location);. There are also methods to retrieve all regions containing a specific location.

The ‘method-chain’ ends in the Shape-interface. So, in the end, the Shape-object can decide if a given location is inside of it.
In Addition, it depends on the implementation of the Shape-interface if the border is counted as ‘in-shape’ or not.