Add action and handler for gliding, equip, refactored PolicyParser and implementations to support world matching
Some checks are pending
Build / build (push) Waiting to run
Some checks are pending
Build / build (push) Waiting to run
This commit is contained in:
parent
96005d8c86
commit
f4a362c1c7
35 changed files with 651 additions and 177 deletions
34
docs/Nodes.md
Normal file
34
docs/Nodes.md
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# Nodes
|
||||
Nodes narrow down even further if an action can be done or not. A node needs _properties_ to know what it should check against, for example, a HIT node needs a _list_ of blocks that it will check if the player is holding; while a USE_ENCHANTMENT node needs a mapping of enchantment to level. Some nodes like glyde don't need a value and will ignore if you provide one.
|
||||
```yaml
|
||||
nodes:
|
||||
- [HIT]:
|
||||
values:
|
||||
- 'GOLD_SWORD'
|
||||
- [USE_ENCHANTMENT]:
|
||||
values:
|
||||
- "UNBREAKING": "1"
|
||||
- [GLYDE]
|
||||
```
|
||||
|
||||
## Available nodes
|
||||
### INTERACT
|
||||
Triggered on `InteractionEvent`, returns true when the provided `list` contains the material used to interact.
|
||||
|
||||
### HIT
|
||||
Triggered on `EntityDamageByEntityEvent`, returns true when the provided `list` contains the material used to hit.
|
||||
|
||||
### PLACE
|
||||
Triggered on `BlockPlaceEvent`, returns true when the provided `list` contains the material being placed.
|
||||
|
||||
### BREAK
|
||||
Triggered on `BlockBreakEvent`, returns true when the provided `list` contains the material used to break.
|
||||
|
||||
### EQUIP
|
||||
Triggered on `InventoryClickEvent` and `PlayerInteractEvent` (only if item is an armor), returns true when the provided `list` contains the material being equipped.
|
||||
|
||||
### GLYDE
|
||||
Triggered on `PlayerMoveEvent`, returns true if player is gliding.
|
||||
|
||||
### USE_ENCHANTMENT
|
||||
Triggered on `BlockBreakEvent` and `onEntityDamageByEntityEvent`, returns true the used item has an enchantment matching the provided mapping of enchantment-level.
|
||||
89
docs/Policies.md
Normal file
89
docs/Policies.md
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
# Policies
|
||||
Policies are a list of nodes with a specific condition to be met, they also determine what effect a node is going to have. Below is an example policy:
|
||||
```yaml
|
||||
- name: "Allow example"
|
||||
type: "location"
|
||||
effect: ALLOW
|
||||
weight: 1
|
||||
worlds: [world]
|
||||
locations:
|
||||
coordinates:
|
||||
- corner1: { x: 2100, y: 256, z: 1400 }
|
||||
corner2: { x: 1000, y: -64, z: 2200 }
|
||||
nodes:
|
||||
- [INTERACT, BREAK, HIT, PLACE]:
|
||||
values:
|
||||
- AIR
|
||||
```
|
||||
|
||||
## Properties
|
||||
### `name`
|
||||
Name of the policy, must not contain spaces or else commands that require you to type the policy name will not work.
|
||||
|
||||
Example: `name: "disable-axe-damage"`
|
||||
|
||||
### `type`
|
||||
One of the policy [types](#Types).
|
||||
|
||||
Example: `type: location`
|
||||
|
||||
### `effect`
|
||||
Can be `deny` to block the action if a node check returns true, `ALLOW` to revert `DENY` effects if the node check is true or `ALLOWONLY` to allow the action **only** if the node check returns true.
|
||||
|
||||
Example: `effect: DENY`
|
||||
|
||||
### `weight`
|
||||
A policy with greater weight will override a conflicting policy of lower weight.
|
||||
|
||||
Example: `weight: 0`
|
||||
|
||||
### `nodes`
|
||||
Must contain a list of node mappings to evaluate if the policy applies to a player.
|
||||
|
||||
Example:
|
||||
```yaml
|
||||
nodes:
|
||||
- [HIT]:
|
||||
values:
|
||||
- '.*_AXE$'
|
||||
```
|
||||
|
||||
### `locations`
|
||||
Only used for `type: "location"`, is a list of mappings where corner1 and corner2 should map x, y and z to two corners of a rectangular area where the policy will take effect; `worlds` may be defined here.
|
||||
|
||||
Example:
|
||||
|
||||
```yaml
|
||||
locations:
|
||||
worlds: [world]
|
||||
coordinates:
|
||||
- corner1: { x: 2100, y: 256, z: 1400 }
|
||||
corner2: { x: 1000, y: -64, z: 2200 }
|
||||
```
|
||||
|
||||
### `permissions`
|
||||
Only used for `type: "permission"`, is a list of permissions.
|
||||
|
||||
Example:
|
||||
|
||||
```yaml
|
||||
permissions:
|
||||
- "server.axehit"
|
||||
```
|
||||
|
||||
### `names`
|
||||
Only used for `type: "playerName"`, is a list of player names.
|
||||
|
||||
## Types
|
||||
|
||||
### `global`
|
||||
Always matches.
|
||||
|
||||
### `location`
|
||||
Matches if the player location is inside any rectangle defined in the `locations` property.
|
||||
|
||||
### `playerName`
|
||||
Matches if the player name is in the `names` property.
|
||||
|
||||
### `permission`
|
||||
Matches if the player has a permission in the `permissions` property.
|
||||
Loading…
Add table
Add a link
Reference in a new issue