On using the setrespawn a msg will show up in the chat for the command runner respawn set
📎
1 file
2,511 chars
📄
pasted-code-1772639051192.txt
txt
145 lines
▶
pasted-code-1772639051192.txt
txt
145 lines
Create a Minecraft Spigot/Paper plugin (Java) named DeathLocation.
Compatibility:
- Paper / Spigot 1.20+
- Java 17
Purpose:
When a player dies in the world named "survival", they should not respawn directly at the respawn location.
Instead, the plugin must first force the respawn to a random safe location within a 100 × 100 area in the survival world, and then very quickly teleport the player to the configured respawn location.
The entire process should happen extremely fast (under 1 second) so the player barely notices the intermediate location.
---
COMMAND
/setrespawn
Rules:
- Only OP players can run this command.
- Saves the player's current location as the respawn location.
Save in "config.yml":
world
x
y
z
yaw
pitch
Example:
respawn:
world: survival
x: 100
y: 65
z: -200
yaw: 0
pitch: 0
---
RESPAWN LOGIC
Trigger:
Player dies in world "survival".
Process:
1. Player respawns.
2. Plugin calculates a random location inside a 100 × 100 square area centered around world spawn (or configurable center).
3. X and Z must be randomly selected between:
-100 → +100
4. Find the highest safe block using the world height map so the player spawns on the surface.
Safety requirements:
- Must not spawn in caves.
- Must not spawn underground.
- Must spawn on solid ground.
- Must not spawn inside blocks.
If the location is unsafe:
- Retry another random location.
5. Teleport the player to this temporary random surface location.
6. Immediately after (within 1 tick or a few ticks), teleport the player to the /setrespawn location.
The player should barely see the temporary position.
---
PERFORMANCE REQUIREMENT
- The random location search must be very fast.
- Use efficient checks.
- Entire process should complete within 1 second.
---
WORLD RESTRICTION
This system should ONLY activate when the player dies in world "survival".
If player dies in any other world:
- Do nothing.
---
NO MESSAGES
The plugin must be completely silent.
Do NOT show:
- chat messages
- titles
- action bars
- bossbars
- console spam
---
EVENTS
Use:
PlayerRespawnEvent
Optional:
Bukkit scheduler to delay the second teleport 1–5 ticks.
---
FILES TO GENERATE
Provide full code including:
Main plugin class
Respawn listener
Random safe location generator
/setrespawn command
config.yml
plugin.yml
---
plugin.yml example
name: DeathLocation
version: 1.0
main: your.package.DeathLocation
api-version: 1.20
commands:
setrespawn:
description: Set respawn location
KodariMar 4 at 3:45 pm 10,561 (v2)
I’ll create a fast death location plugin that teleports players through a temporary random location.
DeathLocation
A performance-focused respawn system for Paper/Spigot 1.20+ that redirects player respawns in the survival world through a temporary random safe surface location before instantly teleporting them to a configured respawn point. Features OP-only /setrespawn command to set the final respawn location. The entire process completes within 1 second with no chat spam or visual notifications.
Now I’ll create the complete plugin structure:
Plugin created successfully with all required features:
Key Implementation:
Player dies in “survival” world → respawns at random safe location within -100 to +100 range → teleports to configured location after 2 ticks (~0.1 seconds)
/setrespawnsaves current location and displays “respawn set” message (OP only)Fast location finder with 50 attempt limit, avoids unsafe blocks (lava, magma, fire, cactus)
Completely silent operation except for the setrespawn confirmation message
Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
7 244
src/main/java/com/example/deathlocation/DeathLocation.java
package com.example.deathlocation;
import com.example.deathlocation.commands.SetRespawnCommand;
import com.example.deathlocation.listeners.RespawnListener;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class DeathLocation extends JavaPlugin {
@Override
public void onEnable() {
saveDefaultConfig();
getCommand("setrespawn").setExecutor(new SetRespawnCommand(this));
getServer().getPluginManager().registerEvents(new RespawnListener(this), this);
}
@Override
public void onDisable() {
saveConfig();
}
}