sxnnyy_69
📎 1 file 4,993 chars
📄
pasted-code-1785741807860.txt
txt 407 lines
▶
# CustomTPA Plugin (Paper 1.21.8+)

You are an expert Java developer specializing in Minecraft Paper plugins.

Create a professional, lightweight, production-ready Paper plugin called **CustomTPA**.

## General Requirements

* Plugin Name: CustomTPA
* Java 21
* Paper API 1.21.8+ (compatible with newer Paper versions)
* Build Tool: Gradle (Kotlin DSL)
* Package: `me.customtpa`
* No dependencies (do NOT require EssentialsX or any other plugin)
* No database
* Store data in memory only
* Optimized for large servers
* No memory leaks
* No lag
* Fully commented code
* Generate a complete Gradle project that compiles without errors.

---

# Commands

Only implement these commands.

```
/tpa 

/tpaccept

/tpcancel
```

There must be NO other commands.

Do NOT create:

* /tpdeny
* /tpahere
* /tptoggle
* /back
* /spawn
* /home
* /warp

Only the three commands above.

---

# /tpa

When a player executes:

```
/tpa Steve
```

A teleport request is sent.

The target receives:

```
━━━━━━━━━━━━━━━━━━━━━━

PlayerName wants to teleport to you.

✔ Click to Accept

✖ Type /tpcancel to decline

━━━━━━━━━━━━━━━━━━━━━━
```

Requirements:

* Accept button must be clickable.
* Hover text:
  "Click to accept teleport request."

The requester receives:

```
Teleport request sent to Steve.
```

---

# Request Timeout

Teleport requests expire after:

60 seconds

If expired:

Requester:

```
Your teleport request expired.
```

Receiver:

```
Teleport request from Player expired.
```

Automatically remove expired requests.

---

# Cooldown

After sending a request:

The sender cannot send another request for:

10 minutes

Cooldown begins immediately after using /tpa.

Message:

```
You must wait 10 minutes before sending another teleport request.
```

Display remaining time in minutes and seconds.

Example:

```
Cooldown: 8m 12s remaining.
```

Cooldown must persist until it expires, even if the request is accepted or cancelled.

---

# /tpaccept

When accepted:

Do NOT teleport instantly.

Instead:

Start a 5-second teleport countdown.

Action Bar (ONLY):

```
Teleporting in 5...
```

Blue text.

No title.

No subtitle.

No chat spam.

No sounds.

No boss bar.

No particles.

No scoreboard.

Only a small blue action bar countdown.

Example:

```
Teleporting in 5...

Teleporting in 4...

Teleporting in 3...

Teleporting in 2...

Teleporting in 1...
```

After countdown:

Teleport requester to the target.

---

# Teleport Cancellation

Cancel teleport immediately if the requester:

Moves from their current block (changes X or Z block position)

Gets damaged

Damages another entity

Is hit by a player

Is hit by a mob

Shoots a bow

Throws a projectile

Uses an ender pearl

Leaves the server

Dies

Changes worlds

If cancelled:

Action bar disappears.

Chat:

```
Teleport cancelled.
```

No teleport occurs.

---

# /tpcancel

This command serves two purposes:

If you SENT a request:

Cancel your outgoing request.

If you RECEIVED a request:

Decline the incoming request.

Messages:

Sender:

```
Teleport request cancelled.
```

Receiver:

```
Teleport request declined.
```

---

# Multiple Requests

Each player may only have:

One outgoing request.

One incoming request.

No duplicate requests.

Prevent spam.

---

# Messages

Create messages.yml.

Every message must be configurable.

Support MiniMessage color format.

---

# Sounds

Default:

Disabled.

Config option:

```
sounds:
  enabled: false
```

---

# Config.yml

```
cooldown: 600

request-expire: 60

teleport-delay: 5

cancel-on-move: true

cancel-on-damage: true

cancel-on-hit: true

cancel-on-attack: true

cancel-on-projectile: true

cancel-on-world-change: true
```

---

# Permissions

```
customtpa.use
customtpa.reload
```

Default:

Everyone has `customtpa.use`.

---

# Reload Command

Do NOT create a reload command.

---

# Performance

Do NOT check every tick.

Use Paper events.

Efficient scheduled countdown task only during active teleports.

Support 300+ players without lag.

---

# Code Structure

Create separate classes:

Main

CommandManager

TPACommand

TPAcceptCommand

TPCancelCommand

RequestManager

CooldownManager

TeleportTask

MessageManager

ConfigManager

ActionBarUtil

PlayerListener

Utility classes

---

# Build Output

Generate the COMPLETE plugin project.

Include:

* All Java source files
* plugin.yml
* config.yml
* messages.yml
* build.gradle.kts
* settings.gradle.kts
* Gradle wrapper
* README.md

The project must compile successfully with Gradle and produce a working Paper plugin JAR without any missing classes or TODO placeholders.
Kodari AI
KodariAug 3 at 7:25 am 2
CustomTPA
CustomTPA provides a lightweight, memory-only teleport request system for Paper 1.21.8 and newer servers. Players can send, accept, and cancel teleport requests with configurable MiniMessage formatting, clickable acceptance prompts, request expiration, cooldowns, and delayed teleport countdowns. Teleports automatically cancel when players move, take damage, attack, use projectiles, change worlds, die, or leave the server. All behavior is configured through config.yml and messages.yml.
  1. Create the Gradle project, Paper plugin metadata, configuration files, wrapper files, and README.

  2. Implement request, cooldown, messaging, teleport countdown, command, and listener systems.

  3. Connect all components through the main plugin class with only /tpa, /tpaccept, and /tpcancel.

Kodari can make mistakes. Review important code before using.
Files
gradle
src
build.gradle.kts
gradle.properties
gradlew
gradlew.bat
README.md
settings.gradle.kts
Code
25 1,278
src/main/java/me/customtpa/CustomTPA.java
package me.customtpa;

import me.customtpa.command.CommandManager;
import me.customtpa.config.ConfigManager;
import me.customtpa.listener.PlayerListener;
import me.customtpa.message.MessageManager;
import me.customtpa.request.RequestManager;
import me.customtpa.teleport.TeleportManager;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

/**
 * Main entry point for the CustomTPA plugin.
 */
public final class CustomTPA extends JavaPlugin {
    private ConfigManager configManager;
    private MessageManager messageManager;
    private RequestManager requestManager;
    private TeleportManager teleportManager;

    /**
     * Initializes managers and registers the plugin commands and events.
     */
    @Override
    public void onEnable() {
        this.configManager = new ConfigManager(this);
        this.messageManager = new MessageManager(this);
        this.requestManager = new RequestManager(this, this.configManager, this.messageManager);
        this.teleportManager = new TeleportManager(this, this.configManager, this.messageManager);

        new CommandManager(this, this.configManager, this.messageManager, this.requestManager, this.teleportManager)
                .registerCommands();

        Bukkit.getPluginManager().registerEvents(
                new PlayerListener(this.configManager, this.requestManager, this.teleportManager),
                this
        );
    }

    /**
     * Cancels active tasks and clears in-memory request data during shutdown.
     */
    @Override
    public void onDisable() {
        if (this.teleportManager != null) {
            this.teleportManager.cancelAll(false);
        }
        if (this.requestManager != null) {
            this.requestManager.clear();
        }
    }
}