halogamer
📎 1 file 1,103 chars
📄
pasted-code-1791056572312.txt
txt 17 lines
▶
Make me a Minecraft Paper plugin for 1.21.11 with a `/vanish` command.

Requirements:

* Only OP players can use `/vanish`.
* `/vanish` toggles vanish on and off.
* When a player enters vanish, make it appear to everyone else that they left the server.
* Completely remove the vanished player from everyone else’s tab list.
* Other players must not be able to see the vanished player in-game.
* The vanished player should still be fully in the server and able to move, interact, use commands, and play normally.
* When vanish is disabled, make it appear that the player joined the server again and show them in the tab list.
* Other players should not receive normal join/leave messages when the vanished player toggles vanish; use custom messages that make it look like a real disconnect/reconnect.
* Make sure vanished players cannot be targeted or detected through normal player visibility.
* Do not kick or disconnect the player when `/vanish` is used.
* Add a permission check so only OP players can use the command.
* Make the plugin lightweight and compatible with Paper 1.21.11.
Kodari AI
KodariOct 3 at 7:44 pm 1
VanishSystem
A lightweight Paper plugin adding a `/vanish` command for OP players. Toggling vanish makes the player appear to leave the server, removes them from tab lists, and hides them from other players' visibility while they remain fully active. When disabled, it appears as a reconnect with custom join/leave messages. Includes OP permission checks and ensures vanished players cannot be targeted or detected through normal player visibility.

I’ll create the Paper 1.21.11 plugin with an OP-only /vanish toggle, hidden-player join handling, and custom disconnect/reconnect messages.

  • Add the Gradle project setup for Paper 1.21.11.

  • Add the plugin manifest and command declaration.

  • Implement visibility, tab-list removal, toggle messages, and cleanup.

Created the Paper 1.21.11 /vanish plugin. It restricts the command to OP players, hides vanished players from others’ visibility and tab lists, hides them from players who join later, and sends custom left/join messages when vanish is toggled.

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

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

public final class VanishPlugin extends JavaPlugin implements Listener, CommandExecutor {
    private final Set<UUID> vanishedPlayers = new HashSet<>();

    @Override
    public void onEnable() {
        Bukkit.getPluginManager().registerEvents(this, this);
        getCommand("vanish").setExecutor(this);
    }

    @Override
    public void onDisable() {
        for (UUID vanishedId : vanishedPlayers) {
            Player vanishedPlayer = Bukkit.getPlayer(vanishedId);
            if (vanishedPlayer == null) {
                continue;
            }
            for (Player viewer : Bukkit.getOnlinePlayers()) {
                if (!viewer.equals(vanishedPlayer)) {
                    viewer.showPlayer(this, vanishedPlayer);
                }
            }
        }
        vanishedPlayers.clear();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage(ChatColor.RED + "Only players can use this command.");
            return true;
        }
        if (!player.isOp()) {
            player.sendMessage(ChatColor.RED + "You must be an operator to use this command.");
            return true;
        }

        if (vanishedPlayers.add(player.getUniqueId())) {
            for (Player viewer : Bukkit.getOnlinePlayers()) {
                if (!viewer.equals(player)) {
                    viewer.hidePlayer(this, player);
                }
            }
            broadcastToggleMessage(player, "left");
            player.sendMessage(ChatColor.GREEN + "You are now vanished.");
        } else {
            vanishedPlayers.remove(player.getUniqueId());
            for (Player viewer : Bukkit.getOnlinePlayers()) {
                if (!viewer.equals(player)) {
                    viewer.showPlayer(this, player);
                }
            }
            broadcastToggleMessage(player, "joined");
            player.sendMessage(ChatColor.GREEN + "You are no longer vanished.");
        }
        return true;
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        Player joiningPlayer = event.getPlayer();
        for (UUID vanishedId : vanishedPlayers) {
            Player vanishedPlayer = Bukkit.getPlayer(vanishedId);
            if (vanishedPlayer != null && !vanishedPlayer.equals(joiningPlayer)) {
                joiningPlayer.hidePlayer(this, vanishedPlayer);
            }
        }
    }

    @EventHandler
    public void onPlayerQuit(PlayerQuitEvent event) {
        vanishedPlayers.remove(event.getPlayer().getUniqueId());
    }

    private void broadcastToggleMessage(Player player, String action) {
        String message = ChatColor.YELLOW + player.getName() + " " + action + " the game";
        for (Player recipient : Bukkit.getOnlinePlayers()) {
            if (!recipient.equals(player)) {
                recipient.sendMessage(message);
            }
        }
    }
}