Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Allow getting offline player's PDC

Open u9g opened this issue 3 years ago • 11 comments

Is your feature request related to a problem?

I want to be able to get a player's PDC container, offline or online.

Describe the solution you'd like.

either Bukkit.getPDC(String username); or Bukkit.getPDC(UUID playerUUID);

Describe alternatives you've considered.

Machine Maker: you'd have to manually load the player data nbt file and search for it yourself

Other

No response

u9g avatar Jan 06 '22 04:01 u9g

is there any updates on this feature?

LoaiDev avatar Feb 19 '22 14:02 LoaiDev

Can I try and implement this feature ? I never contributed to Paper so it would be a first for me.

emneo-dev avatar Jun 10 '22 12:06 emneo-dev

You’re more than welcome to!

Owen1212055 avatar Jun 10 '22 12:06 Owen1212055

Nice thank you I will be looking at this during the weekend then :)

emneo-dev avatar Jun 10 '22 12:06 emneo-dev

sure go ahead but the most important part is when do you save the data. on every set? or periodically and need to have a system for that

LoaiDev avatar Jun 10 '22 12:06 LoaiDev

Well I do not know yet, this is what I will try to figure out

emneo-dev avatar Jun 10 '22 12:06 emneo-dev

So I was looking at where to implement this and was thinking of maybe another way to put it. Instead of doing either Bukkit.getPDC(String username); or Bukkit.getPDC(UUID playerUUID); maybe use the OfflinePlayer interface, even though I still have no idea on how to save the data once changed.

emneo-dev avatar Jul 04 '22 08:07 emneo-dev

I think I don't know enough of the Paper codebase to implement this, I have spent multiple hours already looking at this and I find no way to do it. I think I will just look at other issues, sorry :/

emneo-dev avatar Jul 04 '22 09:07 emneo-dev

I was not aware that someone has already implemented this so I also implemented it but with a different approach of saving the containers alongside saving players to avoid many saves. @Lulu13022002 the problem right now is how do you deal with offline players who never played on the server, wouldn't saving their dat file before them ever joining become a problem when they do? this is the only current problem on hand for me

LoaiDev avatar Aug 13 '22 12:08 LoaiDev

No normally the latest commit fixed that, and in my test that would just create the new file (see: https://github.com/PaperMC/Paper/pull/8117/commits/0388bda656aa55ac2ae672db4f66fe823a1251e9#diff-b3293e7f7cf1058b47281ab025cdeebbedbb2b0e384bb72df32ee57bf519ee5fR64-R66). The real problem is https://github.com/PaperMC/Paper/pull/5529#issuecomment-830155819. And i think the plugins should save themselves the data in an autocloseable or using manually the close method when they needs.

Lulu13022002 avatar Aug 13 '22 14:08 Lulu13022002

nvm i have understand your message in the wrong way. Thanks for the test. I have found two bugs:

  • [Server thread/ERROR]: Not a string caused by legacy support for some old nbt when the tag exists but no world is found
  • The player spawn at 0 0 0 and ignore the world spawn when the tag is almost empty (except the PDC) the tag is fully read and some value fallback to zero or their default value I have fixed that in the latest "real" commit. Can you retest that to be sure

Lulu13022002 avatar Aug 14 '22 09:08 Lulu13022002