priyanshu_2010
📎 1 file 10,295 chars
📄
pasted-code-1790247158152.txt
txt 573 lines
▶
Create a complete, production-ready Minecraft server plugin for **Paper 1.21.11**.

The plugin should provide a professional **TPA + RTP + Spawn + Manual Announcement** system designed for an SMP server.

The plugin MUST support both **Java Edition and Bedrock Edition players through GeyserMC + Floodgate**.

Use modern APIs appropriate for Paper 1.21.11 and avoid outdated NMS unless absolutely necessary.

---

# 1. TPA SYSTEM

Add the following commands:

`/tpa `

`/tpahere `

`/tpaccept`

`/tpdeny`

`/tpacancel`

### TPA Configuration

```yaml
tpa:
  enabled: true
  request-expiration: 60
  teleport-delay: 5
  cooldown: 30
```

### Behaviour

`/tpa ` sends a teleport request to another player.

`/tpahere ` requests the target player to teleport to the sender.

`/tpaccept` accepts the latest incoming request.

`/tpdeny` denies the latest incoming request.

`/tpacancel` cancels the player's outgoing request.

Requests automatically expire after the configured expiration time.

### Teleport Safety

During the teleport countdown:

* Player must remain still.
* Moving cancels the teleport.
* Taking damage cancels the teleport.
* Disconnecting cancels the teleport.
* Dying cancels the teleport.

Example:

`&eTeleporting in &c5 &eseconds...`

Cancellation:

`&cTeleport cancelled because you moved.`

### Permissions

```text
plugin.tpa
plugin.tpahere
plugin.tpaccept
plugin.tpadeny
plugin.tpacancel
```

Add optional bypass permissions for:

* TPA cooldown
* Teleport delay

---

# 2. RANDOM TELEPORT / RTP

Add:

`/rtp`

RTP must work in all three Minecraft dimensions:

* Overworld
* Nether
* End

When a player uses `/rtp`, teleport them to a random safe location in their **current dimension**.

Do not automatically change the player's dimension.

### RTP Configuration

```yaml
rtp:
  enabled: true

  cooldown: 60
  warmup: 3

  min-distance: 500
  max-distance: 5000

  dimensions:
    overworld: true
    nether: true
    end: true

  attempts: 20
```

### RTP Settings

* Cooldown: **60 seconds**
* Warmup: **3 seconds**
* Minimum distance: **500 blocks**
* Maximum distance: **5000 blocks**
* Maximum location attempts: configurable
* Overworld enabled
* Nether enabled
* End enabled

### Safe Location Detection

Never teleport a player into:

* Lava
* Fire
* Void
* Solid blocks
* Dangerous locations
* Locations without enough space

Check the destination before completing the teleport.

The plugin should efficiently search for a safe location without causing server lag.

### RTP Warmup

When RTP starts:

`&eRandom teleporting in &c3 &eseconds...`

If the player moves:

`&cRTP cancelled because you moved.`

Also cancel RTP if:

* Player takes damage
* Player dies
* Player disconnects

### RTP Cooldown

After a successful RTP, the player must wait **60 seconds** before using RTP again.

If they try too early:

`&cYou must wait &e%time% &cbefore using RTP again.`

### RTP Permissions

```text
plugin.rtp
plugin.rtp.bypass
```

`plugin.rtp.bypass` bypasses the RTP cooldown.

---

# 3. SPAWN SYSTEM

Add:

`/spawn`

The command teleports the player to the configured server spawn.

### Spawn Configuration

```yaml
spawn:
  enabled: true
  warmup: 3
  cancel-on-move: true
  cancel-on-damage: true
```

### Spawn Behaviour

* `/spawn` has **no cooldown**.
* Warmup is **3 seconds**.
* Moving during warmup cancels the teleport.
* Taking damage cancels the teleport.
* Disconnecting cancels the teleport.
* Check that the spawn destination is valid.
* `/spawn` must work for Java and Bedrock players.

Example:

`&eTeleporting to spawn in &c3 &eseconds...`

On movement:

`&cTeleport cancelled because you moved.`

On damage:

`&cTeleport cancelled because you took damage.`

On successful teleport:

`&aTeleported to spawn!`

If spawn has not been configured:

`&cThe server spawn has not been configured yet.`

---

# 4. SET SPAWN

Add:

`/setspawn`

ONLY administrators should be able to use `/setspawn`.

Normal players must NOT be able to use it.

Permission:

`plugin.setspawn`

Save the complete spawn location:

* World
* X
* Y
* Z
* Yaw
* Pitch

The spawn location must remain saved after server restarts.

---

# 5. MANUAL ANNOUNCEMENT SYSTEM

Announcements must be **MANUAL ONLY**.

Do NOT create:

* Automatic announcements
* Announcement scheduling
* Announcement intervals
* Rotating automatic messages

The owner/admin should decide when an announcement is sent.

### Announcement Command

Add:

`/announce `

Example:

`/announce Server restart in 10 minutes!`

Broadcast:

`&6&lANNOUNCEMENT &8» &fServer restart in 10 minutes!`

Another example:

`/announce &c&lSERVER &8» &fA special event will begin soon!`

Support:

* `&` color codes
* Hex colors if supported
* PlaceholderAPI placeholders

### Permission

```text
plugin.announce
```

Only players with this permission can use `/announce`.

### Announcement Reload

Add:

`/announce reload`

Permission:

```text
plugin.announce.admin
```

This reloads announcement-related configuration.

There must be **no automatic announcement system**.

---

# 6. GEYSER + FLOODGATE COMPATIBILITY

The entire plugin MUST support:

**Java Edition + Bedrock Edition through GeyserMC and Floodgate.**

All features must work for Bedrock players:

* `/tpa`
* `/tpahere`
* `/tpaccept`
* `/tpdeny`
* `/tpacancel`
* `/rtp`
* `/spawn`
* `/announce`

Do not require:

* Bedrock client mods
* Bedrock addons
* Client-side modifications
* Special resource packs

Use the Floodgate API safely when detecting Bedrock players.

Do not assume every player is a Java player.

Player UUID handling must work correctly with Floodgate.

Teleport requests must work correctly between:

* Java → Java
* Java → Bedrock
* Bedrock → Java
* Bedrock → Bedrock

---

# 7. LUCKPERMS SUPPORT

Use standard Bukkit/Paper permissions so the plugin works correctly with **LuckPerms**.

Do not hard-code rank names.

Permissions should be configurable where practical.

The plugin must still work without LuckPerms installed.

---

# 8. PLACEHOLDERAPI SUPPORT

If PlaceholderAPI is installed, support placeholders in configurable messages.

Examples:

`%player_name%`

`%player_displayname%`

`%vault_eco_balance%`

PlaceholderAPI should be optional.

If PlaceholderAPI is not installed, the plugin must continue working normally.

---

# 9. CONFIGURATION

Use clean configuration files such as:

```text
config.yml
messages.yml
```

All important settings should be configurable.

The owner should be able to change:

* TPA request expiration
* TPA cooldown
* TPA teleport delay
* RTP cooldown
* RTP warmup
* RTP minimum distance
* RTP maximum distance
* RTP dimensions
* RTP attempts
* Spawn warmup
* Spawn behaviour
* Messages
* Permissions where appropriate

Do not create unnecessary configuration options.

---

# 10. ADMIN RELOAD

Create:

`/plugin reload`

Permission:

`plugin.admin.reload`

The command should reload all plugin configuration files without requiring a server restart.

Success message:

`&aPlugin configuration successfully reloaded!`

If a configuration contains an error:

* Do not crash the server.
* Log the exact problem to console.
* Keep valid existing configuration where possible.

---

# 11. COMMAND TAB COMPLETION

Add proper tab completion for all commands.

Examples:

`/tpa `

`/tpahere `

`/tpaccept`

`/tpdeny`

`/tpacancel`

`/announce`

`/announce reload`

`/plugin reload`

Only suggest online players where appropriate.

---

# 12. PERFORMANCE

The plugin must be optimized for a multiplayer SMP server.

For RTP:

* Do not perform expensive searches that freeze the main server thread.
* Use efficient asynchronous processing where safe.
* Return teleport operations to the main server thread when required by the Paper API.
* Avoid excessive chunk loading.
* Limit RTP location attempts.
* Handle unloaded chunks safely.

The plugin must not create unnecessary lag.

---

# 13. SECURITY AND EXPLOIT PREVENTION

Prevent:

* TPA request spam
* TPA request abuse
* Teleport exploits
* RTP exploits
* Command abuse
* Permission bypasses

Add appropriate cooldowns and request limits.

Players should not be able to manipulate another player's teleport request.

---

# 14. CODE QUALITY

Create a complete **production-ready Java plugin**.

Include:

* Complete project structure
* `plugin.yml`
* Main plugin class
* Command classes
* Tab completers
* TPA manager
* RTP manager
* Spawn manager
* Announcement manager
* Configuration manager
* Event listeners
* Permission handling
* Geyser/Floodgate integration
* Optional LuckPerms integration if required
* Optional PlaceholderAPI integration
* Proper logging
* Error handling

Use clean object-oriented architecture.

Avoid unnecessary dependencies.

Use modern Paper 1.21.11 APIs.

---

# 15. FINAL REQUIREMENT

The final plugin must compile successfully for:

**Paper Minecraft 1.21.11**

It should be designed specifically for a multiplayer SMP server.

Required compatibility:

* Paper 1.21.11
* GeyserMC
* Floodgate
* LuckPerms
* PlaceholderAPI

Optional integrations must fail gracefully if they are not installed.

The final result should feel like a polished **Donut-SMP-style utility plugin**, with:

* Fast and reliable TPA
* Safe RTP
* 500–5000 block RTP range
* 60-second RTP cooldown
* 3-second RTP warmup
* All 3 dimensions supported
* 3-second spawn warmup
* No spawn cooldown
* Admin-only `/setspawn`
* Manual `/announce`
* No automatic announcements
* Full Java + Bedrock compatibility

Provide **all source code and required project files** needed to compile the plugin into a `.jar`.

Make sure there are no missing classes, undefined methods, compilation errors, or incomplete sections.
Kodari AI
KodariSep 24 at 10:58 am 4
TravelCore
A comprehensive SMP utility plugin providing TPA, RTP, Spawn, and manual announcement systems with full Java and Bedrock (Geyser/Floodgate) compatibility. Features configurable teleport requests with expiration, cooldowns, and safety checks; dimension-aware random teleportation with safe location detection; spawn management with admin-only setspawn; and manual announcement broadcasting with color and placeholder support. Includes optional PlaceholderAPI integration, LuckPerms compatibility, async RTP processing, and complete reload functionality.
  1. Set up the Paper 1.21.11 Gradle project and configurable defaults/messages.

  2. Implement shared teleport safety/countdown, TPA requests, and bounded RTP search.

  3. Add persistent spawn, manual announcements, optional integrations, and command/tab handling.

  4. Wire permissions, lifecycle, and plugin metadata.

Created the Paper 1.21.11 Java 21 project with TPA, safe asynchronous RTP in the player’s current dimension, persistent spawn, manual announcements, reload commands, permissions, and tab completion. Floodgate and PlaceholderAPI integrations are optional; player handling uses Bukkit UUIDs and standard permissions, so LuckPerms works without becoming a dependency.

The project files are in place. I did not run a local build.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
16 1,429
src/main/java/com/kodari/smputilities/SmpUtilitiesPlugin.java
package com.kodari.smputilities;

import com.kodari.smputilities.command.UtilityCommand;
import com.kodari.smputilities.integration.BedrockDetector;
import com.kodari.smputilities.manager.RtpManager;
import com.kodari.smputilities.manager.SpawnManager;
import com.kodari.smputilities.manager.TeleportManager;
import com.kodari.smputilities.manager.TpaManager;
import com.kodari.smputilities.message.MessageService;
import com.kodari.smputilities.util.ConfigManager;
import com.kodari.smputilities.listener.TeleportListener;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public final class SmpUtilitiesPlugin extends JavaPlugin {
    private ConfigManager configManager;
    private MessageService messages;
    private TeleportManager teleportManager;
    private TpaManager tpaManager;
    private RtpManager rtpManager;
    private SpawnManager spawnManager;
    private BedrockDetector bedrockDetector;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        if (!getDataFolder().exists() && !getDataFolder().mkdirs()) {
            getLogger().severe("Could not create the plugin data directory.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        if (!new java.io.File(getDataFolder(), "messages.yml").exists()) {
            saveResource("messages.yml", false);
        }

        configManager = new ConfigManager(this);
        configManager.reloadAll();
        messages = new MessageService(this, configManager);
        teleportManager = new TeleportManager(this, messages, configManager);
        tpaManager = new TpaManager(this, messages, configManager, teleportManager);
        rtpManager = new RtpManager(this, messages, configManager, teleportManager);
        spawnManager = new SpawnManager(this, messages, configManager, teleportManager);
        bedrockDetector = new BedrockDetector(this);

        getServer().getPluginManager().registerEvents(
                new TeleportListener(teleportManager, tpaManager, rtpManager), this);

        UtilityCommand commandHandler = new UtilityCommand(this, messages, configManager,
                teleportManager, tpaManager, rtpManager, spawnManager);
        for (String name : new String[]{"tpa", "tpahere", "tpaccept", "tpdeny", "tpacancel",
                "rtp", "spawn", "setspawn", "announce", "plugin"}) {
            PluginCommand command = getCommand(name);
            if (command == null) {
                getLogger().severe("Command '" + name + "' is missing from plugin.yml.");
                getServer().getPluginManager().disablePlugin(this);
                return;
            }
            command.setExecutor(commandHandler);
            command.setTabCompleter(commandHandler);
        }

        getLogger().info("SmpUtilities enabled. Floodgate detected: "
                + getServer().getPluginManager().isPluginEnabled("floodgate")
                + "; PlaceholderAPI detected: "
                + getServer().getPluginManager().isPluginEnabled("PlaceholderAPI") + ".");
    }

    @Override
    public void onDisable() {
        if (teleportManager != null) teleportManager.shutdown();
        if (tpaManager != null) tpaManager.shutdown();
        if (rtpManager != null) rtpManager.shutdown();
    }

    public boolean reloadPluginConfiguration() {
        return configManager.reloadAll();
    }

    public boolean reloadAnnouncementConfiguration() {
        return configManager.reloadMessages();
    }

    public boolean isBedrockPlayer(java.util.UUID uuid) {
        return bedrockDetector != null && bedrockDetector.isBedrockPlayer(uuid);
    }
}