Yet-Another-World-Protector icon indicating copy to clipboard operation
Yet-Another-World-Protector copied to clipboard

feat: trigger system for entities leaving/entering a region

Open Z0rdak opened this issue 3 years ago • 2 comments

Description

Note: Everything laid out here is just a first draft, how exactly this feature will be implemented might change

To handle players entering and leaving regions, a trigger-like system (optimal with events) would be handy.

Beside other things, this system would allow it to display the region name or other messages to the player when entering/leaving a region. It also could be extended to execute commands or do other things.

This feature will be based on #181

Trigger types

There are two types of Trigger: PlayerTrigger and EntityTrigger

With three different TriggerConditions: Enter, Leave, Both

  • A region can have multiple triggers for each of these types.
  • A trigger can invoke an action/actions.
  • Triggers can be modified with filters
  • Triggers can be activated and deactivated for easier managemen.

PlayerTrigger

Only triggers when a player enter or leaves a region. Can be modified by a filter.

The filter allows for filtering for players within a certain group.

EntityTrigger

Triggers when a entity enter or leaves a region. Can be modified by a filter.

The filter allows filtering for a specific EntityType, Name or Tag of the Entity.

Actions

An action is a defined command which will be executed when a trigger is activated. Examples for (predefined) triggers are: - displaying a text - sending a message to a player - changing the gamemode - executing a command (very general and covers the above-mentioned ones, but they are there for convenience) - log event to console - ...

  • Actions have an order, they are executed in this order to ensure consistency. The order is determined by an integer.
  • Actions can be activated and deactivated for easier managemen.

Command-Syntax

The syntax could be the following (here for local regions):

  • /wp trigger <dim> <region> add trigger <player|entity> <leave|enter|both> <trigger-name> [filter]

  • /wp trigger <dim> <region> remove trigger <trigger-name>

  • /wp trigger <dim> <region> enable trigger <trigger-name>

  • /wp trigger <dim> <region> disable trigger <trigger-name>

  • /wp trigger <dim> <region> list trigger

  • /wp trigger <dim> <region> list actions <trigger-name>

  • /wp trigger <dim> <region> add action <trigger-name> exec <cmd> <order>

  • /wp trigger <dim> <region> add action <trigger-name> title <title> <subtitle> <order>

  • /wp trigger <dim> <region> add action <trigger-name> msg <msg> <order>

  • /wp trigger <dim> <region> add action <trigger-name>... ... <order>

  • /wp trigger <dim> <region> order action <trigger-name> <order>

  • /wp trigger <dim> <region> enable action <orderPos>

  • /wp trigger <dim> <region> disable action <orderPos>

  • /wp trigger <dim> <region> remove action <orderPos>

Considerations

  • For easier management a pagination for trigger and actions should be considered.
  • Triggers are only applicable for Local Regions and Dimensional Regions
  • Exclude specific players from tracking?

Z0rdak avatar Aug 13 '22 10:08 Z0rdak

Suggestion from Discord: Trigger for playing music when entering region

Z0rdak avatar Oct 06 '24 18:10 Z0rdak

Updated Feature description

Z0rdak avatar Oct 29 '24 18:10 Z0rdak