itz_coolcat

make me 1.21.11 paper plugin that gives admins a dark red name with the word admin in front of it with the command (/admin playername) also a option to put players nametags to a certain color /desert to make them a tan username and /plains to make them a light green username and a /start command that teleport players to a certain cordinate in a config file where you can also set players usernames to teams without having them be in the game

Kodari AI
KodariJul 26 at 12:16 am 1
BiomeRegions
A Paper 1.21.11 plugin that manages player name colors and team assignments via scoreboard teams. Features include: /admin command to give players a dark red name with [Admin] prefix, /desert command for tan/gold name colors, /plains command for light green name colors, and /start command to teleport to a configurable location. Supports pre-assigning players to teams in config.yml for offline players.

I’ll create the full plugin structure now.

itz_coolcat

make two different start loations, one for desert, and one for plains but start at the same time and do not have admins teleport and have a command (/locationstart desert/plains (cordinates)) as an option for ingame

Kodari AI
KodariJul 26 at 12:28 am 1

Now I’ll implement all the changes. Let me update the files:

Now I’ll update all files. Let me do the config, plugin, main plugin class, start command, and create the new locationstart command.

itz_coolcat

its not teleporting us to the start location listed in the console config file and is only teleporting the person who uses the command cona you please fix that

Kodari AI
KodariJul 26 at 12:36 am 2

I see the issues. Let me fix everything:

  1. loadConfigValues() reads start-location but config has desert-start and plains-start

  2. /start only teleports the sender, not all non-admin players

  3. Need the /locationstart command to set locations in-game

Now I see the full picture. Here’s the fix:

  1. Config mismatch: loadConfigValues() reads start-location but config has desert-start and plains-start

  2. /start only teleports the sender, not all non-admin players

  3. Missing: /locationstart command to set locations in-game

Let me fix everything:

Now update /start to teleport all non-admin players to their team’s start location, and create the /locationstart command

Now create the /locationstart command and update plugin.yml:

Let me verify the final state of all changed files:

The filesystem is read-only — I need to use tags. Let me create the file properly:

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
10 507
src/main/java/com/example/biomeregions/BiomeRegionsPlugin.java
package com.example.biomeregions;

import com.example.biomeregions.command.AdminCommand;
import com.example.biomeregions.command.DesertCommand;
import com.example.biomeregions.command.PlainsCommand;
import com.example.biomeregions.command.StartCommand;
import com.example.biomeregions.listener.PlayerJoinListener;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;

import java.util.List;

public class BiomeRegionsPlugin extends JavaPlugin {

