John

Build a plugin for paper 26.2 that can change the skin of a player and name like if it’s a name of the YouTuber it changes your skin too to the character

Kodari AI
KodariToday at 8:26 pm 1
YouTuberSkinChanger
A Paper 26.2 plugin that lets players change their in-game name and skin to match a YouTuber. When a player types a command with a YouTuber's name, the plugin fetches and applies the corresponding character skin from a predefined mapping. It includes a configurable list of YouTuber names and their associated skin URLs, a command to trigger the transformation, and a command to reset the player back to their original skin and name. The plugin handles async skin fetching to avoid lag, stores player data for persistence, and supports reloading the configuration without restarting the server.

Created /disguise <username> to copy a player’s skin and displayed name, and /disguise reset to restore your own. The playerdisguise.use permission defaults to operators.

This changes your display and tab-list names, not your actual account name or UUID. Disguises reset when you leave.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 144
src/main/java/com/kodari/playerdisguise/PlayerDisguise.java
package com.kodari.playerdisguise;

import com.destroystokyo.paper.profile.PlayerProfile;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class PlayerDisguise extends JavaPlugin implements Listener {
    private final Map<UUID, PlayerProfile> originalProfiles = new HashMap<>();
    private final Map<UUID, UUID> requests = new HashMap<>();

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @Override
    public void onDisable() {
        for (Player player : getServer().getOnlinePlayers()) {
            restore(player);
        }
        requests.clear();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage("Only players can use this command.");
            return true;
        }
        if (args.length != 1) {
            return false;
        }
        UUID playerId = player.getUniqueId();
        if (args[0].equalsIgnoreCase("reset")) {
            requests.remove(playerId);
            if (originalProfiles.containsKey(playerId)) {
                restore(player);
                player.sendMessage("§aYour original name and skin have been restored.");
            } else {
                player.sendMessage("§eYou are not disguised.");
            }
            return true;
        }
        String name = args[0];
        if (!name.matches("[A-Za-z0-9_]{1,16}")) {
            player.sendMessage("§cEnter a valid Minecraft username.");
            return true;
        }

        UUID requestId = UUID.randomUUID();
        requests.put(playerId, requestId);
        PlayerProfile lookup = Bukkit.createProfile(null, name);
        player.sendMessage("§eLooking up " + name + "...");
        Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
            boolean found;
            try {
                found = lookup.complete() && lookup.getTextures().getSkin() != null;
            } catch (Exception exception) {
                found = false;
            }
            boolean success = found;
            Bukkit.getScheduler().runTask(this, () -> {
                if (!requestId.equals(requests.get(playerId))) {
                    return;
                }
                requests.remove(playerId);
                Player current = Bukkit.getPlayer(playerId);
                if (current == null) {
                    return;
                }
                if (!success) {
                    current.sendMessage("§cCould not find a skin for " + name + ".");
                    return;
                }
                originalProfiles.putIfAbsent(playerId, current.getPlayerProfile().clone());
                PlayerProfile profile = current.getPlayerProfile();
                profile.setTextures(lookup.getTextures());
                current.setPlayerProfile(profile);
                String resolvedName = lookup.getName() == null ? name : lookup.getName();
                current.setDisplayName(resolvedName);
                current.setPlayerListName(resolvedName);
                current.sendMessage("§aYour displayed name and skin are now " + resolvedName + ".");
            });
        });
        return true;
    }

    @EventHandler
    public void onQuit(PlayerQuitEvent event) {
        requests.remove(event.getPlayer().getUniqueId());
        restore(event.getPlayer());
    }

    private void restore(Player player) {
        PlayerProfile original = originalProfiles.remove(player.getUniqueId());
        if (original != null) {
            player.setPlayerProfile(original);
            player.setDisplayName(null);
            player.setPlayerListName(null);
        }
    }
}