Skip to content

Commit 88a3701

Browse files
committed
more configurable regear command behavior for /rg vs /regear
1 parent 128051d commit 88a3701

5 files changed

Lines changed: 97 additions & 10 deletions

File tree

COMMANDS.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@ The following table outlines each command, its usage, aliases, and permissions r
4646
| `heal` | `N/A` | `perplayerkit.heal` |
4747
| `repair` | `N/A` | `perplayerkit.repair` |
4848

49+
## Regear Command Details
50+
51+
The regear system allows players to restock items from their loaded kit. The behavior of the `/rg` and `/regear` commands can be configured independently:
52+
53+
### Modes
54+
55+
**Command Mode**: Directly restocks whitelisted items from the player's loaded kit
56+
- Cooldown applies between uses
57+
- Damage timer prevents regearing while in combat
58+
- Only whitelisted items are restocked
59+
60+
**Shulker Mode**: Gives the player a regear shulker box
61+
- Player places the shulker on the ground to open a special interface
62+
- Player clicks the regear shell inside to trigger the restock
63+
- Cooldown applies between command uses
64+
- Damage timer prevents regearing while in combat
65+
66+
### Configuration
67+
68+
Both `/rg` and `/regear` can use different modes. See **CONFIG.md****Regear Command** for configuration options (`rg-mode` and `regear-mode`).
69+
4970
## Permissions
5071

5172
The following table outlines each top-level permission and the sub-permissions it grants.

CONFIG.md

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,12 @@ anti-exploit:
203203

204204
### **Regear Command**
205205

206-
Allows customization of the regear command which is used on some servers in various competition formats.
206+
Allows customization of the regear commands which are used on some servers in various competition formats. The `/rg` and `/regear` commands can be configured independently to use different modes.
207207

208208
```yaml
209209
regear:
210-
mode: "command" #OPTIONS: command, shulker
210+
rg-mode: "command" #OPTIONS: command, shulker - Behavior for /rg command
211+
regear-mode: "command" #OPTIONS: command, shulker - Behavior for /regear command
211212
command-cooldown: 5 #command cooldown in seconds. recommended to be low or 0 if using shulker mode.
212213
damage-timer: 5 #time in seconds to wait after taking damage before players can regear
213214
allow-while-using-elytra: true #set false to block regearing command while using elytra
@@ -224,8 +225,27 @@ regear:
224225
- OBSIDIAN
225226
- GLOWSTONE
226227
- RESPAWN_ANCHOR
228+
```
229+
230+
#### Regear Mode Options:
231+
232+
- **command**: Directly restocks items from the player's loaded kit (only whitelisted items are restocked)
233+
- **shulker**: Gives the player a physical regear shulker box that they can place and interact with
234+
235+
#### Example Configurations:
227236

237+
**Both commands use same mode:**
238+
```yaml
239+
regear:
240+
rg-mode: "command"
241+
regear-mode: "command"
242+
```
228243

244+
**Different modes for different commands:**
245+
```yaml
246+
regear:
247+
rg-mode: "shulker" # /rg gives a shulker
248+
regear-mode: "command" # /regear directly restocks items
229249
```
230250

231251

