TRCStudioDean / LiteCommandEditor

Bukkit/Spigot plugin LiteCommandEditor
3 stars 0 forks source link

question #1

Open Zarkness opened 1 month ago

Zarkness commented 1 month ago

I need help on how to create a command with arguments and each argument has subarguments, for example I am trying to make a command that is /setup and I want that if I put only /setup it will send me an error message saying that arg 1 is missing, then if I put /setup arg1 it will have its own args and the same if I put /setup arg2 and each one if its subargument is missing it will send its own error message and the same if inside arg1 a subargument has subarguments.

Apart from the tab completer showing me all args and subargs etc....

example of command:

    /setup arg1
        test
            subtest
        test2
        test3
TRCStudioDean commented 1 month ago

for example I am trying to make a command that is /setup and I want that if I put only /setup it will send me an error message saying that arg 1 is missing,

Command-Executor:
    'case1': # if only /setup
        Conditions:
        - '{length} == 0'
        Break: true
        Messages:
        - 'Please enter an argument!'
    'case2': # pass
        Messages:
        - 'You are entering an argument: [1]'

This idea provides reference, and other requirements you mentioned later can be edited through this idea

Visit the following link for detailed instructions on placeholders: https://github.com/TRCStudioDean/LiteCommandEditor/wiki/Function-Configuration-Document#Preset-Placeholders

Zarkness commented 1 month ago

but that makes the main command always setup and then each argument can have its subargument?

TRCStudioDean commented 1 month ago

You can distinguish functions from multiple cases by comparing placeholders in the Conditions setting. For more details, please refer to the link provided above

TRCStudioDean commented 1 month ago

BTW this plugin is currently in a snapshot version and I am working on optimizing it as much as possible. I will continue to update it until the official version is released.

Zarkness commented 1 month ago

ok, I thought so that for example if the command is /setup user color

which would be something like what I have

############################################################
# +------------------------------------------------------+ #
# |                        Usage                         | #
# +------------------------------------------------------+ #
############################################################

#This is a configuration file for demonstration purposes. You can refer to the format specifications 
#and annotation content of this configuration file to freely create new command configuration files.
#After setting up, use the command "/litecommandeditor load" to load command configuration file.

#Note: Each command configuration file only corresponds to one custom command.
#Anyone can trigger through "/[Command Name]" or "/[Prefix:Command Name]".
#Please set relevant options such as permissions with caution!

############################################################
# +------------------------------------------------------+ #
# |                  General Settings                    | #
# +------------------------------------------------------+ #
############################################################

#Enable this command configuration.
#Since the command configuration file will be automatically loaded as long as it exists, 
#this option can be used during debugging to prevent loading.
Enabled: true

#Command Prefix & Command Belong
#PS: Spaces cannot be used!
#Example: Command prefix of "/minecraft:gamemode" is "minecraft"
#         Such as "/gamemode", "/tp", "/gamerule" is belong to "minecraft"
#If this option is not filled in, it defaults to "litecommandeditor"
Prefix: 'aeternum'

#Main command name
#PS: Spaces cannot be used!
#Example: Command name of "/gamemode" is "gamemode"
#This option must be filled in, otherwise the configuration file for this command cannot be loaded.
Name: 'hsetup'

#Command aliases (optional)
#PS: Spaces cannot be used!
#Please fill in the other names of this command in this list, 
#which can be used with "/[Alias]" and "/[Command Prefix]:[Command Alias]" to trigger this command configuration file
#Aliases: []

#Command usage permissions (optional)
#This permission applies to the entire command. 
#If the player does not have this permission, they cannot use this command
Permission: litecommandeditor.customcommand.example

#Command description (optional)
#This description will be displayed in the "/litecommandeditor info" or /help command
#Description: None

#Command usage (optional)
#This usage will be displayed in the "/litecommandeditor info" or /help command
#Usage: None

