Paper
Paper copied to clipboard
More MemoryKey API
So I added a bunch more of the memory keys. Pretty sure I tested one of every type to ensure the conversions were working correctly.
Only ones I didn't add keys for, are the ones without a clear bukkit equivalent class to its type. These are the nms classes I didn't know of a bukkit equivalent for:
- PositionTracker
- WalkTarget
- DamageSource (1.19.4 should make adding API for this nicer)
- Path (just needs a slight re-work of paper's path api impl)
Interesting approach. Thanks for adding that, thought of adding it myself. Had a simpler not finished approach here: https://github.com/WeepingMC/Weeper/pull/1/files
Taking a look at your method, I can simplify mine more, by removing the need for multiple List and Set converters.
Idk what the best way to do it is, have a big chain of instanceof checks, or the way I did it. I didn’t really want to add a ton of instanceof checks just cause I think it’s ugly.
Also, I see you used Vector for BlockPosition. Didn’t think of that, is that what should be used as the Bukkit equivalent of BlockPos? I just did a world-less location.
Vector would probably be preferred, allowing Locations without a world was a mistake
Yeah the instance of chain is ugly but a good min diff solution.
The preferred thing I like to do is an enhanced switch with Pattern matching but this is out of scope because the feature is not even out of preview state. 😢
return switch (object){
case GlobalPos globalPos -> fromNms(globalPos);
case Long longValue -> longValue;
case UUID uuid -> uuid;
case Boolean booleanValue -> booleanValue;
default -> throw new UnsupportedOperationException("Do not know how to map " + object);
}
So under that condition I'm fine with that map. Your way it is much more extendable.
Yeah, pattern matching would be nice. Gonna be a while before Paper gets that though... :laughing:
Ok, made some changes to this.
Yeah, pattern matching would be nice. Gonna be a while before Paper gets that though... 😆
A day later and everything has changed. 🤣
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Bad stale bot. :D
Rebased and reworked a bit. Much cleaner, but I still think this is the way to go over big pattern matching chains.
Rebased for 1.18.1
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Rebased for 1.19. Mojang added Unit memory types, I just used Void, not sure there's a point it adding a Unit enum.
Rebased with all new memory types