HelpChat / DeluxeMenus

DeluxeMenus but open source!?
https://wiki.helpch.at/clips-plugins/deluxemenus
MIT License
61 stars 31 forks source link

Issue/78 #99

Closed BlitzOffline closed 3 weeks ago

BlitzOffline commented 1 month ago

NOTE: This PR is built on top of #64. Please merge that one before merging this one.

This fixes a side effect of our changes regarding parsing placeholders inside arguments.

We have previously made some changes to how arguments and placeholders are handled. How it used to work:

Parse Arguments
Parse Placeholders

How it works now:

Parse placeholders
If enabled, parse placeholders inside arguments
Parse arguments

These changes were made because we've realized that letting players parse arbitrary placeholders is bad. In my opinion, placeholders should be simple mapping operations without any side effects. Not everyone agrees or sticks by this rule. Some placeholders do things such as giving items to players, executing commands, etc. when they are parsed.

When I've made the changes, I have allowed menu designers to enable placeholder parsing inside arguments on a per-menu basis. I have missed that parsing arguments after parsing placeholders, does not allow menu designers to use arguments inside placeholders anymore.

This PR fixes this by adding a new per menu option parse_placeholders_after_arguments. This option defaults to the false value and this is how it would work:

If parse_placeholders_after_arguments is disabled:

    Parse placeholders
    If enabled, parse placeholders inside arguments
    Parse arguments

If parse_placeholders_after_arguments is enabled:

    If enabled, parse placeholders inside arguments
    Parse arguments
    Parse placeholders

Enabling this option reverts to parsing working how it was before. We are giving menu designers the choice of taking risks but we are disabling the option by default.

Closes #78

Tested on:

This server is running Paper version git-Paper-496 (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 7ac24a1 on ver/1.20.4)
You are running the latest version
Previous version: git-Paper-365 (MC: 1.20.4)

Tested with a simple ParseOther + Vault placeholder and a player argument. As it can be seen, with the new option disabled, the placeholder returns the default value from the vault placeholder since it tries to parse the placeholder for the argument key ({player}) and not the value of the argument. This is fixed with the new option enabled. image image image