############################################################
# +------------------------------------------------------+ #
# |                  Function Settings                   | #
# +------------------------------------------------------+ #
############################################################

#Command Executor Settings
#Used to handle the execution of this custom command
Command-Executor:
    #Example: main command settings.
    #When the player only uses "/examplecommand", the following functions are triggered:
    'main-command':
        Conditions:
        - '{length} == 0'
        Break: true
        #List of functions, executed from top to bottom
        #If Break is not set to true, it will be executed all the time from top to bottom
        Functions:
            #Case 1: 
            'pass':
                #When the player meets the requirement to have this permission
                Conditions: 
                - 'permission:litecommandeditor.examplecommand'
                #End the function list traversal, i.e. no longer execute the following Case 2
                Break: true
                Messages:
                - '&bLite&3Command&9Editor &f&l>>> &aHere is the execution result of the main command &e"/examplecommand"'
            #Case 2
            'no permission':
                Messages:
                - '&bLite&3Command&9Editor &f&l>>> &cYou do not have permission to use this command!'
    #Examples: sub command settings.
    #When the player uses "/examplecommand... [subcommand]...", the following functions are triggered:
    'sub-commands':
        Conditions:
        - '{length} >= 1'
        Break: true
        Functions:
            'help':
                Conditions:
                - '[1] == help'
                Break: true
                Functions: 
                    'pass':
                        Conditions: 
                        - 'permission:litecommandeditor.examplecommand.help'
                        Break: true
                        Messages:
                        - '&bLite&3Command&9Editor &f&l>>> &a&lCommand help'
                        - '&3- &6/examplecommand help &eView the help'
                        - '&3- &6/examplecommand message &eExample message'
                        - '&3- &6/examplecommand broadcast &eExample broadcast'
                        - '&3- &6/examplecommand command &eExample command'
                        - '&3- &6/examplecommand title &eExample title'
                        - '&3- &6/examplecommand actionbar &eExample action bar'
                        - '&3- &6/examplecommand sound &eExample play sound'
                        - '&3- &6/examplecommand compound &eExample compound functions'
                    'no permission':
                        Messages:
                        - '&bLite&3Command&9Editor &f&l>>> You are not have permission to do this!'
            'user':
                Conditions:
                - '[1] == user'
                Break: true
                Functions:
                    'test':
                        Functions:
                            'Example1':
                                Conditions:
                                - '[2] == color'
                                Break: true
                                Messages:
                                - 'test [2]'
                            'Example2':
                                Messages:
                                - 'The arithmetic expression you entered is incorrect!'
            'unknown':
                Messages:
                - '&bLite&3Command&9Editor &f&l>>> &cUnknown command, please use "/examplecommand help" for assistance.'

#Tab Completer settings
#Used to handle the content that can be automatically filled in through the TAB key when using this custom command
Tab-Completer:
    'sub-commands': 
        Conditions:
        - '{length} >= 1'
        Functions:
            'user':
                Conditions: 
                - 'permission:litecommandeditor.examplecommand.message'
                Recipes:
                - 'user'
            'default':
                Recipes:
                - 'help'

############################################################
# +------------------------------------------------------+ #
# |                   Other Settings                     | #
# +------------------------------------------------------+ #
############################################################

#Inner JSON components
JSON-Components: {}

#Item collection
Item-Collection: {}
TRCStudioDean commented 1 month ago

Yes, you can refer to Example.yml, but I will also provide more configuration files for reference later, which may take a few days. Thank you for your support.

Zarkness commented 1 month ago

you're welcome, the problem with the one I have is that it doesn't work because I have a function inside test, besides that it doesn't show me in the autocomplete the arg after user

Zarkness commented 1 month ago

I have this command in a plugin but I want to pass it to yours, the command what it does is if the command /setup user accent <color code, legacy, hex or minimessage> works if it does not send an error message, how could I make this command in your plugin

image

TRCStudioDean commented 1 month ago

I see...I need some time to understand it

TRCStudioDean commented 1 month ago

If you are willing to wait, I will try to provide you with a reference configuration file later, but I have found that there seem to be some features that are not yet available in LCE, so I may also take this opportunity to improve the functionality of this plugin in the next snapshot version

Zarkness commented 1 month ago

no problem, as far as waiting for that, but with that update I could already do what I told you?

TRCStudioDean commented 1 month ago

Yes, I found that LCE currently lacks a feature that can determine regular expressions through Conditions. As long as I make it, LCE will be able to meet all the requirements in the configuration file you provided above

Zarkness commented 1 month ago

Ok and how would the configuration look like?

Zarkness commented 1 month ago

for example I am trying to make a command that is /setup and I want that if I put only /setup it will send me an error message saying that arg 1 is missing,

Command-Executor:
    'case1': # if only /setup
        Conditions:
        - '{length} == 0'
        Break: true
        Messages:
        - 'Please enter an argument!'
    'case2': # pass
        Messages:
        - 'You are entering an argument: [1]'

This idea provides reference, and other requirements you mentioned later can be edited through this idea

Visit the following link for detailed instructions on placeholders: https://github.com/TRCStudioDean/LiteCommandEditor/wiki/Function-Configuration-Document#Preset-Placeholders

with this you do not help me much about what I asked you since you do not show me how to create a command with subcommand1 and subcommand2 and then autocomplete it.

TRCStudioDean commented 1 month ago
Enabled: true
Prefix: 'litecommandeditor'
Name: 'setup'

Command-Executor:
    'Case1':
        Conditions: 
        - '{sender_type} != Player'
        Break: true
        Messages: '&cYou must be a player!'
    'Case2':
        Conditions: 
        - '{length} >= 2'
        - '[1] == user'
        - '[2] == accent'
        Break: true
        Functions:
            'Case1':
                Conditions:
                - '{length} == 2'
                Break: true
                Messages: 
                - '&c&m                    &r &c&lERROR! &c&m                    '
                - '&cFalta el argumento prueba con un codigo de color, ya sea legacy o hexadecimal o minimessage'
                - ''
                - '&c&m                                               '
            'Case2':
                Conditions:
                - '!Matcher:^(#([A-Fa-f0-9]{6})|<color:(#([A-Fa-f0-9]{6})|([a-zA-Z_]+))>|&[0-9a-fA-F])$:[3]'
                Break: true
                Messages: 
                - '&c&m                    &r &c&lERROR! &c&m                    '
                - '&cPon un codigo de color valido, prueba con un codigo hexadecimal, MiniMessage o legacy'
                - ''
                - '&c&m                                               '
            'Case3':
                Commands: 'server:itsmymeta set {sender} user_accent_color [3]'
                Messages: '%itsmymeta_prefix% %itsmymeta_Server-Name-Color-default% #0055FFAhora estas usando el color &e%itsmymeta_Color-Code-Show-Accent%'
    'Case3':
        Messages:
        - '&c&m                    &r &c&lERROR! &c&m                    '
        - '&cFalta el argumento prueba con un codigo de color, ya sea legacy o hexadecimal o minimessage'
        - ''
        - '&c&m                                               '

Tab-Completer:
    'Case1': 
        Conditions: '{length} == 1'
        Recipes: 'user'
    'Case2': 
        Conditions: '{length} == 2'
        Recipes: 'accent'

Setup.yml

You need to update to snapshot 3 version to use it.

Command is "/setup user accent [Hexadecimal]"

In theory, this is the configuration file format that meets your needs, you can refer to it.
By the way, since I don't have your server-side environment here, I cannot achieve its true effect (such as using Placeholder API in the expression), but the command's judgment logic is basically fine. {2BB58EFA-AC24-4558-BD4F-A88F3458B81E}

Zarkness commented 1 month ago

Until 11 pm Spain time, I can't prove anything, at that time I will tell you, do not close the issue for now

TRCStudioDean commented 1 month ago

ok, I will wait for your message This is China time, if you need help, you will have to wait until at least 10am to receive a response.

Zarkness commented 1 month ago

I'm testing it and it goes pretty well but the weird thing is that I put for example &b or #FFFFEE or any of what allows the regex and always sends me the error message, does not accept the regex, try the regex on the page regex101 in case it was something wrong but everything was fine, the snapshot I used is the 4, and in the end it was a little later than the time I told you

TRCStudioDean commented 1 month ago

Perhaps it's because the expression in your previous plugin couldn't be directly used with LCE. Here, I tried changing the regular expression and it worked for color codes in actual testing. You can try again.

Conditions:
- '!Matcher:^(#([A-Fa-f0-9]{6})|#([A-Fa-f0-9]{6})|([a-zA-Z_]+)|&[0-9a-fA-F])$:[3]'
Zarkness commented 1 month ago

I just put that one and it still happens the same look at the video, besides you removed a part of the regex that was necessary which is the .

instead if I put this only this regex [0-9a-fA-F] if it works, but it accepts even without putting the & and I want you need to put the & and should accept the one that happened to you before because it has no fault, because as I said I went to this page to check that this well https://regex101.com/

besides this regex ^(#([A-Fa-f0-9]{6})|<color:(#([A-Fa-f0-9]{6})|([a-zA-Z_]+))>|&[0-9a-fA-F])$ should work since what it does is to detect if the value begins with #, or or & if not, we give an error message and the one you gave me if I put it without # or &, if it works for me.

https://github.com/user-attachments/assets/a4b1b72e-d422-44a5-b026-b0e944443958

image

TRCStudioDean commented 1 month ago

I understand. After testing, I confirmed that this is a bug because the color symbol in the content you entered was automatically replaced. I will fix it in the next version. However, the<color: [color]>placeholder is a feature of the previous plugin and cannot be used by LCE. Perhaps you should consider using other features instead.

Zarkness commented 1 month ago

<color:> is from minimessage https://docs.advntr.dev/minimessage/format.html so it should accept it but the plugin should detect if the value of argument 3 matches any of those and then if it matches it should send the message that it worked.

as it is in the regex it should accept any regex that you put in it as if instead of <color:> it is {kriptin:<color code>} or any other thing in itself the command when the user executes it should look like this

/setup user accent &b (if you want to use legacy colors)
/setup user accent #FFFFEE (if you want to use hexadecimal colors)
/setup user accent <color:#FFFFEE> (if you want to use minimessage colors)
/setup user accent <color:yellow> (if you want to use minimessage colors)
/setup user accent <yellow> (if you want to use minimessage colors)

that is how the result that accepts the command that will pass you from the other plugin will look like

TRCStudioDean commented 1 month ago

Okay, I will consider making LCE compatible with it, but currently I need to fix the current bug first, at least so that legacy color and hexadecimal color can be used

Zarkness commented 1 month ago

without problems, but it is rare that to accept a regex with the content that is as for example in this case a color code needs compatibility, it would be that even if it is a color code in that case is a value that you give to the argument 3 and should not be necessary.

So what you should do is without needing to add compatibility to minimessage or any other color format, check if the argument 3 agrees with any part of that regex and if it agrees not to send the error message.

the command that will show you the other plugin the condition what it does is to check if the command is setup, and is 3 arguments, the argument 1 is user, the 2 is accent and the 3 matches any part of the regex runs the action setup_accent_color and in the action setup_accent_color the argument 3 takes it as text to give that value to a placeholder

  - '%main_command% startsWith /setup and %args_length% >= 3 and %arg_1% == user and %arg_2% == accent and %args_length% >= 3 and %arg_3% matches ^(#([A-Fa-f0-9]{6})|<color: (#([A-Fa-f0-9]{6})|([a-zA-Z_]+))>|&[0-9a-fA-F])$ execute setup_accent_color
TRCStudioDean commented 1 month ago

Yes, ultimately, the problem lies in its automatic replacement of color symbols. As long as I fix it, maybe everything can be used normally

Zarkness commented 1 month ago

okey

Zarkness commented 1 month ago

another thing that would be nice is to accept .yml files that are inside folders and nested folders for further organization, something like this custom placeholders plugin.

image

TRCStudioDean commented 1 month ago

I will consider

Now you can update to snapshot 5 version for testing. When I was testing it, it worked perfectly. :)

BrokenDreamStar commented 1 month ago

I am his teammate. He just finished updating and has something to attend to. I will reply to you on his behalf. By the way, you need to include the regular expression in double quotation marks because <color:[]> contains a colon, which can cause it to be recognized as a conditional expression

Zarkness commented 1 month ago

What I told him yesterday I can't test the update until yesterday, as soon as I get home from work I will test it and let you know.

Zarkness commented 1 month ago

So it would have to be something like this,

right now I can only reply from the GitHub mobile app

conditions:

TRCStudioDean commented 1 month ago

So it would have to be something like this,

right now I can only reply from the GitHub mobile app

conditions:

  • '!matcher:"^(#([A-Fa-f0-9]{6})|<color: (#([A-Fa-f0-9]{6})|([a-zA-Z_]+))>|&[0-9a-fA-F])$":[3]'

Yes, everything will proceed perfectly
Your suggestion will be adopted in the next version

Zarkness commented 1 month ago

That's asking your partner what he had told me before, not a suggestion.

TRCStudioDean commented 1 month ago

another thing that would be nice is to accept .yml files that are inside folders and nested folders for further organization, something like this custom placeholders plugin.

image

I mean

Zarkness commented 1 month ago

Okay, I thought you were referring to what I asked your partner.

Zarkness commented 1 month ago

As you can see in the video, the command that is in red is the one of the other plugin and the one that is in white and with hylarion: is the one of your plugin.

The placeholder Color-Code-Show-Accent, if you look what it does is to catch the placeholder user_accent_color and go through several revisions until you get to the message of not working, to put between the code and the # or & to prevent it from parse and thus to be able to show it.

The one that this the color code in the chat this in yellow is the one of the other plugin that the other plugin is called conditionalevents.

The one that says it does not work or the color code in white is the one of your plugin.

The conditionalevents what it does is to pass it as text not as color code.

And yours should do the same, because when in yours I use the placeholder user_accent_color anywhere if mysteriously catches the colors as long as they are the legacy or hex, instead minimessage does something strange gives the color of the hex code but you put the when in the other plugin the value is still <color:> but does not show the <color:>, that means that in yours there is some problem when you create a command and you pass a color code.

Besides if in the plugin that I use here that is the itsmymeta if you put the color code directly with the command /itsmymeta set user_accent_color &b and then put /papi parse me %itsmymeta_user_accent_color% returns &b even when I do it with the conditionalevents also returns &b, instead with your plugin when I give the value &b what returns is empty.

https://github.com/user-attachments/assets/c0f5c5c3-7bb3-423e-b1d7-3e1f668248df


then with another plugin that is one of the ones I use to create custom placeholders, in this case is with the one called itsmyconfig has a symbol-prefix system that what it does is in plugins that do not support minimessage and you can not use placeholders so you can.

If you look at the picture of the configs it is the same value, however in yours it shows it that way and in the other one it shows it well.

There must be some problem in your plugin with things like the color codes and this plugin, because I tested the feature of this plugin in many other plugins and it works without problem, example plugins ajparkour, conditionalevents, and most plugins that send content to chat

image

![image](https://github.com/user-attachments/assets/b11928a8-3f67-4e33-b16e-21012228b8eb

Zarkness commented 1 month ago

even it does not show the color code when I put it in the tab-completer I have to put &&r but it does not work because when it autocompletes it puts me &§r1 instead of &1, when it should show there the color code or if you want that there you can put color, put some way that the one that shows and the one that autocompletes are different.

image image

TRCStudioDean commented 1 month ago

The placeholder Color-Code-Show-Accent, if you look what it does is to catch the placeholder user_accent_color and go through several revisions until you get to the message of not working, to put between the code and the # or & to prevent it from parse and thus to be able to show it.

The one that this the color code in the chat this in yellow is the one of the other plugin that the other plugin is called conditionalevents.

The one that says it does not work or the color code in white is the one of your plugin.

The conditionalevents what it does is to pass it as text not as color code.

And yours should do the same, because when in yours I use the placeholder user_accent_color anywhere if mysteriously catches the colors as long as they are the legacy or hex, instead minimessage does something strange gives the color of the hex code but you put the color: when in the other plugin the value is still but does not show the , that means that in yours there is some problem when you create a command and you pass a color code.

Besides if in the plugin that I use here that is the itsmymeta if you put the color code directly with the command /itsmymeta set user_accent_color &b and then put /papi parse me %itsmymeta_user_accent_color% returns &b even when I do it with the conditionalevents also returns &b, instead with your plugin when I give the value &b what returns is empty.

I understand, this is indeed due to LCE's inadequate design considerations. I will continue to improve it in future versions. Thank you for your cooperation :)

even it does not show the color code when I put it in the tab-completer I have to put &&r but it does not work because when it autocompletes it puts me &§r1 instead of &1, when it should show there the color code or if you want that there you can put color, put some way that the one that shows and the one that autocompletes are different.

This bug will be fixed in the next version

Zarkness commented 1 month ago

ok, I will be waiting for both updates, including the nested folder support, for better organization of the commands.

Zarkness commented 1 month ago

then with another plugin that is one of the ones I use to create custom placeholders, in this case is with the one called itsmyconfig has a symbol-prefix system that what it does is in plugins that do not support minimessage and you can not use placeholders so you can.

If you look at the picture of the configs it is the same value, however in yours it shows it that way and in the other one it shows it well.

There must be some problem in your plugin with things like the color codes and this plugin, because I tested the feature of this plugin in many other plugins and it works without problem, example plugins ajparkour, conditionalevents, and most plugins that send content to chat

image

image

I'm trying the last version you uploaded to spigot and now I get this instead of how it should look like in the previous image of the conditionalevents.

image

and about the setup command the color code is the same as before

https://github.com/user-attachments/assets/492904bf-e502-48a4-97f1-9882886f6e4f

TRCStudioDean commented 1 month ago

Not fixed yet, it will take some more time

Zarkness commented 1 month ago

okey

TRCStudioDean commented 1 month ago

If I finish it, I will tell you here

Zarkness commented 1 month ago

hello, is there any news?

Zarkness commented 1 month ago

a question, how can I make a say command or a command which is to announce to all users or specific user a message that I write from the chat.

example I create the command announcements, and in minecraft I put the command

/announcements hello, x............................. has just been implemented and the message that I put goes out in chat

at the moment what I have is with [1]...[40] but if it doesn't reach 40 which is only ten it shows [11]...[40], is there any way to avoid that?

TRCStudioDean commented 1 month ago

I've been quite busy lately, and I'm working on fixing a bug in another plugin. LCE will introduce built-in placeholders related to string processing that allow multiple arguments to be linked in the future, but this will take some time.

Zarkness commented 1 month ago

okey thx

Zarkness commented 3 weeks ago

hi any news?

TRCStudioDean commented 3 weeks ago

I just finished working today, and we can resume LCE updates starting next week

TRCStudioDean commented 3 weeks ago

Now you can use this placeholder {color:[text]}, all color symbols and hexadecimal colors in [text] will not be automatically converted. See wiki for details.