Skip to content

Refactor/Clarify logic of tracking and collecting player and entity's death context#200

Merged
Dreeam-qwq merged 4 commits intomasterfrom
refactor/death-context-collection
Feb 9, 2026
Merged

Refactor/Clarify logic of tracking and collecting player and entity's death context#200
Dreeam-qwq merged 4 commits intomasterfrom
refactor/death-context-collection

Conversation

@Dreeam-qwq
Copy link
Member

@Dreeam-qwq Dreeam-qwq commented Feb 9, 2026

Note

Some class or variable namings refer to the suggestions of ChatGPT, to follow the "best practice" of related project standards. I'm not sure whether they are entirely correct.
If you have any better ideas or naming, welcome to contact me, open an issue, or any other way to let me know.

Renamed PlayerManager / EntityManager to PlayerCtx / EntityCtx, meaning the "context of the player / entity", to be more consistent with its actual function. Related variable names are also renamed.

The original name *Manager does not describe the function of the class clearly; it actually has no relationship with "managing" or managing the states of players.

The player context functions as a "wrapper" of the Player instance, but stores additional useful context of the death, like last entity damager, etc., used for building death messages.

Also, only create a new instance for the player context on player join and plugin load, and remove it when the player quits to prevent a memory leak happens and be friendly to big networks.
The original logic actually has a memory leak, because the map keeps adding players, but doesn't remove them when a player quits.

Player context creation in other stages is also removed, like during the entity damage stage, which is unnecessary, and the condition will never be reached.

Useless player online checks are removed in many places; we can assume that the player is online when the damage event or death event is triggered.

@Dreeam-qwq Dreeam-qwq merged commit c08e41f into master Feb 9, 2026
1 check passed
@Dreeam-qwq Dreeam-qwq deleted the refactor/death-context-collection branch February 9, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant