berkgp

create me a simple plugin that contains /tpa and features

Kodari AI
KodariApr 17 at 5:30 pm 10,874 (v2)
SimpleTPA
A lightweight teleport request plugin featuring /tpa, /tpahere, /tpaccept, /tpdeny, /tpacancel, and /tptoggle commands. Players can send teleport requests to others, accept or deny incoming requests, and toggle whether they receive requests. Includes configurable request timeout, warmup delay before teleporting, movement cancel on warmup, cooldown system, and formatted chat messages with color support.

Planning:

  • SimpleTPA main plugin class with managers registered

  • TPAManager handles all request logic, cooldowns, timeouts, warmup tasks

  • TPAListener cancels warmup on movement/damage

  • TPACommand handles all subcommands

  • MessageUtil for color formatting

  • config.yml with all tunable settings

  • plugin.yml with command registrations

SimpleTPA
A lightweight teleport request plugin featuring /tpa, /tpahere, /tpaccept, /tpdeny, /tpacancel, and /tptoggle commands. Players can send teleport requests to others, accept or deny incoming requests, and toggle whether they receive requests. Includes configurable request timeout, warmup delay before teleporting, movement cancel on warmup, cooldown system, and formatted chat messages with color support.

Here’s what was built:

Feature
Details
/tpa <player>
Send a teleport request to another player
/tpahere <player>
Request another player to come to you
/tpaccept [player]
Accept latest (or specific) request
/tpdeny [player]
Deny latest (or specific) request
/tpacancel
Cancel your outgoing request
/tptoggle
Toggle receiving requests on/off
Warmup
Configurable countdown before teleporting
Cancel on move/damage
Interrupts warmup if player moves or takes damage
Cooldown
Prevents spamming requests
Request timeout
Pending requests auto-expire
Sounds
Plays configurable sounds on request/accept/deny/teleport
Tab Completion
All player-argument commands support tab complete
Permission bypass
simpletpa.bypass.toggle
and
simpletpa.bypass.cooldown
for OPs

All values (timeout, warmup, cooldown, messages, sounds) are fully configurable in config.yml.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
9 821
src/main/java/com/simpletpa/SimpleTPA.java
package com.simpletpa;

import com.simpletpa.commands.TPACommand;
import com.simpletpa.listeners.TPAListener;
import com.simpletpa.manager.TPAManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

public class SimpleTPA extends JavaPlugin {

    @Getter
    private static SimpleTPA instance;

    @Getter
    private TPAManager tpaManager;

    @Override
    public void onEnable() {
        instance = this;
        saveDefaultConfig();
        this.tpaManager = new TPAManager(this);

        TPACommand cmd = new TPACommand(this);
        getCommand("tpa").setExecutor(cmd);
        getCommand("tpahere").setExecutor(cmd);
        getCommand("tpaccept").setExecutor(cmd);
        getCommand("tpdeny").setExecutor(cmd);
        getCommand("tpacancel").setExecutor(cmd);
        getCommand("tptoggle").setExecutor(cmd);

        getServer().getPluginManager().registerEvents(new TPAListener(this), this);
        getLogger().info("SimpleTPA enabled.");
    }

    @Override
    public void onDisable() {
        if (tpaManager != null) {
            tpaManager.cancelAll();
        }
        getLogger().info("SimpleTPA disabled.");
    }
}