Skip to content

NamespacedKey based plugin chunk tickets#4173

Closed
Trigary wants to merge 2 commits into
PaperMC:masterfrom
Trigary:keyed-plugin-chunk-tickets
Closed

NamespacedKey based plugin chunk tickets#4173
Trigary wants to merge 2 commits into
PaperMC:masterfrom
Trigary:keyed-plugin-chunk-tickets

Conversation

@Trigary
Copy link
Copy Markdown
Contributor

@Trigary Trigary commented Aug 22, 2020

A work-in-progress (at the time of creation) implementation of NamespacedKey based plugin chunk tickets. The reasoning behind the creation of this API can be found in #4147

State of draft PR:

  • yet to be tested
  • yet to receive JavaDocs

Copy link
Copy Markdown
Contributor

@Proximyst Proximyst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good so far!

Comment thread Spigot-Server-Patches/0553-NamespacedKey-based-plugin-chunk-tickets.patch Outdated
Comment thread Spigot-Server-Patches/0553-NamespacedKey-based-plugin-chunk-tickets.patch Outdated
Comment thread Spigot-API-Patches/0219-NamespacedKey-based-plugin-chunk-tickets.patch Outdated
@Proximyst Proximyst added the type: feature Request for a new Feature. label Aug 24, 2020
Copy link
Copy Markdown
Member

@aikar aikar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good bit of changes needed. overall dont want to expose actual numeric levels, and want to improve the api signatures more than spigot used.
and while the system supports putting multiple tickets of the same key at different levels, dont want to support it over api as we cant guarantee that, and it also makes it more complicated.

if people want to have multiple tickets at different levels, they can use multiple keys to achieve that.

Comment thread Spigot-API-Patches/0219-NamespacedKey-based-plugin-chunk-tickets.patch Outdated
Comment thread Spigot-API-Patches/0219-NamespacedKey-based-plugin-chunk-tickets.patch Outdated
Comment thread Spigot-Server-Patches/0553-NamespacedKey-based-plugin-chunk-tickets.patch Outdated
Comment thread Spigot-API-Patches/0219-NamespacedKey-based-plugin-chunk-tickets.patch Outdated
Comment thread Spigot-API-Patches/0219-NamespacedKey-based-plugin-chunk-tickets.patch Outdated
Comment thread Spigot-Server-Patches/0553-NamespacedKey-based-plugin-chunk-tickets.patch Outdated
Comment thread Spigot-Server-Patches/0553-NamespacedKey-based-plugin-chunk-tickets.patch Outdated
Comment thread Spigot-Server-Patches/0553-NamespacedKey-based-plugin-chunk-tickets.patch Outdated
Comment thread Spigot-Server-Patches/0553-NamespacedKey-based-plugin-chunk-tickets.patch Outdated
Comment thread Spigot-Server-Patches/0553-NamespacedKey-based-plugin-chunk-tickets.patch Outdated
@Trigary
Copy link
Copy Markdown
Contributor Author

Trigary commented Sep 10, 2020

Thanks for the review, I shall make these changes.

@Trigary
Copy link
Copy Markdown
Contributor Author

Trigary commented Nov 30, 2020

I apologize for the delays, I finally made the requested changes.

