Spigot Plugin

OfflineTP

Create a production-ready Minecraft Paper/Spigot 1.21+ plugin called OfflineTP. Command /tpoffline <player> Functionality When a player runs the command, save the sender’s current location. The target player may be offline. The next time the target joins, teleport them to the saved location instantly. After teleporting once, automatically remove the queued teleport. Requirements Permission: offlinetp.use Sender message: Teleport queued for <player>. Join message: You have been teleported. Store queued teleports in a YAML file that persists through restarts. Use UUIDs, not player names.

Read the full description

Support multiple queued teleports. Prevent errors if the world no longer exists. Clean, optimized, commented Java code. Include plugin.yml. Fully functional and production-ready. op only please

src/main/java/eu/codexe/offlinetp/OfflineTPPlugin.java
package eu.codexe.offlinetp;

import eu.codexe.offlinetp.commands.TpOfflineCommand;
import eu.codexe.offlinetp.listeners.PlayerJoinListener;
import eu.codexe.offlinetp.managers.TeleportQueueManager;
import eu.codexe.offlinetp.storage.YamlTeleportStorage;
import eu.codexe.offlinetp.utils.MessageUtil;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

public final class OfflineTPPlugin extends JavaPlugin {

    private MessageUtil messageUtil;
    private TeleportQueueManager teleportQueueManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        this.messageUtil = new MessageUtil(this);
        this.teleportQueueManager = new TeleportQueueManager(this, new YamlTeleportStorage(this));

        teleportQueueManager.load();

        PluginCommand command = getCommand("tpoffline");
        if (command != null) {
            TpOfflineCommand executor = new TpOfflineCommand(this, teleportQueueManager);
            command.setExecutor(executor);
            command.setTabCompleter(executor);
        }

        getServer().getPluginManager().registerEvents(new PlayerJoinListener(teleportQueueManager, messageUtil), this);
    }

    @Override
    public void onDisable() {
        if (teleportQueueManager != null) {
            teleportQueueManager.save();
        }
    }

    public MessageUtil getMessageUtil() {
        return messageUtil;
    }
}