📄
pasted-code-1786104086447.txt
txt
25 lines
▶
Act as an expert Java developer specializing in modern Minecraft server APIs (Paper and Folia 1.21.11+). Write a complete, production-ready, and highly optimized plugin that allows administrators to deeply spoof a player's identity.
Core Functionality:
The plugin must completely mask a player's original identity with a new name across all server systems. When spoofed, the server and other players must treat them entirely as the new name.
This includes Tablist name, Above-head nametag, Chat messages, Death messages, and targeting for commands (e.g., if 'xyz' is spoofed as 'hello', /tp hello or /op hello must target 'xyz').
Commands:
/name change : Updates the internal mapping and applies the disguise. The player must appear as the new name immediately or upon their next relog.
/name reset : Removes the disguise, reverting the player to their original identity.
Strict Technical Constraints (CRITICAL):
Folia Compatibility: You absolutely MUST NOT use Bukkit.getScheduler(). You must use Folia's RegionScheduler, GlobalRegionScheduler, and AsyncScheduler. Structure the plugin so it gracefully checks if Folia is present and routes scheduling accordingly to maintain compatibility with standard Paper.
Identity Spoofing Method: Utilize Paper's modern PlayerProfile API and Adventure components. Avoid legacy NMS where possible to maintain version stability.
Command Interception: To ensure commands like /tp work with the spoofed name, you will need to handle PlayerCommandPreprocessEvent and ServerCommandEvent to intercept and translate the spoofed name back to the real player's name before the server executes the command.
Data Persistence: Store the UUID-to-SpoofedName mapping in a lightweight, optimized data.yml or JSON file so disguises persist across server restarts and player relogs. Use asynchronous tasks for all file I/O operations.
Performance: Cache the spoof mappings in memory (e.g., a ConcurrentHashMap) for instantaneous lookup during chat and command events.
Create the Gradle/Paper project metadata and plugin descriptor.
Add Folia-safe scheduler and asynchronous YAML persistence.
Add the identity manager, profile/tablist/nametag updates, chat/death masking, and command target translation.
Add the administrator
/name changeand/name resetcommand with tab completion.
Created the Paper/Folia-compatible Gradle project and plugin descriptor.
Added asynchronous YAML persistence with atomic file replacement.
Added cached identity mappings, profile/display-name updates, tablist and nametag masking.
Added chat, death, join/quit, player-command, and console-command translation.
Added
/name changeand/name resetwith permission checks and tab completion.
📄
pasted-code-1786104621616.txt
txt
25 lines
▶
e previous native API method failed to update the physical above-head nametag. We are going to solve this using ProtocolLib as a required dependency to intercept network packets directly.
Write the Java code for Paper/Folia (1.21.11+) with ProtocolLib.
Core Requirements & Dependency Setup:
Require ProtocolLib in the plugin.yml (or paper-plugin.yml) and assume it is added to the build.gradle or pom.xml.
Packet Interception Logic (The Nametag Fix):
Register a ProtocolLib PacketAdapter listening for PacketType.Play.Server.PLAYER_INFO (and PLAYER_INFO_UPDATE depending on the 1.21+ packet wrapper structure).
When the server sends this packet to update player data to clients, intercept it asynchronously.
Loop through the PlayerInfoData list inside the packet. If any UUID in the packet matches a player in your spoofed ConcurrentHashMap, clone the GameProfile from the packet data.
Modify the cloned GameProfile to use the while strictly retaining the original texture properties (so their skin does not break).
Write the modified PlayerInfoData back into the packet before letting it proceed to the client.
Why this matters for Folia:
Packet interception via ProtocolLib happens asynchronously on the network I/O threads. This completely bypasses Folia's strict RegionScheduler limitations, meaning we do not need to use hidePlayer() or showPlayer(), which are prone to cross-region thread crashes.
Maintain Previous Features:
Continue to use the ConcurrentHashMap for O(1) lookups and ensure PlayerCommandPreprocessEvent is still utilized to translate spoofed names back to original names for commands like /tp or /op.
Add ProtocolLib as a compile-only dependency and hard dependency.
Add a packet listener that rewrites player-info profiles while preserving UUID and skin properties.
Keep the existing cached command translation and ensure packet registration is cleaned up on disable.
Added ProtocolLib as a compile-only dependency and required plugin dependency.
Added
PacketIdentityListenerforPLAYER_INFOpacket interception.Rewrites spoofed profile names while preserving UUIDs, skin properties, latency, game mode, tab-list state, ordering, and chat-session data.
Registers the listener on enable and removes it cleanly on disable.
📄
pasted-code-1786104901340.txt
txt
34 lines
▶
7:44:10 ERROR]: [IdentitySpoof] Unhandled exception number 64 occurred in onPacketSending(PacketEvent) for IdentitySpoof
java.lang.IllegalAccessError: class com.kodari.identityspoof.PacketIdentityListener$1 tried to access private method 'void com.kodari.identityspoof.PacketIdentityListener.rewrite(com.comphenix.protocol.events.PacketEvent)' (com.kodari.identityspoof.PacketIdentityListener$1 and com.kodari.identityspoof.PacketIdentityListener are in unnamed module of loader 'IdentitySpoof-1.0.0 (1).jar' @27b9766c)
at IdentitySpoof-1.0.0 (1).jar//com.kodari.identityspoof.PacketIdentityListener$1.onPacketSending(PacketIdentityListener.java:33) ~[?:?]
at ProtocolLib.jar//com.comphenix.protocol.injector.collection.OutboundPacketListenerSet.invokeListener(OutboundPacketListenerSet.java:76) ~[?:?]
at ProtocolLib.jar//com.comphenix.protocol.injector.collection.PacketListenerSet.lambda$invoke$0(PacketListenerSet.java:123) ~[?:?]
at ProtocolLib.jar//com.comphenix.protocol.timing.TimingTracker.lambda$static$0(TimingTracker.java:7) ~[?:?]
at ProtocolLib.jar//com.comphenix.protocol.injector.collection.PacketListenerSet.invoke(PacketListenerSet.java:123) ~[?:?]
at ProtocolLib.jar//com.comphenix.protocol.injector.collection.OutboundPacketListenerSet.invoke(OutboundPacketListenerSet.java:30) ~[?:?]
at ProtocolLib.jar//com.comphenix.protocol.injector.collection.PacketListenerSet.invoke(PacketListenerSet.java:102) ~[?:?]
at ProtocolLib.jar//com.comphenix.protocol.injector.PacketFilterManager.postPacketToListeners(PacketFilterManager.java:545) ~[?:?]
at ProtocolLib.jar//com.comphenix.protocol.injector.PacketFilterManager.invokeOutboundPacketListeners(PacketFilterManager.java:520) ~[?:?]
at ProtocolLib.jar//com.comphenix.protocol.injector.netty.channel.NettyChannelInjector.processOutbound(NettyChannelInjector.java:569) ~[?:?]
at ProtocolLib.jar//com.comphenix.protocol.injector.netty.channel.NettyEventLoopProxy.proxyRunnable(NettyEventLoopProxy.java:46) ~[?:?]
at ProtocolLib.jar//com.comphenix.protocol.injector.netty.channel.NettyEventLoopProxy.execute(NettyEventLoopProxy.java:235) ~[?:?]
at net.minecraft.network.Connection.sendPacket(Connection.java:451) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.network.Connection.send(Connection.java:412) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.server.network.ServerCommonPacketListenerImpl.send(ServerCommonPacketListenerImpl.java:329) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.server.network.ServerCommonPacketListenerImpl.send(ServerCommonPacketListenerImpl.java:311) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.server.players.PlayerList.broadcastAll(PlayerList.java:755) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.server.level.ServerPlayerGameMode.changeGameModeForPlayer(ServerPlayerGameMode.java:90) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.server.level.ServerPlayer.setGameMode(ServerPlayer.java:2309) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.server.commands.GameModeCommand.setGameMode(GameModeCommand.java:77) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChangeGameMode(ServerGamePacketListenerImpl.java:3591) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.network.protocol.game.ServerboundChangeGameModePacket.handle(ServerboundChangeGameModePacket.java:21) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.network.protocol.game.ServerboundChangeGameModePacket.handle(ServerboundChangeGameModePacket.java:9) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.network.PacketProcessor$ListenerAndPacket.handle(PacketProcessor.java:99) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.network.PacketProcessor.executeSinglePacket(PacketProcessor.java:33) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1499) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.server.MinecraftServer.recordTaskExecutionTimeWhileWaiting(MinecraftServer.java:1225) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1341) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:388) ~[paper-1.21.11.jar:1.21.11-132-c5eb079]
at java.base/java.lang.Thread.run(Thread.java:1474) ~[?:?]
[17:44:10 INFO]: [Y4SH_07: Set own game mode to Creative Mode]
📄
pasted-code-1786105011088.txt
txt
26 lines
▶
The previous ProtocolLib implementation threw a console error because it failed to correctly handle the 1.21.11 packet structure for PlayerInfoUpdate on Folia.
You must completely remove ProtocolLib and replace it with PacketEvents (by retrooper). Rewrite the packet interception logic using the PacketEvents API.
Core Requirements & Initialization:
Add PacketEvents as a dependency. You must properly initialize PacketEvents in the plugin's onLoad() phase by calling PacketEvents.setAPI(NettyPacketEventsBuilder.build(this)) and PacketEvents.getAPI().load(). Initialize it in onEnable() with PacketEvents.getAPI().init().
Ensure the plugin is still fully Folia-compatible (no Bukkit schedulers).
Packet Interception (PacketEvents Logic):
Register a PacketListenerAbstract with PacketListenerPriority.NORMAL.
Listen specifically for PacketType.Play.Server.PLAYER_INFO_UPDATE (and PLAYER_INFO_REMOVE if necessary for caching).
Inside the listener, wrap the packet using new WrapperPlayServerPlayerInfoUpdate(event) or the equivalent PacketEvents wrapper for the current version.
Iterate through the PlayerInfo entries in the wrapper. If the entry's UUID matches a spoofed player in our ConcurrentHashMap, you must clone the UserProfile from that entry.
Modify the cloned UserProfile to apply the while strictly retaining the original texture properties (so their skin does not break).
Update the entry in the wrapper and force the event to save the modified packet before it reaches the client.
Command Translation:
Do not forget to retain the PlayerCommandPreprocessEvent and ServerCommandEvent logic. Any command targeting must still translate back to so the server processes it correctly. Provide the complete, updated code.
Remove ProtocolLib and switch dependency metadata to PacketEvents.
Replace the failing packet listener with a PacketEvents
PLAYER_INFO_UPDATElistener compatible with the project’s API version.Initialize/tear down PacketEvents in the plugin lifecycle while preserving Folia-safe scheduling and command translation.
Update any affected configuration and imports so the project remains buildable.
Removed ProtocolLib and added PacketEvents
2.10.0as a compile-only dependency.Updated
plugin.ymlto require thepacketeventsplugin.Replaced the ProtocolLib listener with a PacketEvents
PacketListenerAbstracthandlingPLAYER_INFO_UPDATE.Rewrites
UserProfilenames while copying all texture properties, preserving skins and UUIDs.Added PacketEvents lifecycle initialization in
onLoad(), initialization inonEnable(), listener removal, and API termination inonDisable().Preserved the existing Folia-safe scheduler and command translation behavior.
The current PacketEvents API exposes SpigotPacketEventsBuilder, so the implementation uses that supported builder rather than the nonexistent NettyPacketEventsBuilder.
package com.kodari.identityspoof;
import com.github.retrooper.packetevents.PacketEvents;
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public final class IdentitySpoofPlugin extends JavaPlugin {
private TaskScheduler scheduler;
private SpoofDataStore dataStore;
private IdentityManager identityManager;
private PacketIdentityListener packetIdentityListener;
@Override
public void onLoad() {
PacketEvents.setAPI(SpigotPacketEventsBuilder.build(this));
PacketEvents.getAPI().load();
}
@Override
public void onEnable() {
PacketEvents.getAPI().getSettings().debug(false).checkForUpdates(false).reEncodeByDefault(true);
PacketEvents.getAPI().init();
scheduler = new TaskScheduler(this);
dataStore = new SpoofDataStore(this, scheduler);
identityManager = new IdentityManager(this, dataStore);
Bukkit.getPluginManager().registerEvents(new IdentityListener(this, identityManager), this);
packetIdentityListener = new PacketIdentityListener(this, identityManager);
packetIdentityListener.register();
NameCommand nameCommand = new NameCommand(this, identityManager);
getCommand("name").setExecutor(nameCommand);
getCommand("name").setTabCompleter(nameCommand);
dataStore.loadAsync().thenAccept(identityManager::loadMappings)
.thenRun(() -> scheduler.runGlobal(this::applyLoadedMappings));
getLogger().info("IdentitySpoof enabled with " + (scheduler.isFolia() ? "Folia" : "Paper") + " scheduling.");
}
@Override
public void onDisable() {
if (packetIdentityListener != null) {
packetIdentityListener.unregister();
}
if (dataStore != null && identityManager != null) {
dataStore.saveAsync(identityManager.snapshot());
}
if (PacketEvents.getAPI() != null && PacketEvents.getAPI().isInitialized()) {
PacketEvents.getAPI().terminate();
}
}
public TaskScheduler getScheduler() {
return scheduler;
}
private void applyLoadedMappings() {
for (Player player : Bukkit.getOnlinePlayers()) {
scheduler.runAtPlayer(player, () -> identityManager.apply(player));
}
}
}