Open Wundero opened 7 years ago
So I've been playing with the idea of the parser system, and I've come up with some ideas:
%...%
placeholders and json/hocon on {...}
placeholders{player}
) would parse as if that was the id (like {id:player}
)null
otherwise (if they register it as non-optional, just don't call placeholder parsing method)type
shortens to t
, etc. If there are 2 or more parts that start with the same letter, shorthand would be disabled)I still need to figure out how this system might include support for placeholder-object attachment.
I like the Cause and Context system because it's what I already know when learning Sponge. I've read over your first idea a couple times now and I still can't wrap my head around it.
It's likely that I will adopt something like that, though I think using contexts in some way is more important since they are named. If there is no source but an observer exists, the placeholder may think the observer is the source (which may or may not be desirable), so I have to do some thinking about what to do.
Oops clicked the wrong button.
I've read through this many times now and am still confused. Won't be able to help out until I see some commits as a start. :(
I am still figuring out how I want to go about making this update as there are a lot of things that would have to be changed, and if I should wait until 8.0 hits a snapshot stream to start or just force 7.0 instead. I will create commits at some point which lay out the groundwork but I have some thinking to do first haha. I was on holiday and so had no time to work on this the past couple of weeks, but I might be able to get some things done soon (I hope).
Another rough idea I have:
I would like to create an asynchronous handling system for placeholders; that way, if a placeholder takes a long time to parse (for instance a mysql query), it does not slow the main thread. Ideally, all placeholders should be asynchronous since they are not supposed to modify any Sponge objects, and thus asynchronous computation is fine (we do not care about values that may change during execution, since we will only be grabbing it once anyways), however placeholders like the sound
placeholder may not support it. If a placeholder does not support asynchronous computation, it will be parsed synchronously and then wait for the remaining async parses to complete. Realistically, if I handle this properly, there should be no issues with having parts be synchronous and parts not, due to the fact that parsing is the only real external handling and each parser should be independent. The javascript parser may present an issue if called async and that worries me, so what I might do is use the classwriter from ASM to determine if calls are made to the placeholder service parsing, and if they are enforce that that placeholder is synchronous.
CompletableFuture
should allow me to do most of this properly, and I will probably use something like a ResultBuilder
that supports concurrent modification (with a concurrent hash map probably) to combine the results and then return them.
This is my sort of idea list for version 5 that I would like to put out before working on it. Figured this time it would be better to make the complete update process transparent as migrating from 3 to 4 was quite interesting.
I have two streams, with separate ideas, that can be implemented:
@Token
parameters in a method, parsed out as _ separated in order from left to right@Nullable
-> if parsing fails, try parsing to the next parameter from the same tokenOR
ValueParser
,Parameter
, etc.) to parse a placeholder's tokens@Async
or something)As well as those two streams, there would be some common ground:
{id:player,type:name}
type:name
forid:player
would directly correspond to a functiongetName
in this case).That's all I've got for now but it's pretty big so I will leave it as is. for a bit. Any suggestions are appreciated, as always