FancyMcPlugins / FancyNpcs

FancyNpcs is a simple, lightweight and fast npc plugin using packets
https://modrinth.com/plugin/fancynpcs
MIT License
100 stars 23 forks source link

Replace map with weak set #42

Closed ghost closed 10 months ago

ghost commented 10 months ago

Current implementation never removes player UUIDs from maps and uses Map for things that can be replaced with Set. This PR replaced Map with Set (with weak set created via WeakHash, Java does not have native weak sets) and stores Player objects insteads of UUIDs which should be automatically cleaned when player is not online and Garbage Collector is running in any free time. EDIT: Also players is removed manually on quit now, just to make it cooler.

ghost commented 10 months ago

Closing due to some other optimizations I've found and will be PR'ing in the future