xavier.6996

Plugin Name: LastLocation Minecraft Versions: 1.21+ (tested on 1.21.1) Java Version: 21

Description / Goal: Create a plugin that automatically teleports players to their last world whenever they join a server or switch worlds. If the last world was slobby, teleport them to the slobby spawn set by an admin. For all other worlds, automatically execute a Multiverse teleport command (/mvtp) as the player to return them to that world. Works regardless of join method (direct join, Velocity, NPCs, etc.).

Features / Requirements:

  1. 1.

Detect Last World:

- When a player joins the server:

- Check which world they were in last (stored in Multiverse format: e.g., ll:survival, ll:slobby_nether).

- If the world is slobby, teleport them to the slobby spawn.

- If the world is any other world, execute /mvtp ll:<world_name> as the player to send them to that world.

  1. 2.

Slobby Spawn Management:

- Admin command /setslobby to set the spawn point of slobby.

  1. 3.

Force Teleport as Player:

- Ensure /mvtp runs as the player, not the console, so permissions or teleport issues do not block the process.

  1. 4.

Optional Commands (Admin / Debugging):

- /lastlocation reload — reload plugin config.

- /lastlocation info <player> — show last world stored for the player.

  1. 5.

Integration:

- Should work with Velocity or direct server join.

- NPC server commands are optional, the main focus is auto-world teleport on join.

Example Behavior:

  • Player joins the server:

- Last world was slobby → teleported to slobby spawn.

- Last world was survival → executes /mvtp ll:survival as the player.

- Last world was slobby_nether → executes /mvtp ll:slobby_nether as the player.

Goal: Automatically return players to their previous world when they join, handling slobby as a special spawn, using Multiverse commands executed as the player for seamless world restoration.

Kodari AI
KodariApr 5 at 5:11 pm 8,871 (v2)

I’ll create a plugin that automatically returns players to their last world on join, with special handling for the “slobby” spawn point.

LastLocation
Automatically teleports players to their last visited world when they join the server. Features special spawn handling for the "slobby" world with admin-configurable spawn point. For all other worlds, executes Multiverse teleport commands as the player to seamlessly restore their previous location. Includes admin commands for spawn management and player tracking.

Plugin created! LastLocation will:

  • Automatically save each player’s current world when they quit or change worlds

  • On join, teleport players to their last world after a 5-tick delay (configurable)

  • Special handling for “slobby” world: teleports to admin-configured spawn point

  • Other worlds: executes /mvtp ll:<worldname> as the player for seamless Multiverse integration

  • Admin commands: /setslobby to configure spawn, /lastlocation info <player> to check stored data, /lastlocation reload to refresh config

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
9 420
src/main/java/com/example/lastlocation/LastLocationPlugin.java
package com.example.lastlocation;

import com.example.lastlocation.commands.LastLocationCommand;
import com.example.lastlocation.commands.SetSlobbyCommand;
import com.example.lastlocation.listeners.PlayerListener;
import com.example.lastlocation.managers.ConfigManager;
import com.example.lastlocation.managers.DataManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class LastLocationPlugin extends JavaPlugin {
    
    private ConfigManager configManager;
    private DataManager dataManager;

    @Override
    public void onEnable() {
        this.saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        this.dataManager = new DataManager(this);
        
        Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this);
        
        this.getCommand("setslobby").setExecutor(new SetSlobbyCommand(this));
        this.getCommand("lastlocation").setExecutor(new LastLocationCommand(this));
        
        this.getLogger().info("LastLocation has been enabled!");
    }

    @Override
    public void onDisable() {
        if (this.dataManager != null) {
            this.dataManager.saveData();
        }
        this.getLogger().info("LastLocation has been disabled!");
    }
}