Magic

Magic

190k Downloads

Request to add new class that can read placeholders

vajuvung opened this issue ยท 4 comments

commented

request to add new class that can read palceholder

Modify Vartiables can read placeholders but only numbers. So new class actualy can read and i mean ONLY read placeholder
example

- class: Placeholder
  placeholder: "%biome%"
  value: Desert

if placeholder has name Desert then ssuccess, if not then stop action

commented

Hello, I am a new contributor. I would like to try and work on this issue. Can you please elaborate a little more on what exactly is the requirement.

commented

Hello, @Eesha04 ! If you'd like to try to implement this and PR, that'd be nice :)

It should be a pretty easy task. This would be another "Check" action, I would perhaps name it CheckMessage to fit with the general language of messages, since this is not strictly about placeholders.

Take a look at the CheckTrigger action for a good example- you would want to extend CheckAction and implement isAllowed to do a simple string comparison.

I would suggest two parameters, message1 and message2.

The simplest case is just comparing the two strings, after calling context.parameterize() on it, which will take care of translating any builtin Magic properties (e.g. @pn, @spell, etc) as well as any placeholders (e.g. %biome%)

I think this would be a good place to start.

A nice second step would be to add an operation parameter that would default to equal but could be other options like greater, less .. not sure there is a precedent for this in the plugin, but we'd want to make an enum and probably centralize the comparison logic.

If using something other than "equal" it would try to parse both messages as numbers and then compare them numerically. This could be used to check numeric placeholders in some useful ways, I'm guessing.

Let me know if you do attempt this so I don't do it myself ;)

commented

Also add target placeholders like %target:player_name%
And add more built-in placeholders like @h (health of the entity) @th (target health) etc

commented

Thank you so much @NathanWolf for explaining the issue. I will really try my best to work on it.