Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A better way to associate metadata with objects such as Players #2766

Closed
dktapps opened this issue Feb 16, 2019 · 1 comment
Closed

A better way to associate metadata with objects such as Players #2766

dktapps opened this issue Feb 16, 2019 · 1 comment
Labels
Category: API Related to the plugin API Resolution: Obsolete Superseded by other changes Type: Enhancement Contributes features or other improvements to PocketMine-MP

Comments

@dktapps
Copy link
Member

dktapps commented Feb 16, 2019

Description

Currently it's difficult to store data which is associated with, for example, a Player, which will not outlive the player.

Current methods used

  • Plugins keep their own hashmap of some unique identifier -> whatever data
    • Problem: The plugin must clean up after itself when the player quits. If it does not, memory will be leaked.
  • MetadataStore: I don't think anyone actually uses this overengineered piece of cargo-cult garbage. MetadataStore in Bukkit is designed to deal with this problem.
    • Problem: Overengineered to the point of being unusably inconvenient.
    • Problem: Objects associated with a particular Metadatable are not cleaned up when the Metadatable is disposed, making it effectively useless for this purpose.
  • Magic fields on players
  • Extra tags in Entity->namedtag
    • Problem: Again, this is not really supported API and is no longer possible as of latest 4.0 dev builds since NBT is no longer retained at runtime.
    • Problem: It's not possible to store non-scalar items in this manner.
    • Problem: Different plugins' data may collide.
    • Problem: Data ends up getting saved to disk, which might not be desirable.
@dktapps dktapps added Category: API Related to the plugin API Type: Request for Comments Type: Enhancement Contributes features or other improvements to PocketMine-MP labels Feb 16, 2019
@dktapps dktapps added this to the 4.0 milestone Feb 23, 2019
dktapps added a commit that referenced this issue Jun 26, 2019
the intentions of this are good, but the usability is terrible and it's not fit for purpose. Since there are a total of zero plugins on Poggit which use this garbage, it makes more sense to eliminate the technical debt. See #2766 for discussion about replacing this.
@SOF3 SOF3 closed this as completed Mar 27, 2021
@pmmp pmmp locked and limited conversation to collaborators Mar 27, 2021
@dktapps dktapps reopened this Nov 12, 2024
@pmmp pmmp unlocked this conversation Nov 12, 2024
@dktapps dktapps removed this from the 4.0 milestone Nov 12, 2024
@dktapps
Copy link
Member Author

dktapps commented Dec 19, 2024

This is no longer needed as PHP's WeakMap can now be used for this purpose.

@dktapps dktapps closed this as completed Dec 19, 2024
@dktapps dktapps added Resolution: Obsolete Superseded by other changes and removed Priority: High labels Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: API Related to the plugin API Resolution: Obsolete Superseded by other changes Type: Enhancement Contributes features or other improvements to PocketMine-MP
Projects
None yet
Development

No branches or pull requests

2 participants