Mwexim / skript-parser

A standalone and improved implementation of the Skript language for use outside of Minecraft servers.
MIT License
49 stars 15 forks source link

Way to make a sort of 'entry' + Validator for Elements #124

Closed ItsTheSky closed 1 year ago

ItsTheSky commented 3 years ago

Hello! With Skript v2, we got a useful object called SectionValidator, here to validate a bunch of Node (skript-parser consider them as Element if I'm not wrong) We were able to test an entire SectionNode for the validator, and check for potential sections (same thing as here) and entries. Here's go my second point: Entry would be such as condition, but followed by the string we want, example:

entryname: value

It could be used for deep configuration, such as (example):

define webserver: # A SkriptEvent
    port: XXX # Entry
    on request: # Section
        # </>

Defined by the SectionValidator:

new SectionValidator()
    .addEntry("port", false) // Optional ?
    .addSection("on request", false); // Optional ?

What do you think about that?

Mwexim commented 3 years ago

I don’t think adding the validator itself is necessary, since this is perfectly possible with skript-parser’s restriction system for section.

I think it would be beneficial though to implement the following:

Good ideas!

WeeskyBDW commented 3 years ago

an EntryEffect class that can hold one single entry. a CategorySection that holds specific entries that are either necessary or not (kind of what you proposed, but as a syntax class rather than a utility method) Imo, it can be better to add a real support for entries. I mean, when parsing, if the parser found a entry, it try to see if current section have this section. If the entry isn't in a section, then the parser return an error. Same if entry isn't register for the current section or if a required entry isn't set

Mwexim commented 3 years ago

Imo, it can be better to add a real support for entries. I mean, when parsing, if the parser found a entry, it try to see if current section have this section. If the entry isn't in a section, then the parser return an error. Same if entry isn't register for the current section or if a required entry isn't set

That'd be roughly the idea.

Mwexim commented 1 year ago

Feature was added in #126, closing the issue.