@@ -240,18 +260,40 @@ feature:
240260
set-hunger-on-kit-load: false
241261
set-saturation-on-kit-load: false
242262
remove-potion-effects-on-kit-load: false
243-
263+
244264
heal-on-enderchest-load: false
245265
feed-on-enderchest-load: false
246266
set-saturation-on-enderchest-load: false
247267
remove-potion-effects-on-enderchest-load: false
248-
268+
249269
rekit-on-respawn: true
250270
rekit-on-kill: false
251-
271+
272+
broadcast-kit-messages: true #broadcasts when a player loads a kit or enderchest
273+
252274
broadcast-on-player-action: true #broadcasts when a player uses a kit, copies a kit, etc.
253-
275+
254276
send-update-message-on-join: true #sends a message to players with perplayerkit.admin when they join the server if a new version is available
255-
277+
256278
old-death-drops: false #makes it so players drop items in a condensed area rather than spreading out when they die
257279
```
280+
281+
#### Feature Flag Descriptions:
282+
283+
**Kit Loading Features:**
284+
- **rekit-on-respawn**: Automatically loads the player's last used kit when they respawn after death
285+
- **rekit-on-kill**: Automatically loads the player's last used kit when they kill another player
286+
- **broadcast-kit-messages**: Controls whether broadcast messages are sent when players load kits or enderchesets (e.g., "Player loaded a kit"). When set to `false`, these specific kit-loading broadcast messages are suppressed
287+
288+
**Action Broadcast Features:**
289+
- **broadcast-on-player-action**: Controls whether broadcast messages are sent for other player actions like copying kits, repairing gear, opening kit room, etc. This does NOT affect kit loading messages (controlled by `broadcast-kit-messages`)
290+
291+
**Health/Hunger Features:**
292+
- **set-health-on-kit-load**: Sets player health to full when loading a kit
293+
- **set-hunger-on-kit-load**: Sets player hunger to full when loading a kit
294+
- **set-saturation-on-kit-load**: Sets player saturation to full when loading a kit
295+
- **remove-potion-effects-on-kit-load**: Removes all potion effects when loading a kit
296+
- **heal-on-enderchest-load**: Sets player health to full when loading an enderchest
297+
- **feed-on-enderchest-load**: Sets player hunger to full when loading an enderchest
298+
- **set-saturation-on-enderchest-load**: Sets player saturation to full when loading an enderchest
299+
- **remove-potion-effects-on-enderchest-load**: Removes all potion effects when loading an enderchest

src/main/java/dev/noah/perplayerkit/commands/RegearCommand.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,17 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
6464
return true;
6565
}
6666

67-
if (plugin.getConfig().getString("regear.mode", "command").equalsIgnoreCase("shulker")) {
67+
// Determine which mode to use based on the command label
68+
String effectiveMode;
69+
if (label.equalsIgnoreCase("rg")) {
70+
effectiveMode = plugin.getConfig().getString("regear.rg-mode", "command");
71+
} else if (label.equalsIgnoreCase("regear")) {
72+
effectiveMode = plugin.getConfig().getString("regear.regear-mode", "command");
73+
} else {
74+
effectiveMode = plugin.getConfig().getString("regear.rg-mode", "command"); // Default fallback
75+
}
76+
77+
if (effectiveMode.equalsIgnoreCase("shulker")) {
6878
int slot = player.getInventory().firstEmpty();
6979
if (slot == -1) {
7080
BroadcastManager.get().sendComponentMessage(player, MiniMessage.miniMessage().deserialize("<red>Your inventory is full, can't give you a regear shulker!"));
@@ -77,7 +87,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
7787
return true;
7888
}
7989

80-
if (plugin.getConfig().getString("regear.mode", "command").equalsIgnoreCase("command")) {
90+
if (effectiveMode.equalsIgnoreCase("command")) {
8191
int slot = KitManager.get().getLastKitLoaded(player.getUniqueId());
8292

8393
if (slot == -1) {

src/main/java/dev/noah/perplayerkit/util/BroadcastManager.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ public static Component generateBroadcastComponent(String message) {
6868
return MiniMessage.miniMessage().deserialize(formattedMessage);
6969
}
7070

71+
private boolean isKitLoadingMessage(MessageKey key) {
72+
return key == MessageKey.PLAYER_LOADED_PRIVATE_KIT ||
73+
key == MessageKey.PLAYER_LOADED_PUBLIC_KIT ||
74+
key == MessageKey.PLAYER_LOADED_ENDER_CHEST;
75+
}
76+
7177
private void broadcastMessage(Player player, String message, String permission) {
7278
World world = player.getWorld();
7379

@@ -95,6 +101,11 @@ private void broadcastMessage(Player player, BroadcastManager.MessageKey key, Co
95101
return;
96102
}
97103

104+
// Check if this is a kit loading message and if kit message broadcasts are disabled
105+
if (isKitLoadingMessage(key) && !plugin.getConfig().getBoolean("feature.broadcast-kit-messages", true)) {
106+
return;
107+
}
108+
98109
if (cooldownManager != null && cooldownManager.isOnCooldown(player)) {
99110
return;
100111
}

src/main/resources/config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ anti-exploit:
138138

139139

140140
regear:
141-
mode: "command" #OPTIONS: command, shulker
141+
rg-mode: "command" #OPTIONS: command, shulker
142+
regear-mode: "command" #OPTIONS: command, shulker
142143
command-cooldown: 5 #command cooldown in seconds. recommended to be low or 0 if using shulker mode.
143144
damage-timer: 5 #time in seconds to wait after taking damage before players can regear
144145
allow-while-using-elytra: true #set false to block regearing command while using elytra
@@ -185,6 +186,8 @@ feature:
185186
rekit-on-respawn: true
186187
rekit-on-kill: false
187188

189+
broadcast-kit-messages: true #broadcasts when a player loads a kit (applies to both kits and enderchesets)
190+
188191
broadcast-on-player-action: true #broadcasts when a player uses a kit, copies a kit, etc.
189192

190193
send-update-message-on-join: true #sends a message to players with perplayerkit.admin when they join the server if a new version is available

0 commit comments

Comments
 (0)