Skip to content

Commit df1040e

Browse files
committed
add configurable delay for rekit-on-respawn
Adds rekit-on-respawn-delay config option (in ticks) to delay kit re-application on respawn. Useful when other plugins give items on respawn. Default is 0 (instant, unchanged behavior).
1 parent 8ecdac9 commit df1040e

4 files changed

Lines changed: 20 additions & 1 deletion

File tree

CONFIG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ feature:
321321
remove-potion-effects-on-enderchest-load: false
322322
323323
rekit-on-respawn: true
324+
rekit-on-respawn-delay: 0 #delay in ticks before re-applying kit on respawn (20 ticks = 1 second)
324325
rekit-on-kill: false
325326
326327
broadcast-kit-messages: true #broadcasts when a player loads a kit or enderchest
@@ -336,6 +337,7 @@ feature:
336337

337338
**Kit Loading Features:**
338339
- **rekit-on-respawn**: Automatically loads the player's last used kit when they respawn after death
340+
- **rekit-on-respawn-delay**: Delay in ticks before re-applying the kit on respawn (20 ticks = 1 second). Useful if another plugin gives items on respawn. Default: `0` (instant)
339341
- **rekit-on-kill**: Automatically loads the killer's last used kit when they kill another player. See [Rekit on Kill Configuration](#rekit-on-kill-configuration) for advanced options
340342
- **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
341343

SIMPLE_SETUP_GUIDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ feature:
122122
```yaml
123123
feature:
124124
rekit-on-respawn: true
125+
rekit-on-respawn-delay: 0 #delay in ticks (20 ticks = 1 second). useful if another plugin gives items on respawn.
125126
```
126127
127128
### Disable Kits in Certain Worlds:

src/main/java/dev/noah/perplayerkit/listeners/AutoRekitListener.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.bukkit.event.entity.PlayerDeathEvent;
2727
import org.bukkit.event.player.PlayerRespawnEvent;
2828
import org.bukkit.plugin.Plugin;
29+
import org.bukkit.scheduler.BukkitRunnable;
2930

3031
import java.util.List;
3132

@@ -48,7 +49,21 @@ public void onRespawn(PlayerRespawnEvent e) {
4849
return;
4950
}
5051

51-
KitManager.get().loadLastKit(e.getPlayer());
52+
long delay = plugin.getConfig().getLong("feature.rekit-on-respawn-delay", 0);
53+
Player player = e.getPlayer();
54+
55+
if (delay <= 0) {
56+
KitManager.get().loadLastKit(player);
57+
} else {
58+
new BukkitRunnable() {
59+
@Override
60+
public void run() {
61+
if (player.isOnline()) {
62+
KitManager.get().loadLastKit(player);
63+
}
64+
}
65+
}.runTaskLater(plugin, delay);
66+
}
5267
}
5368

5469
@EventHandler

src/main/resources/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ feature:
184184
heal-remove-effects: false #makes the /heal command remove potion effects in addition to healing
185185

186186
rekit-on-respawn: true
187+
rekit-on-respawn-delay: 0 #delay in ticks before re-applying kit on respawn (20 ticks = 1 second). useful if another plugin gives items on respawn.
187188
rekit-on-kill:
188189
enabled: false
189190
# World filtering based on killer's current world

0 commit comments

Comments
 (0)