Jump to content

[SOLVED] [1.12.2] Modifying player capabilities for offline players?


Recommended Posts

Posted (edited)

Hey!

 

Is there any way to modify capability values for offline players (where EntityPlayerMP instance is null essentially) without using JSON? Is there like a way to make capabilities for GameProfile?

 

Any help is appreciated!

 

Thanks! :D

Edited by Differentiation
Posted (edited)
3 hours ago, diesieben07 said:

How is JSON applicable at all here? Capabilities use NBT...

You can probably do something similar to what SaveHandler#readPlayerData does. You can't use it directly, because it requires an EntityPlayerMP. Then you can modify the data and save it back. Note however that you need to take to only do this if the player isn't logged in or your changes will go away.

I mean, it isn't necessarily capabilities that I'm trying to store, it's just raw data (some boolean, integer variables, etc.) and that's what I meant by using JSON.

 

So the way I currently do it is make a temporary entry in my JSON file for offline player. Then when they log on, I move the values to NBT (the player capability class) and remove the JSON entry.

Edited by Differentiation
Posted
1 minute ago, diesieben07 said:

In that case you could just store a Map<UUID, YourDataClass> somewhere and load/unloaded from that as needed. And then you can use whatever data format you want.

Yes, but what if the Dedicated Server is, say, closed before the player gets to log on?

Posted (edited)
7 minutes ago, diesieben07 said:

The one the world is also saved to?

 

Like I said, which file format you use is completely up to you here.

Ah I see. I think now the JSON much is way simpler xD

 

Thanks for the help! :)

Edited by Differentiation
Posted
8 minutes ago, diesieben07 said:

The one the world is also saved to?

 

Like I said, which file format you use is completely up to you here.

The thing is I was trying to figure out if there's any way to accomplish this without having to save data to a file.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.