Stack trace
Server Log containing the errors:
https://paste.gg/p/anonymous/fb749d8c53cb422ea335f69a2ef75fac
Plugin and Datapack List

Actions to reproduce (if known)
- Run the command
/to-config as a player
- On the console, run either
startConfig or unconfig command
Paper version
[21:49:30 INFO]: This server is running Paper version 1.21.1-120-master@57c75a4 (2024-10-09T21:11:07Z) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
You are running the latest version
Other
Here's the full testplugin code:
package com.zedphi.testplugin;
import com.mojang.brigadier.Command;
import io.papermc.paper.command.brigadier.Commands;
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerConfigurationPacketListenerImpl;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class TestPlugin extends JavaPlugin {
@Override
public void onLoad(){
getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS.newHandler(event -> {
var registrar = event.registrar();
registrar.register(Commands.literal("to-config")
.executes(sourceStack -> {
switch (sourceStack.getSource().getSender()){
case Player player -> switchToConfig(player);
default -> throw new IllegalStateException("Unexpected value: " + sourceStack.getSource().getSender());
}
return Command.SINGLE_SUCCESS;
})
.build());
registrar.register(Commands.literal("startConfig")
.executes(sourceStack -> {
startConfig();
return Command.SINGLE_SUCCESS;
})
.build());
registrar.register(Commands.literal("unconfig")
.executes(sourceStack -> {
unconfig();
return Command.SINGLE_SUCCESS;
})
.build());
}));
}
private void switchToConfig(Player player){
ServerGamePacketListenerImpl gameListener = ((CraftPlayer) player).getHandle().connection;
gameListener.switchToConfig();
}
private void startConfig(){
MinecraftServer.getServer().getConnection().getConnections().forEach(connection -> {
if (connection.getPacketListener() instanceof ServerConfigurationPacketListenerImpl configListener){
configListener.startConfiguration();
}
});
}
private void unconfig(){
MinecraftServer.getServer().getConnection().getConnections().forEach(connection -> {
if (connection.getPacketListener() instanceof ServerConfigurationPacketListenerImpl configListener){
configListener.returnToWorld();
}
});
}
}
Stack trace
Server Log containing the errors:
https://paste.gg/p/anonymous/fb749d8c53cb422ea335f69a2ef75fac
Plugin and Datapack List
Actions to reproduce (if known)
/to-configas a playerstartConfigorunconfigcommandPaper version
Other
Here's the full testplugin code: