Do we need a region API?

Edit: Moved these posts, as this deserves its own topic:

I agree with that.
But where I see problems is “which player owns which block”. There isn’t a “region api”. I think some plugins need this for checking if an action is valid/can be performed by the plugin in this location. Therefore the developers had to support the different plugins(worldguard, foxguard, redprotect etc…)

2 Likes

Yeah, the Economy API was implemented to “abstract” all of the actions you need into an interface, and the plugin implements it; as long as you don’t rely specifically on a plugin’s API, and instead use the general Sponge-supplied EconomyAPI, you should be all good to go :wink:

@Randombyte, I do agree! That would be cool, but technically it could be created by a user, and then each of the “guards” could supply their service to the Sponge service manager… though it would be nice to be “official” :stuck_out_tongue:

Someone, draft up a PR, quick! [/s]

1 Like

Don’t you just check if the player has the permission to do stuff™?

Afaik you don’t need to rely on the actual protection plugin but you rather check via the permission API if the player has the permission or not.

The other option you have is to check who the last modification to a block made.
This should be doable via causes and causetracking.

1 Like

What if a player wants to apply special behavior to a block with a plugin and the block wasn’t placed by the current “region owner”? A player tries to execute /registerBlock on a block that he didn’t place but now is in his region. How could the plugin now know that he owns the block? The plugin only knows who/what placed the block, not its “owner”.

Uhm, usually you grant users the right to modify blocks in “their” region. Most protection plugins don’t check if you’re the owner or the one who modified it last, but if you’re in a region where you have a permission (or not). So causes and ownership aren’t an actual problem when it comes to protection.

So in your case the protection plugin would check two things:
a) does the user have the permission to execute the command /registerBlock?
b) does the user have the permission to modify blocks (aka is he in “his” region)?

If i’m missing the point, please tell me :wink:

@SuperMarioCraft_Gam At the bottom of this website you can turn the mode to “normal”.

@Tzk
a) Yes, I understand
b) Are the permissions relative to the current location of the player? So the permission e.g. blocks.break is granted for the player when he stands in his region but not when he moves outside?
In the end that could simply be tested by simulating a block break by the player. If the block is gone, he has permission there.

When using Foxguard you can create regions and grant or deny permissions depending on the position of the player :slight_smile:
We actually use this on the Sponge Community Server to protect different buildings but still allow free building in the rest of the world.

Ok, I think we talk past each other.
I think going practical helps: How do you check whether a player can build in Location loc?

You’d need a plugin which has a region set up eg: X1 Y1 Z1 to X2 Y2 Z2. Now you’d check if the current coords the player is at are in the range of the region. If yes, you grant/deny all perms based on the region if the player does something.

Note that i haven’t done this yet, i’m mostly a user, not a plugin author :wink:

Exactly this. Therefore I would have to ask WorldGuard, FoxGuard, RedProtect etc… That could be easier with a standardized Api. Maybe @gravityfox can help?

FoxGuard checks block location, not player location. Otherwise there would be a really easy exploit to break protected blocks.

Also regarding a region API. I was thinking about that, but i’m not sure if that’s something Sponge would actually do.

I’ll think about it though.

At the very least I would like to make Foxguard regions a lot more accessible.

I know I am not stupid. I suggested to move posts here because I wanted to receive notifications and emails that really apply to me. Especially from my own topics. @Tzk thanks for moving it. That was really appreciated.

1 Like

It might be pretty neat to have a separate library of APIs for plugins to implement or interact with various services (such as regions) through Sponge’s service manager.

I think there definitely should be an API of this sort, but not necessarily a region one. I think we need more of an ‘owner’ api, in which we can assign owners (not in the cause-tracking sense) to entities or blocks.

This is doable with the data api, except that Locations currently don’t necessarily retain data.

Setting an owner per Tile Entity / Entity would be fine, but per block? That would be a little intense for region-protectors (data wise, I think).

Though I could see the value of separating the API’s, one for simply owning and the other for regions… ack, this is interesting!

Wouldnt it just be simpler to check by permission with like FoxGuard?

Essentially this API is a permission system. There are already plugins that do this.

There already is an “owner” API: SpongeAPI/Extent.java at 648d95fb613ccb7020fce645dddaf703fb01130a · SpongePowered/SpongeAPI · GitHub

Either the existing “api” should be extended so there can be more than one owner or there should be a seperate api that handles them. I vote for foxguard like region shapes and not per block data.
@Ryahn can you name some examples?

Setting an owner by block would be a feature, but there would also be setting an owner by region, and if it had large regions already set, checking one block against them would be easy.

No, the api only allows us to see who create the block, there’s nothing about setting a certain block to a certain person…