Skip to content

Commit

Permalink
#610 Improved wiki.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shynixn committed Aug 30, 2024
1 parent 86fc9e0 commit 177a2fc
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 12 deletions.
45 changes: 45 additions & 0 deletions docs/wiki/docs/particleexample.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Selectable particle effects

This is a tutorial to get into building selectable parts for pets. It can also be used
to define selectable sounds, potion effects, etc.

## 1. Edit the pet template

Add a basic vanilla particle command as action to one of the loops. In this case the ``idle`` loop.

* Instead of absolute coordinates we use the pet coordinate placeholders.
* The placeholder ``%petblocks_js_mypart%`` is a custom placeholder defined by you, which stores the **currently selected particle**. You can also name it ``%petblocks_js_mysound%`` to store sound names for example.
* The condition checks if the placeholder can actually be resolved e.g. a particle has been set.

```yaml
loops:
idle:
actions:
- name: "Play particle effect"
condition:
type: STRING_NOT_CONTAINS
left: "%petblocks_js_mypart%"
right: "petblocks_js_mypart"
type: "COMMAND"
level: "SERVER"
run:
- "/particle %petblocks_js_mypart% %petblocks_pet_locationX% %petblocks_pet_locationY% %petblocks_pet_locationZ%"
```
## 2. Adjust vanilla command settings
A vanilla command may automatically log to the console and to the chat of every op player. You can disable the output for op players using vanilla game rules such as ``gamerule sendCommandFeedback false``, ``/gamerule logAdminCommands false``, ``/gamerule commandBlockOutput false``. If you want to hide the output in your console, you need to install a LogFilter plugin.
## 3. Check if it works ingame
Execute the following commands and take a look if the pet displays heart particles.
```
/petblocks reload
/petblocks variable pet mypart heart
```

## 4. GUI buttons

Open the GUI of petblocks or your favourite GUI plugin and add a button where the command ``/petblocks variable pet mypart heart %petblocks_owner_name%`` is executed with server level permissions.
You can add more particles by creating new buttons with new commands e.g. ``/petblocks variable pet mypart angry_villager %petblocks_owner_name%``
13 changes: 3 additions & 10 deletions docs/wiki/docs/receivingpets.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@
Once you have setup the permission, join your server. The PetBlocks default configuration creates a pet
with template ``classic`` for you and makes it spawn in front of you. If you cannot see the pet, try executing ``/petblocks call pet`` or review your permissions again.


**Make sure your players have this permission to see their pet:**
```
petblocks.pet.spawn
petblocks.pet.amount.1
```

The next step is to decide, how you want your players to receive a pet. There are multiple options below.

## Receiving a pet on first join

This is enabled per default and can be changed in the ``config.yml`` under ``pet/receivePetsOnJoin``. This creates a new database entry for each joining player, regardless if he has the spawn permission or not.
The player requires the minimum ``petblocks.pet.spawn`` to see their pet.
!!! note "Important"
Make sure you have given your players the minimum required permissions before you continue.

This is enabled per default and can be changed in the ``config.yml`` under ``pet/receivePetsOnJoin``. This creates a new database entry for each joining player, regardless if he has the spawn permission or not.
If you want to receive no pets on join and unlock pets later own (e.g. for shops or VIP perks), change this to:

```
Expand All @@ -38,7 +32,6 @@ pet:
In order to configure, if the pet should automatically spawn in front of the player on creation, open the template
``plugins/PetBlocks/pets/pet_classic.yml``. Set ``pet/spawned`` to ``true`` or ``false``.


## Receiving pets using a shop

There are many ways how you can handle it. These are just examples below:
Expand Down
2 changes: 2 additions & 0 deletions docs/wiki/docs/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ Actions can optionally have conditions, which support the following types:
* ``STRING_EQUALS``
* ``STRING_NOT_EQUALS``
* ``STRING_CONTAINS``
* ``STRING_NOT_CONTAINS``
* ``STRING_EQUALS_IGNORE_CASE``
* ``STRING_NOT_EQUALS_IGNORE_CASE``
* ``NUMBER_GREATER_THAN``
Expand Down
3 changes: 2 additions & 1 deletion docs/wiki/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ nav:
- 'PetBlocks Wiki':
- Introduction: README.md
- Permission: permission.md
- Giving pets to players: receivingpets.md
- Commands: commands.md
- Giving Pets to Players: receivingpets.md
- Templates: template.md
- GUI: gui.md
- PlaceHolders: placeholders.md
- Custom Models: custommodels.md
- Selectable particle effects: particleexample.md
- Developer Api: api.md
- 'FAQ': faq.md
theme:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.github.shynixn.petblocks.enumeration
enum class PetActionConditionType {
NONE,
STRING_EQUALS,
STRING_CONTAINS,
STRING_NOT_CONTAINS,
STRING_NOT_EQUALS,
STRING_EQUALS_IGNORE_CASE,
STRING_NOT_EQUALS_IGNORE_CASE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,32 @@ class PetActionExecutionServiceImpl @Inject constructor(
}

return conditionResult
} else {
}
else if (conditionType == PetActionConditionType.STRING_CONTAINS) {
val conditionResult = leftEscaped.contains(rightEscaped)

if (action.debug) {
plugin.logger.log(
Level.INFO,
"End evaluating condition, $leftEscaped contains $rightEscaped -> ${conditionResult}."
)
}

return conditionResult
}
else if (conditionType == PetActionConditionType.STRING_NOT_CONTAINS) {
val conditionResult = !leftEscaped.contains(rightEscaped)

if (action.debug) {
plugin.logger.log(
Level.INFO,
"End evaluating condition, $leftEscaped not contains $rightEscaped -> ${conditionResult}."
)
}

return conditionResult
}
else {
val leftNumber = leftEscaped.toDoubleOrNull()

if (leftNumber == null) {
Expand Down

0 comments on commit 177a2fc

Please sign in to comment.