Skip to content

Commit

Permalink
Merge pull request BetonQuest#2575 from Wolf2323/stage
Browse files Browse the repository at this point in the history
Added stage event, objective and conditions.
  • Loading branch information
SaltyAimbOtter authored Nov 5, 2023
2 parents ecbfecb + 3a04e88 commit c1cdc01
Show file tree
Hide file tree
Showing 13 changed files with 751 additions and 82 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- `npcinteract` objective - now supports the argument `interaction` to choose between left, right or both clicks
- `log` event
- `party` event - new range 0 and -1 to select players in the same world or server wide
- `stage` objective, condition and event
- Things that are also added in 1.12.X:
- new line support for `journal_lore` in `messages.yml`
- FastAsyncWorldEdit compatibility
Expand Down
19 changes: 18 additions & 1 deletion docs/Documentation/Scripting/Building-Blocks/Conditions-List.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ This condition checks the players moon cycle (1 is full moon, 8 is Waxing Gibbou
## Number compare: `numbercompare`

This condition compares two numbers.
The valid operations are: `<`, `<=`, `=`, `>=`, `>`.
The valid operations are: `<`, `<=`, `=`, `!=`, `>=`, `>`.

!!! example
```YAML
Expand Down Expand Up @@ -435,6 +435,23 @@ Sneak condition is only true when the player is sneaking. This would probably be
```YAML
sneak
```

## Check Stage: `stage`
This condition compares the players current stage with the given stage by its index numbers.
For more take a look at the [stage objective](./Objectives-List.md#stages-stage).
The valid operations are: `<`, `<=`, `=`, `!=`, `>=`, `>`.

| Parameter | Syntax | Default Value | Explanation |
|-------------------|------------|------------------------|------------------------------------------|
| _stage objective_ | Objective | :octicons-x-circle-16: | The name of the stage objective |
| _comparator_ | Comparator | :octicons-x-circle-16: | The comparator to use for the comparison |
| _stage_ | Stage | :octicons-x-circle-16: | The name of the stage to compare |

```YAML title="Example"
conditions:
isDeliverCookies: "stage bakeCookies = deliverCookies"
isDeliverCookiesOrAbove: "stage bakeCookies > cookCookies"
```

## Tag: `tag`

Expand Down
22 changes: 22 additions & 0 deletions docs/Documentation/Scripting/Building-Blocks/Events-List.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,28 @@ Very powerful if used to trigger redstone contraptions.
setblock REDSTONE_BLOCK 100;200;300;world
setblock SAND 100;200;300;world ignorePhysics
```

## Modify Stage: `stage`
You can `set`, `increase` or `decrease` the player's stage. The objective will not automatically complete when using `set`.
By increasing it the player will be able to complete the objective. When increasing or decreasing the stage
you can optionally specify an amount to increase or decrease by.
When decreasing the objective it will do nothing when the first stage is reached.
When the conditions of the stage objective are not met, the stage of the player can not be modified.
For more take a look at the [stage objective](./Objectives-List.md#stages-stage).

| Parameter | Syntax | Default Value | Explanation |
|-------------------|---------------------------------|------------------------|-------------------------------------------------|
| _stage objective_ | Objective | :octicons-x-circle-16: | The name of the stage objective |
| _action_ | `set`, `increase` or `decrease` | :octicons-x-circle-16: | The action to perform |
| _stage_ | Stage | :octicons-x-circle-16: | The name of the stage to set when `set` is used |
| _amount_ | Number | 1 | The amount to increase or decrease by |

```YAML title="Example"
events:
setCookCookies: "stage bakeCookies set cookCookies"
increase: "stage bakeCookies increase"
decrease2: "stage bakeCookies decrease 2"
```

## Spawn Mob: `spawn`

Expand Down
58 changes: 44 additions & 14 deletions docs/Documentation/Scripting/Building-Blocks/Objectives-List.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ give accurate results. Experiment with this objective a bit to make sure you've

To complete this objective the player must break or place the specified amount of blocks.

| Parameter | Syntax | Default Value | Explanation |
|-----------------|---------------------------------------------------|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Parameter | Syntax | Default Value | Explanation |
|-----------------|------------------------------------------------------|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| _Block Type_ | [Block Selector](../Data-Formats.md#block-selectors) | :octicons-x-circle-16: | The block which must be broken / placed. |
| _Amount_ | Number | :octicons-x-circle-16: | The amount of blocks to break / place. Less than 0 for breaking and more than 0 for placing blocks. |
| _Safety Check_ | Keyword (`noSafety`) | Safety Check Enabled | The Safety Check prevents faking the objective. The progress will be reduced when the player does to opposite of what they are supposed to do. Example: Player must break 10 blocks. They place 10 of their stored blocks. Now the total amount of blocks to break is 20. |
| _Notifications_ | Keyword (`notify`) | Disabled | Displays messages to the player each time they progress the objective. Optionally with the notification interval after colon. |
| _Amount_ | Number | :octicons-x-circle-16: | The amount of blocks to break / place. Less than 0 for breaking and more than 0 for placing blocks. |
| _Safety Check_ | Keyword (`noSafety`) | Safety Check Enabled | The Safety Check prevents faking the objective. The progress will be reduced when the player does to opposite of what they are supposed to do. Example: Player must break 10 blocks. They place 10 of their stored blocks. Now the total amount of blocks to break is 20. |
| _Notifications_ | Keyword (`notify`) | Disabled | Displays messages to the player each time they progress the objective. Optionally with the notification interval after colon. |


```YAML
Expand Down Expand Up @@ -210,11 +210,11 @@ objectives:

<h5> Variable Properties </h5>

| Name | Example Output | Explanation |
|--------------|---------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
| _left_ | 23 days 5 hours 45 minutes 17 seconds | Shows the time left until the objective is completed. |
| Name | Example Output | Explanation |
|--------------|---------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|
| _left_ | 23 days 5 hours 45 minutes 17 seconds | Shows the time left until the objective is completed. |
| _date_ | 17.04.2022 16:14 | Shows the date the objective is completed at using the config's `date_format` [setting](../../Configuration/Configuration.md#misc-settings). |
| _rawSeconds_ | 5482 | Shows the amount of seconds until objective completion. |
| _rawSeconds_ | 5482 | Shows the amount of seconds until objective completion. |


## Death: `die`
Expand All @@ -233,13 +233,13 @@ add them right after type of objective.

Requires the player to catch something with the fishing rod. It doesn't have to be a fish, it can also be any other item.

| Parameter | Syntax | Default Value | Explanation |
|-----------------|---------------------------------------------------------------------|------------------------|------------------------------------------------------------------------------------------------------------------------|
| Parameter | Syntax | Default Value | Explanation |
|-----------------|------------------------------------------------------------------------|------------------------|------------------------------------------------------------------------------------------------------------------------|
| _item_ | [Block Selector](../Data-Formats.md#block-selectors) | :octicons-x-circle-16: | The item that must be caught. |
| _amount_ | Any Number | :octicons-x-circle-16: | The amount that must be caught. |
| _notifications_ | notify:number | notify:0 | Add `notify` to display a notification when a fish is caught. Optionally with the notification interval after a colon. |
| _amount_ | Any Number | :octicons-x-circle-16: | The amount that must be caught. |
| _notifications_ | notify:number | notify:0 | Add `notify` to display a notification when a fish is caught. Optionally with the notification interval after a colon. |
| _hookLocation_ | hookLocation:[Location](../Data-Formats.md#unified-location-formating) | Everywhere | The location at which the item must be caught. Range must also be defined. |
| _range_ | range:number | Everywhere | The range around the `hookLocation`. |
| _range_ | range:number | Everywhere | The range around the `hookLocation`. |



Expand Down Expand Up @@ -473,6 +473,36 @@ This objective has three properties: `amount`, `left` and `total`. `amount` is t
smeltIron: "smelt ironIngot 5 events:reward"
```

## Stages: `stage`
The Stage objective is a special objective that can be used to track the progress of a quest or a part of a quest.
It can be completed in two ways, the first one is by increasing the stage more than there are stages defined
and the second one is by completing the objective with the [objective event](./Events-List.md#objective-objective).
The behaviour of completing the objective by increasing the stage can be disabled by setting the `preventCompletion` flag.

When the conditions of the stage objective are not met, the stage of the player can not be modified.
You can modify the stages with the [stage event](./Events-List.md#modify-stage-stage) and check it's state with the [stage condition](./Conditions-List.md#check-stage-stage).

| Parameter | Syntax | Default Value | Explanation |
|---------------------|---------------------|------------------------|----------------------------------------------------------------------|
| _stages_ | List of stage names | :octicons-x-circle-16: | The stages that must be completed. |
| _preventCompletion_ | Keyword | Completion Enabled | Prevents the objective from being completed by increasing the stage. |

```YAML title="Example"
objectives:
questProgress: "stage part1,part2,part3"
bakeCookies: "stage collectIngredients,cookCookies,deliverCookies preventCompletion"
```

<h5> Variable Properties </h5>

| Name | Example Output | Explanation |
|------------|--------------------|--------------------------------------------------------------------------------|
| _index_ | 2 | The index of the players current stage beginning at 1. |
| _current_ | cookCookies | The current stage name of the player or empty if the objective is not active. |
| _next_ | deliverCookies | The next stage name of the player or empty if the objective is not active. |
| _previous_ | collectIngredients | The previous stage name of the player or empty if the objective is not active. |


## Step on pressure plate: `step`

To complete this objective the player has to step on a pressure plate at a given location. The type of plate does not
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/betonquest/betonquest/BetonQuest.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import org.betonquest.betonquest.conditions.RideCondition;
import org.betonquest.betonquest.conditions.ScoreboardCondition;
import org.betonquest.betonquest.conditions.SneakCondition;
import org.betonquest.betonquest.conditions.StageCondition;
import org.betonquest.betonquest.conditions.TagCondition;
import org.betonquest.betonquest.conditions.TestForBlockCondition;
import org.betonquest.betonquest.conditions.TimeCondition;
Expand Down Expand Up @@ -196,6 +197,7 @@
import org.betonquest.betonquest.objectives.RideObjective;
import org.betonquest.betonquest.objectives.ShearObjective;
import org.betonquest.betonquest.objectives.SmeltingObjective;
import org.betonquest.betonquest.objectives.StageObjective;
import org.betonquest.betonquest.objectives.StepObjective;
import org.betonquest.betonquest.objectives.TameObjective;
import org.betonquest.betonquest.objectives.VariableObjective;
Expand Down Expand Up @@ -239,6 +241,7 @@
import org.betonquest.betonquest.quest.event.random.PickRandomEventFactory;
import org.betonquest.betonquest.quest.event.scoreboard.ScoreboardEventFactory;
import org.betonquest.betonquest.quest.event.setblock.SetBlockEventFactory;
import org.betonquest.betonquest.quest.event.stage.StageEventFactory;
import org.betonquest.betonquest.quest.event.sudo.OpSudoEventFactory;
import org.betonquest.betonquest.quest.event.sudo.SudoEventFactory;
import org.betonquest.betonquest.quest.event.tag.TagGlobalEventFactory;
Expand Down Expand Up @@ -870,6 +873,7 @@ public void onEnable() {
registerConditions("effect", EffectCondition.class);
registerConditions("rating", ArmorRatingCondition.class);
registerConditions("sneak", SneakCondition.class);
registerConditions("stage", StageCondition.class);
registerConditions("random", RandomCondition.class);
registerConditions("journal", JournalCondition.class);
registerConditions("testforblock", TestForBlockCondition.class);
Expand Down Expand Up @@ -923,6 +927,7 @@ public void onEnable() {
registerNonStaticEvent("weather", new WeatherEventFactory(loggerFactory, getServer(), getServer().getScheduler(), this));
registerEvents("folder", FolderEvent.class);
registerEvent("setblock", new SetBlockEventFactory(getServer(), getServer().getScheduler(), this));
registerNonStaticEvent("stage", new StageEventFactory(this));
registerNonStaticEvent("damage", new DamageEventFactory(loggerFactory, getServer(), getServer().getScheduler(), this));
registerNonStaticEvent("party", new PartyEventFactory(loggerFactory));
registerEvents("clear", ClearEvent.class);
Expand Down Expand Up @@ -968,6 +973,7 @@ public void onEnable() {
registerObjectives("arrow", ArrowShootObjective.class);
registerObjectives("experience", ExperienceObjective.class);
registerObjectives("step", StepObjective.class);
registerObjectives("stage", StageObjective.class);
registerObjectives("logout", LogoutObjective.class);
registerObjectives("login", LoginObjective.class);
registerObjectives("password", PasswordObjective.class);
Expand Down
Loading

0 comments on commit c1cdc01

Please sign in to comment.