There is one thing that's definitely not finished yet (they produce a compile error at the moment): there are two getter methods that list chunks that have these keyed plugin chunk tickets. What should they return?

  • return Chunk instances, possibly forcing sync chunk loads
  • return some sort int-int pair (the X, Z coordinates of the chunk) (I don't think this chunk coord pair class exists in the API yet)
  • return Chunk instances for loaded chunks and specify in the JavaDocs that only already loaded chunks are returned, so not yet loaded chunks must be handled manually somehow

Another questionable implementation is CraftWorld#removeKeyedPluginChunkTicket(x, z, org.bukkit.NamespacedKey). It iterates over the TickingLevel values and tries to remove them one-by-one. The alternative is to iterate over the tickets that actually exist in the chunk and remove the correct iterator. The issue with this 2nd option is that removing a ticket is a bit harder to implement, I'm afraid I might make mistakes. And the issue with the 1st option is the performance overhead, heap allocations.

All of these WIP / not finished methods have TODOs in them, that's an easy way to find them.

@Trigary Trigary requested a review from aikar November 30, 2020 12:52
@aikar
Copy link
Copy Markdown
Member

aikar commented Nov 30, 2020

I think you have a slight bit of confusion. TickingLevel.NONE is still going to be returned in Loaded Chunks.

These chunks will be loaded, just at BORDER status. TickingLevel.NONE = Border

@Trigary
Copy link
Copy Markdown
Contributor Author

Trigary commented Nov 30, 2020

They will be loaded, but only asynchronously as far as I know, but I might be wrong. So the getter method might catch them when they are not yet loaded, just being loaded. In this case a Chunk does not yet exist AFAIK.

@aikar
Copy link
Copy Markdown
Member

aikar commented Nov 30, 2020

Hmm I see, in that this API is meant to return chunks that have a plugin ticket but since they are loaded async does present a window they havent finished yet.

Returning a collection of Long's does make more sense than chunks, and people can re-map it to Chunk objects and filter by loaded status on their own if needed.

Or even provide a .getKeyedPluginChunkTicketLoadedChunks that does the filtering for you.

@Trigary
Copy link
Copy Markdown
Contributor Author

Trigary commented Nov 30, 2020

Thank you for your response, I shall make the necessary changes and finalize the PR.

@Trigary
Copy link
Copy Markdown
Contributor Author

Trigary commented Dec 3, 2020

I am considering this done, apart from testing: I am yet to actually test these additions in action.

Ignore the failed GitHub Actions check. It worked fine locally on WSL and on Git Bash (on 2 separate PCs) and Z750 also believes that GitHub Actions is the culprit here.

@Trigary
Copy link
Copy Markdown
Contributor Author

Trigary commented Dec 12, 2020

I have finished testing, everything seems to be in order, I am marking this PR as ready, non-draft. For possible future uses, this is what I used for testing: https://pastebin.com/S1B4NKAC

@Trigary Trigary marked this pull request as ready for review December 12, 2020 10:32
@Trigary Trigary requested a review from a team as a code owner December 12, 2020 10:32
@Proximyst
Copy link
Copy Markdown
Contributor

The CI does not seem to be in order, actually :p

@Trigary
Copy link
Copy Markdown
Contributor Author

Trigary commented Dec 13, 2020

@Proximyst

The CI does not seem to be in order, actually :p

Have you read the 2nd paragraph of this comment of mine? #4173 (comment)

@Proximyst
Copy link
Copy Markdown
Contributor

Tried forcepushing to have GH Actions retry? We can't merge without it passing 😅

@Trigary Trigary force-pushed the keyed-plugin-chunk-tickets branch from f0a97c8 to 0952726 Compare December 13, 2020 15:59
@Trigary
Copy link
Copy Markdown
Contributor Author

Trigary commented Dec 13, 2020

CI is having none of it by the looks of it

@Proximyst
Copy link
Copy Markdown
Contributor

Well that's because it's trying to merge 1.16.3 code into 1.16.4; there will quite often be some kind of issue. I've rebased your PR for you.

@Proximyst Proximyst force-pushed the keyed-plugin-chunk-tickets branch from 0952726 to feb5843 Compare December 13, 2020 16:09
@Trigary
Copy link
Copy Markdown
Contributor Author

Trigary commented Dec 13, 2020

Makes sense, thank you.

@Trigary
Copy link
Copy Markdown
Contributor Author

Trigary commented Feb 10, 2021

I have improved the JavaDocs. There was some outdated stuff in there, I removed that. I improved the wording here and there. I also documented what happens when chunk tickets are added to unloaded chunks (the chunk gets loaded async).

I have also moved the removeKeyedPluginChunkTickets(Plugin) call from removePluginChunkTickets(Plugin) to SimplePluginManager. Aikar once told me to put it inside removePluginChunkTickets(Plugin), but I'm confident keyed plugin chunk tickets shouldn't be removed just because non-keyed ones are removed through removePluginChunkTickets(Plugin). Feel free to tell me to revert that though if you believe this change is bad.

I have moved the TickingLevel class to the io.papermc.paper.world package from io.papermc.paper. I have also switched to using import statements. Again, feel free to tell me to revert.

Still awaiting review.

@Trigary Trigary requested a review from a team as a code owner June 20, 2021 12:00
@Owen1212055
Copy link
Copy Markdown
Member

Closing PR, as it seems that this has gone inactive.

If you're still interested in continuing this PR, feel free to leave a comment and we can reopen it for you. 😄

@Trigary
Copy link
Copy Markdown
Contributor Author

Trigary commented Oct 23, 2022

I am still interested in continuing this PR. I am just waiting for a review.

@NoahvdAa NoahvdAa reopened this Oct 23, 2022
@Owen1212055
Copy link
Copy Markdown
Member

I am still interested in continuing this PR. I am just waiting for a review.

Would you be able to rebase it? 😄

@Owen1212055
Copy link
Copy Markdown
Member

See above, if you are still interested in continuing, please feel free to rebase this pr. 😄
It should be noted that upstream has added some methods to get tick levels for chunks to the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants