NucleoidMC / leukocyte

Region-based protection controllable by API or commands
GNU Lesser General Public License v3.0
39 stars 13 forks source link

Leukocyte

Leukocyte is a simple world protection mod for Fabric providing optional integration with player-roles.

The basis of world protection with leukocyte is an "authority". An authority is responsible for applying specific rules to players within it. An authority has a unique name, as well as a priority ("level"), and set of player exclusions.

creating authorities

To create an empty authority, run: /protect add <name>.
Alternatively, an authority can be created to apply within a specific area like:

An authority can be later removed with /protect remove <name>.

setting rules

Leukocyte provides various rules that can be applied within authorities. These rules are:

To set a rule as allow or deny on an authority, use /protect set rule <authority> <rule> <result>.

For example: /protect set example place deny will disallow block placement within the authority named example.

making shapes

Often, you may want to protect an area with a weird shape that is not just a simple box. To achieve this, it is possible to combine multiple simple shapes into a more complex one which will be used to apply rules.

To start, run: /protect shape start. This will begin the construction of a shape.
Next, to add primitives to this shape, run:

These commands can be run multiple times to compose your shape.

Once you have finished composing a shape, you can run: /protect shape finish <name> to <authority>. This will add a shape with the given name to the given authority.

This shape can be removed in the future with /protect shape remove <name> from <authority>.

setting levels

When dealing with multiple authorities, you may want one to take priority over another. For example, you may want a global authority to disallow griefing everywhere except specific areas for building.

This is where levels come in: a level is just any number, where a higher level indicates higher priority, and a lower level indicates lower priority. Given an authority with a level of -1, an overlapping authority with a level of 10 will override the rules of the first.

Levels can be set on an authority with: /protect set level <authority> <level>.

adding exclusions

It may not be desirable for the rules of an authority to apply to everyone. In this case, it is possible to exclude specific players, or entire roles from being affected by a given authority.

This is achieved through running: /protect exclusion add <authority> player <name> or /protect exclusion add <authority> role <name>.

These exclusions can additionally be later removed with /protect exclusion remove.

putting it together: an example

That was a lot of things! Let's put this knowledge together on a simple example.

Our example server will want to have global grief protection, except in our survival dimension and free-build areas. We additionally want to be able to exclude certain players from building in the free-build areas by use of a role.

Let's consider the two dimensions: minecraft:overworld and example:survival, as well as the role builders.

First, let's create an authority named global. Since we will mostly want protection everywhere, it makes sense to globally apply protection and then specifically override this in specific areas.

Next, we can set the rules on this authority:

Done! Now, let's override this behavior in our survival dimension.

But wait..! How will the mod know to apply the rules of global or survival, since global also applies in the survival dimension? Here, we can make use of levels: the default level for an authority is 0, and a larger value means higher priority.
So: let's set the level of our global authority to -1 such that anything we add in the future overrides it by default.

Now we can similarly add our free build areas as exclusions too! Let's say we have two free build areas, creatively named free_build_1 and free_build_2. First, we should create an empty authority that applies to both of them, since they both have the same rules.

Next, let's compose the shape for free_build_1:

And repeat the same for free_build_2:

Done! Now the free-build areas should be editable by any player- except, we want to create exclusions such that we can 'ban' players from the areas. Let's do that with a free_build_banned role:

With that, all our protection should be set up nicely! :)

testing! querying and checking rules

Okay, we've set up authorities, but how can we easily check which rules are set and by what?

A few commands may come in handy: