starscript icon indicating copy to clipboard operation
starscript copied to clipboard

[Change] Added `setRaw` and `removeRaw` to `ValueMap`

Open CDAGaming opened this issue 1 year ago • 3 comments

  • These two functions have been added for two reasons:
    • A) Just some basic cleanup to consolidate some repeat logic
    • B) By having the ability to raw remove and raw set values, this commit also gives the user a bit more general control over setting/getting data from the ValueMap

In my use case, CraftPresence, this change was implemented here as a way to re-implement ValueMap#set to work with my placeholder mappings (My mod has the abilities to search for and see previews of any placeholder, hence the separate storage and why just using getGlobals() wouldn't work easily.

This is more so something for backend usage, rather then anything that would be useful to the frontend, besides the additional change of using a ConcurrentHashMap for ValueMap to be a bit more thread-friendly.

CDAGaming avatar May 20 '24 02:05 CDAGaming

i dont really understand the point of getRaw and setRaw, do you have an example use case for them?

to my knowledge, the dot notation is already opt-in as you can add ValueMap objects already. the only differences is that getRaw/setRaw would let you register variables with dots in the name, but that would probably cause issues with the way the parser is built as . is a reserved character

crosby-moe avatar May 20 '24 04:05 crosby-moe

Re-marking as draft, since my original testing for the getRaw and setRaw changes failed.

CDAGaming avatar May 20 '24 05:05 CDAGaming

Use-case info in initial description, took a bit of time to get things settled, but things should be ready to be looked at.

CDAGaming avatar May 20 '24 08:05 CDAGaming