📎
1 file
5,526 chars
📄
pasted-code-1772651857292.txt
txt
420 lines
▶
pasted-code-1772651857292.txt
txt
420 lines
Create a high-performance Minecraft Spigot/Paper plugin (Java) named RTP.
Target Platform:
- Java 21
- Spigot / Paper 1.21+
- Must support modern Paper async APIs
- Designed for large servers with minimal CPU and RAM usage
The plugin must be stable, optimized, and production-ready.
---
CORE GOAL
Provide a fully configurable Random Teleport system with:
• INVENTORY GUI teleport menu
• command teleport
• teleport warmup
• movement cancel
• combat protection
• cooldown system
• blocklisted worlds
• safe teleport detection
• async teleport generation
• anti-freeze protection
• safe structure spawning
• config reload command
• optimized chunk loading
The RTP system must never freeze or lag the server.
---
MAIN COMMANDS
/rtp
/rtp
/rtp reload
Command behavior:
/rtp
→ Opens the RTP INVENTORY GUI
/rtp
→ Starts teleport warmup then RTP to that world
/rtp reload
→ Reloads:
• config.yml
• rtp_gui.yml
• blocklist.yml
Only OP players can use "/rtp reload".
---
BLOCKLIST SYSTEM
Create file:
blocklist.yml
Worlds listed here cannot be teleported to using "/rtp ".
Example:
blocked_worlds:
- slobby
- creative
Important:
Players can still be inside these worlds.
But "/rtp slobby" must be blocked.
---
COOLDOWN SYSTEM
Players must wait between RTP uses.
Default:
5 minutes
Configurable in config.yml.
Example:
cooldown_seconds: 300
Cooldown message must include remaining time.
---
TELEPORT WARMUP
Before teleporting, run a countdown timer.
Default:
5 seconds
Configurable.
Example:
teleport_timer_seconds: 5
timer_text: "&eTeleporting in &a{time}&e..."
Display countdown using ActionBar or MiniTitle.
---
MOVEMENT CANCEL
Teleport cancels if the player:
• moves to a different block (X or Z change)
Looking around does NOT cancel.
---
COMBAT SYSTEM
Players cannot RTP while in combat.
Combat triggers when:
• player damages another player
• player is damaged by another player
Use:
EntityDamageByEntityEvent
Combat time configurable.
Example:
combat_seconds: 10
---
RTP INVENTORY GUI
Using "/rtp" with no arguments opens INVENTORY GUI.
INVENTORY GUI size:
3 rows (27 slots)
Example layout:
Slot 11 → Survival
Slot 13 → Nether
Slot 15 → End
Clicking an item starts RTP warmup.
---
INVENTORY GUI CONFIGURATION
Everything configurable in:
rtp_gui.yml
Example:
worlds:
Survival:
world: survival
material: GRASS_BLOCK
slot: 11
display_name: "&a&lSurvival"
lore:
- "&8Teleport Location"
- ""
- "&7Click here to randomly teleport"
- "&7to somewhere in Survival"
- ""
- "HFF97&l➥ CLICK TO TELEPORT"
Nether:
world: world_nether
material: NETHERRACK
slot: 13
display_name: "&c&lNether"
End:
world: world_the_end
material: END_STONE
slot: 15
display_name: "&e&lThe End"
Server owners must be able to modify:
• slot
• material
• display name
• lore
• world
---
RTP RANGE
Overworld:
X: -8000 → 8000
Z: -8000 → 8000
Nether:
X: -1000 → 1000
Z: -1000 → 1000
End:
X: -8000 → 8000
Z: -8000 → 8000
---
END WORLD RULE
The RTP location must never be near the main End island.
Players must spawn on outer islands (End City region).
---
SAFE TELEPORT SYSTEM
The plugin must always find safe teleport locations.
Safety checks:
• highest safe block
• avoid lava
• avoid water spawn
• avoid air spawn
• avoid spawning inside blocks
• ensure solid ground
Also avoid unsafe terrain:
• lava lakes
• ocean spawn
• cliffs without ground
• deep caves
---
ANTI FREEZE / PERFORMANCE SYSTEM
The RTP system must include:
Max attempt protection:
max_attempts: 20
If safe location fails:
Try new coordinates.
Never allow infinite loops.
---
ASYNC TELEPORT SYSTEM
Use Paper asynchronous chunk loading.
Example:
Use async chunk loading APIs when generating RTP locations.
Goal:
• avoid main thread blocking
• reduce lag spikes
---
ANTI STUCK SYSTEM
Ensure RTP never causes players to:
• spawn in blocks
• spawn underground
• spawn in caves
• fall into lava
• spawn in ocean
---
AFTER TELEPORT EFFECTS
After teleport completes:
Show Title message with coordinates.
Example:
X: {x} | Y: {y} | Z: {z}
Configurable:
title:
enabled: true
text: "&aX: {x} &f| &aY: {y} &f| &aZ: {z}"
---
DARKNESS EFFECT
Apply Darkness effect after teleport.
Default:
2 seconds
Configurable.
darkness_duration_seconds: 2
---
SOUND EFFECT
Play TNT explosion sound after teleport.
---
CHAT MESSAGE
Example message:
[RTP] You got RTP to (x y z) in
Configurable:
chat:
prefix: "&7[&aRTP&7]"
message: "&fYou got RTP to &a({x} {y} {z}) &fin &e{world}"
---
CONFIG FILE
Example config.yml:
teleport_timer_seconds: 5
cooldown_seconds: 300
combat_seconds: 10
darkness_duration_seconds: 2
max_attempts: 20
teleport_ranges:
survival:
min: -8000
max: 8000
nether:
min: -1000
max: 1000
end:
min: -8000
max: 8000
---
FILES TO GENERATE
Provide full code including:
• Main plugin class
• RTP command system
• Reload command
• Teleport warmup manager
• Combat tag system
• Cooldown manager
• Movement cancel listener
• INVENTORY GUI manager
• Random teleport generator
• Safe location finder
• Async chunk loader
• Blocklist system
• Inventory click listener
• Config loaders
Also generate:
plugin.yml
config.yml
rtp_gui.yml
blocklist.yml
---
plugin.yml example
name: RTP
version: 1.0
main: your.package.RTP
api-version: 1.21
commands:
rtp:
description: Random teleport command
Kodari can make mistakes. Review important code before using.
Files
No files in this session
Code