Add ability to define cooldowns for actions (#437)

This commit is contained in:
William authored and GitHub committed 2023-06-16 17:39:54 +01:00
1 parent fb052340c0
commit fc8d3b0098
52 files changed
+1140 -619

No files matched your search

+8 -10
View File
@@ -109,19 +109,17 @@ These permissions allow you to make a home public/private (toggling its privacy)
<details>
<summary>Cooldown, warmup and economy bypasses</summary>
<summary>Bypass teleport warmup, cooldowns & economy checks</summary>
These permissions let you bypass teleportation warmup checks, rtp cooldown checks and economy checks
These permissions let you bypass teleportation warmup checks, cooldown, and economy checks
| Description | Permission | Default |
|--------------------------------------------|-----------------------------------------|:-------:|
| Bypass timed teleportation warmups&dagger; | `huskhomes.bypass_teleport_warmup` | Not set |
| Bypass economy checks | `huskhomes.bypass_economy_checks` | Not set |
| Bypass the cooldown on `/rtp`&ddagger; | `huskhomes.command.rtp.bypass_cooldown` | ❌ |
| Description | Permission | Default |
|--------------------------------------------|------------------------------------|:-------:|
| Bypass timed teleportation warmups&dagger; | `huskhomes.bypass_teleport_warmup` | Not set |
| Bypass [cooldown checks](cooldowns) | `huskhomes.bypass_cooldowns` | Not set |
| Bypass [economy checks](economy-hook) | `huskhomes.bypass_economy_checks` | Not set |
&dagger;This is not effective when the teleport warmup time is set `<= 0` in the config file.
&ddagger;This is not effective when the /rtp cooldown time is set `<= 0` in the config file.
&dagger;This is not effective when the teleport warmup time is set to `<= 0` in the config file.
</details>
<details>
+60 -18
View File
@@ -16,15 +16,19 @@ This page contains the configuration structure for HuskHomes.
# ┃ HuskHomes Config ┃
# ┃ Developed by William278 ┃
# ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
# ┣╸ Information: https://william278.net/project/huskhomes
# ┗╸ Documentation: https://william278.net/docs/huskhomes
# ┣╸ Information: https://william278.net/project/huskhomes/
# ┣╸ Config Help: https://william278.net/docs/huskhomes/config-files/
# ┗╸ Documentation: https://william278.net/docs/huskhomes/
# Locale of the default language file to use. Docs: https://william278.net/docs/huskhomes/translations
language: en-gb
# Whether to automatically check for plugin updates on startup
check_for_updates: true
database:
# Database connection settings
# Type of database to use (MYSQL, SQLITE)
type: SQLITE
mysql:
credentials:
# Specify credentials here if you are using MYSQL as your database type
host: localhost
port: 3306
database: HuskHomes
@@ -32,85 +36,123 @@ database:
password: pa55w0rd
parameters: ?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8
connection_pool:
# MySQL connection pool properties
# MYSQL database Hikari connection pool properties. Don't modify this unless you know what you're doing!
size: 12
idle: 12
lifetime: 1800000
keepalive: 30000
timeout: 20000
# Names of tables to use on your database. Don't modify this unless you know what you're doing!
table_names:
home_data: huskhomes_homes
position_data: huskhomes_position_data
warp_data: huskhomes_warps
saved_position_data: huskhomes_saved_positions
player_cooldowns_data: huskhomes_user_cooldowns
home_data: huskhomes_homes
teleport_data: huskhomes_teleports
player_data: huskhomes_users
saved_position_data: huskhomes_saved_positions
position_data: huskhomes_position_data
general:
# General plugin settings
# The maximum homes a user can create. Override with the huskhomes.max_homes.<number> permission.
max_homes: 10
# The maximum public homes a user can create. Override with the huskhomes.max_public_homes.<number> permission.
max_public_homes: 10
# Whether permission limits (i.e. huskhomes.max_homes.<number>) should stack if the user inherits multiple nodes.
stack_permission_limits: false
# Whether users require a permission (huskhomes.command.warp.<warp_name>) to use warps
permission_restrict_warps: false
# Whether running /sethome <name> or /setwarp <name> when a home/warp already exists should overwrite it.
overwrite_existing_homes_warps: true
# How long a player has to stand still and not take damage for when teleporting (in seconds)
teleport_warmup_time: 5
# Where the teleport warmup timer should display (CHAT, ACTION_BAR, TITLE, SUBTITLE or NONE)
teleport_warmup_display: ACTION_BAR
# How long before received teleport requests expire (in seconds)
teleport_request_expiry_time: 60
# Whether /tpahere should use the location of the sender when sent. Docs: https://william278.net/docs/huskhomes/strict-tpahere/
strict_tpa_here_requests: true
# Whether home or warp names should be case insensitive (i.e. allow /home HomeOne and /home homeone)
case_insensitive_names: false
# Whether home or warp names should allow UTF-8 characters (i.e. allow /home 你好)
allow_unicode_names: false
# Whether home or warp descriptions should allow UTF-8 characters
allow_unicode_descriptions: true
# Whether /back should work to teleport the user to where they died
back_command_return_by_death: true
# Whether /back should work with other plugins that use the PlayerTeleportEvent (this can cause conflicts)
back_command_save_teleport_event: false
# How many items should be displayed per-page in chat menu lists
list_items_per_page: 12
# Whether teleportation should be carried out asynchronously (ensuring chunks load before teleporting)
asynchronous_teleports: true
# Whether to play sound effects
play_sound_effects: true
# Which sound effects to play for various actions
sound_effects:
teleportation_complete: entity.enderman.teleport
teleport_request_received: entity.experience_orb.pickup
teleportation_cancelled: entity.item.break
teleportation_warmup: block.note_block.banjo
teleportation_complete: entity.enderman.teleport
teleport_request_received: entity.experience_orb.pickup
# Whether to provide modern, rich TAB suggestions for commands (if available)
brigadier_tab_completion: true
cross_server:
# Enable teleporting across proxied servers. Requires MySQL
# Enable teleporting across your proxy network. Requires database type to be MYSQL
enabled: false
# The type of message broker to use for cross-server communication. Options: PLUGIN_MESSAGE, REDIS
messenger_type: PLUGIN_MESSAGE
# Specify a common ID for grouping servers running HuskHomes on your proxy. Don't modify this unless you know what you're doing!
cluster_id: ''
global_spawn:
# Define a single global /spawn for your network via a warp. Docs: https://william278.net/docs/huskhomes/global-spawn/
enabled: false
# The name of the warp to use as the global spawn.
warp_name: Spawn
# Whether player respawn positions should work cross-server. Docs: https://william278.net/docs/huskhomes/global-respawning/
global_respawning: false
redis_credentials:
# Specify credentials here if you are using REDIS as your messenger_type. Docs: https://william278.net/docs/huskhomes/redis-support/
host: localhost
port: 6379
password: ''
use_ssl: false
rtp:
# Random teleport (/rtp) command settings
cooldown_length: 10
# Radius around the spawn point in which players cannot be random teleported to
radius: 5000
# Radius of the spawn area in which players cannot be random teleported to
spawn_radius: 500
# Mean of the normal distribution used to calculate the distance from the center of the world
distribution_mean: 0.75
# Standard deviation of the normal distribution used to calculate the distance from the center of the world
distribution_deviation: 2.0
# List of worlds in which /rtp is disabled. Please note that /rtp does not work well in the nether.
restricted_worlds:
- world_nether
- world_the_end
cooldowns:
# Whether to apply a cooldown between performing certain actions
enabled: true
# Set a cooldown between performing actions (in seconds). Docs: https://william278.net/docs/huskhomes/cooldowns/
cooldown_times:
random_teleport: 600
economy:
# Charge for certain actions (requires Vault)
# Enable economy plugin integration (requires Vault)
enabled: false
# Use this currency for payments (works only with RedisEconomy), defaults to Vault currency
redis_economy_name: vault
# Specify how many homes players can set for free, before they need to pay for more slots
free_home_slots: 5
# Require money to perform certain actions. Check https://william278.net/docs/huskhomes/economy-hook for available actions
# Charge money for perform certain actions. Docs: https://william278.net/docs/huskhomes/economy-hook/
costs:
additional_home_slot: 100.0
make_home_public: 50.0
additional_home_slot: 100.0
random_teleport: 25.0
map_hook:
# Display public homes/warps on your web map (supports Dynmap and BlueMap)
# Display public homes/warps on your Dynmap, BlueMap or Pl3xMap. Docs: https://william278.net/docs/huskhomes/map-hooks
enabled: true
# Show public homes on the web map
show_public_homes: true
# Show warps on the web map
show_warps: true
# Disabled commands (e.g. ['/home', '/warp'] to disable /home and /warp)
# List of commands to disable (e.g. ['/home', '/warp'] to disable /home and /warp)
disabled_commands: []
```
</details>
+46
View File
@@ -0,0 +1,46 @@
HuskHomes supports enforcing a cooldown against certain actions. Players must wait a certain amount of time between performing the action, otherwise the action will not be allowed. The cooldown will be enforced just before the action is performed, and the player will be notified of the remaining cooldown time if they attempt to perform the action before the cooldown has expired.
## Configuring cooldowns
Cooldowns can be configured in the `cooldowns` section of [`config.yml`](config-files). To enable cooldowns, set `enabled` to `true` and define `cooldown_times` for actions you want to apply cooldowns to. The cooldown time is an integer value, defined in seconds.
### Bypassing cooldowns
Players with the `huskhomes.bypass_cooldowns` [permission node](commands) bypass cooldowns and can perform them immediately.
### Table of actions
| Action | Description |
|---------------------------|-------------------------------------------------------------|
| `additional_home_slot` | When a user wants to buy another home slot |
| `make_home_public` | When a user wants to make their home public |
| `random_teleport` | When a user executes /rtp |
| `back_command` | When a user executes /back to return to their last position |
| `home_teleport` | When a user executes /home to teleport to a home |
| `public_home_teleport` | When a user uses /phome to teleport to a public home |
| `warp_teleport` | When a user uses /warp to teleport to a warp |
| `spawn_teleport` | When a user uses /spawn to teleport to spawn |
| `send_teleport_request` | When a user sends a teleport request |
| `accept_teleport_request` | When a user accepts an incoming teleport request |
### Example config
Cooldowns are defined under `cooldown_times` in the `cooldowns` section of [`config.yml`](config-files). By default, only a cooldown for `random_teleport` is defined. Add the other actions to this section of the file and associate a cooldown with them to enable them.
<details>
<summary>Defining cooldowns (config.yml)</summary>
```yaml
cooldowns:
# Whether to apply a cooldown between performing certain actions
enabled: true
# Set a cooldown between performing actions (in seconds). Docs: https://william278.net/docs/huskhomes/cooldowns/
costs:
additional_home_slot: 0
make_home_public: 0
random_teleport: 600
back_command: 0
home_teleport: 0
public_home_teleport: 0
warp_teleport: 0
spawn_teleport: 0
send_teleport_request: 0
accept_teleport_request: 0
```
</details>
+21 -14
View File
@@ -18,7 +18,7 @@ To enable the Economy Hook on Sponge server, you require a mod installed for man
</details>
### Bypassing economy checks
Players with the `huskhomes.bypass.economy` [permission node](commands) bypass economy checks and can perform economy actions without paying.
Players with the `huskhomes.bypass_economy_checks` [permission node](commands) bypass economy checks and can perform economy actions without paying.
## Home slots
With the economy hook enabled, players will need to pay for home slots beyond their initial "free" allotment.
@@ -31,7 +31,7 @@ You can configure the number of 'free home slots' a user gets using the `free_ho
You can set the economy cost for the following actions in the `costs` section of the `config.yml` file. Note that this section by default only has the `additional_home_slot`, `make_home_public` and `random_teleport` actions defined. Add the other actions to this section of the file and associate a price with them to enable them.
### Table of actions
| Economy Action | Description | Default Cost |
| Action | Description | Default Cost |
|---------------------------|-------------------------------------------------------------|-------------:|
| `additional_home_slot` | When a user wants to buy another home slot | `$100.00` |
| `make_home_public` | When a user wants to make their home public | `$50.00` |
@@ -46,21 +46,28 @@ You can set the economy cost for the following actions in the `costs` section of
### Example config
> **Warning:** You must specify a decimal monetary value in the config.yml. (i.e. `100.00` is valid, but `100` is not.)
Economy costs are defined under `costs` in the `economy` section of [`config.yml`](config-files).
<details>
<summary>Defining economy costs (config.yml)</summary>
```yaml
# Require money to perform certain actions. Check https://william278.net/docs/huskhomes/economy-hook for available actions
costs:
additional_home_slot: 100.0
make_home_public: 50.0
random_teleport: 25.0
back_command: 0.0
home_teleport: 0.0
public_home_teleport: 0.0
warp_teleport: 0.0
spawn_teleport: 0.0
send_teleport_request: 0.0
accept_teleport_request: 0.0
economy:
# Enable economy plugin integration (requires Vault)
enabled: true
# Charge money for perform certain actions. Docs: https://william278.net/docs/huskhomes/economy-hook/
costs:
additional_home_slot: 100.0
make_home_public: 50.0
random_teleport: 25.0
back_command: 0.0
home_teleport: 0.0
public_home_teleport: 0.0
warp_teleport: 0.0
spawn_teleport: 0.0
send_teleport_request: 0.0
accept_teleport_request: 0.0
```
</details>
+1
View File
@@ -14,6 +14,7 @@ Welcome to the plugin documentation for HuskHomes v4.x+, the powerful and intuit
* 📝 [[Translations]]
* 🟩 [[Plan Hook]]
* 🗺️ [[Map Hooks]]
* ⏰ [[Cooldowns]]
* 💵 [[Economy Hook]]
* ⚠️ [[Strict Tpahere]]
* 🚫 [[Restricted Warps]]
+1
View File
@@ -11,6 +11,7 @@
* 📝 [[Translations]]
* 🟩 [[Plan Hook]]
* 🗺️ [[Map Hooks]]
* ⏰ [[Cooldowns]]
* 💵 [[Economy Hook]]
* ⚠️ [[Strict Tpahere]]
* 🚫 [[Restricted Warps]]