ClientConnectionEvent error

So I’m trying to make my plugin save the players name in a config file when they first join the server. this is how it looks:

if(!hasJoinedBefore(playerID)){
playerConfig.getNode(playerID.toString(), "Name").setValue(player.getName());
try {
     loader.save(playerConfig);
catch (IOException e) {
     logger.warn("[WARNING!] Failed to create player config for user \"" + player.getName() + "\" \n" + e.toString());
    }
}

and in my main class it looks like this:

@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event){
     UUID playerID event.getTargetEntity().getUniqueId();

     playerManager.CreatePlayer(playerID);
}

but it returns this message in the console: " [Sponge]: Could not pass ClientConnectionEvent$Join$Impl to Plugin"

Turns out it works if I change the setValue to something else, guess you can’t use player.getName() for that

How come you were attempting to save the name? As a player can change their name through the minecraft website?

I wanted to make it easy for the server owner or whatever to find the playername they were looking for in the config. In case there would be like 100 people joining I imagine it would be hard to find by just the uuid

Fair enough. Just out of curiosity. How come you wanted this list of players who joined? As Sponge allows you to get the User data of players who have joined before?

Sorry for all the questions, im just curious.

No problem, I just wanted to make it as handy as possible. It’s not something that’s required but just something I wanted to try to make :smiley:

There is an = missing ^^

UUID playerID = event.getTargetEntity().getUniqueId();

ah my bad, I had remove alot of " " that got copied when you copy from IntelliJ so I accidentally removed it in the post. It’s there in the code I just made a mistake. But thanks for noticing!

Yeah, I already thought so :smiley:

Is it only this message, or is there a stacktrace?

Good news! I found out how to do it / what I did wrong. I hadn’t set the player variable to anything, so all i did was change the main class method to send a player variable with the value event.getTargetEntity()