    private Scoreboard scoreboard;
    private Team adminTeam;
    private Team desertTeam;
    private Team plainsTeam;
    private Location desertStartLocation;
    private Location plainsStartLocation;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        loadConfigValues();
        setupTeams();
        registerCommands();
        registerListeners();
        getLogger().info("BiomeRegions enabled!");
    }

    @Override
    public void onDisable() {
        getLogger().info("BiomeRegions disabled!");
    }

    private void loadConfigValues() {
        reloadConfig();
        FileConfiguration config = getConfig();

        desertStartLocation = loadLocation(config, "desert-start");
        plainsStartLocation = loadLocation(config, "plains-start");
    }

    private Location loadLocation(FileConfiguration config, String path) {
        String worldName = config.getString(path + ".world", "world");
        World world = Bukkit.getWorld(worldName);
        if (world == null) {
            world = Bukkit.getWorlds().getFirst();
        }
        double x = config.getDouble(path + ".x", 0.0);
        double y = config.getDouble(path + ".y", 64.0);
        double z = config.getDouble(path + ".z", 0.0);
        float yaw = (float) config.getDouble(path + ".yaw", 0.0);
        float pitch = (float) config.getDouble(path + ".pitch", 0.0);
        return new Location(world, x, y, z, yaw, pitch);
    }

    private void setupTeams() {
        scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();

        // Unregister existing teams if they exist
        for (String teamName : new String[]{"admin", "desert", "plains"}) {
            Team team = scoreboard.getTeam(teamName);
            if (team != null) team.unregister();
        }

        // Create admin team
        adminTeam = scoreboard.registerNewTeam("admin");
        adminTeam.color(NamedTextColor.DARK_RED);
        adminTeam.prefix(Component.text("[Admin] "));

        // Create desert team
        desertTeam = scoreboard.registerNewTeam("desert");
        desertTeam.color(NamedTextColor.GOLD);

        // Create plains team
        plainsTeam = scoreboard.registerNewTeam("plains");
        plainsTeam.color(NamedTextColor.GREEN);

        // Load player assignments from config
        FileConfiguration config = getConfig();
        for (String playerName : config.getStringList("teams.admin")) {
            adminTeam.addEntry(playerName);
        }
        for (String playerName : config.getStringList("teams.desert")) {
            desertTeam.addEntry(playerName);
        }
        for (String playerName : config.getStringList("teams.plains")) {
            plainsTeam.addEntry(playerName);
        }
    }

    private void registerCommands() {
        getCommand("admin").setExecutor(new AdminCommand(this));
        getCommand("desert").setExecutor(new DesertCommand(this));
        getCommand("plains").setExecutor(new PlainsCommand(this));
        getCommand("start").setExecutor(new StartCommand(this));
        getCommand("locationstart").setExecutor(new com.example.biomeregions.command.LocationStartCommand(this));
    }

    private void registerListeners() {
        Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(this), this);
    }

    public void addToTeam(String playerName, String teamName) {
        // Remove from all teams first
        adminTeam.removeEntry(playerName);
        desertTeam.removeEntry(playerName);
        plainsTeam.removeEntry(playerName);

        // Add to the specified team
        switch (teamName.toLowerCase()) {
            case "admin" -> adminTeam.addEntry(playerName);
            case "desert" -> desertTeam.addEntry(playerName);
            case "plains" -> plainsTeam.addEntry(playerName);
        }

        // Update config
        saveTeamToConfig(playerName, teamName);
    }

    private void saveTeamToConfig(String playerName, String teamName) {
        FileConfiguration config = getConfig();
        // Remove from all teams in config
        for (String team : new String[]{"admin", "desert", "plains"}) {
            List<String> list = config.getStringList("teams." + team);
            list.remove(playerName);
            config.set("teams." + team, list);
        }
        // Add to the specified team
        List<String> list = config.getStringList("teams." + teamName);
        if (!list.contains(playerName)) {
            list.add(playerName);
        }
        config.set("teams." + teamName, list);
        saveConfig();
    }

    public Location getDesertStartLocation() {
        return desertStartLocation.clone();
    }

    public Location getPlainsStartLocation() {
        return plainsStartLocation.clone();
    }

    public void setDesertStartLocation(Location location) {
        this.desertStartLocation = location.clone();
        saveLocationToConfig("desert-start", location);
    }

    public void setPlainsStartLocation(Location location) {
        this.plainsStartLocation = location.clone();
        saveLocationToConfig("plains-start", location);
    }

    private void saveLocationToConfig(String path, Location location) {
        FileConfiguration config = getConfig();
        config.set(path + ".world", location.getWorld().getName());
        config.set(path + ".x", location.getX());
        config.set(path + ".y", location.getY());
        config.set(path + ".z", location.getZ());
        config.set(path + ".yaw", (double) location.getYaw());
        config.set(path + ".pitch", (double) location.getPitch());
        saveConfig();
    }

    public boolean isPlayerInTeam(String playerName, String teamName) {
        return switch (teamName.toLowerCase()) {
            case "admin" -> adminTeam.hasEntry(playerName);
            case "desert" -> desertTeam.hasEntry(playerName);
            case "plains" -> plainsTeam.hasEntry(playerName);
            default -> false;
        };
    }
}