$script$ feature suggestion #169


  • New
  • Enhancment
Open
  • Digital_Beast created this issue Mar 26, 2019

    Hello
    This is more of a feature request than an issue.. 

    in the $script$ part of this plugin, can you add in a way to check if a command contains anything specific? 
    My use would be, to check if the command contained other than alphanumerical characters in the arguments.  


    I am making a custom GUI for name-color and nickname settings with MyCommands icon-menu, and set up so users decide their username with a custom command, using a custom variable. This variable is synced across my network using another powerful plugin. 
    The issue is that they can bypass my permissions because when I force them to do "/mynick $arg1" The $arg1 can contain color codes as "&1" or whatever the creative person wants to use.  So if I could check if the command contained specific characters I could avoid this issue. 
    So the user can bypass my permission system and set his desired color typing "/mynick &1Nickname". I want to disallow the "&" character in this command.

    You can in the pastebin, (line 13-17) see my attempts using something similar that is shown in the help files. and I think I've tried at least 20 variations of this feature, but I gave up, commented it out, and asked here) 

    Additionally, here is a pastebin and a .gif showing what I made so far, but it's not showing the use of color codes in the /mynick command.
    https://pastebin.com/sTYvRL8u
    https://imgur.com/xnOgUUa


    Example of how I think it could look in the commands file. 
    Mynick:
      command: /mynick
      type: RUN_CONSOLE
      runcmd:
       - "$Script$%if%$arg1{contain:&}"   <--- My thought how to define what to look for.. 
       - "$Script$%PlayerData%mynick=$player"
       - "$text$&aYour nickname contained illegal characters and is now saved as &e$player&a."
       - "$Script$%else%"
       - "$Script$%PlayerData%mynick=$arg1"
       - "$text$&aYour nickname is now saved as &e$PlayerData%mynick%&a."

       - /sync console all mynick $player $arg1
      permission-required: false
      required_args: 1
      require_all_arguments: true

    I run MyCommand version 5.3.4 on Spigot version 1.12.2..

    I hope you will consider this as this will improve the usage of this plugin for me a lot.  Also, allow me to thank you for this wonderful plugin, my server would be much less fun without it.. 
    Cheers 
    Digi

    (Edit1: Added a .gif to show my use-case)
    (Edit2: Added a Pastebin to show my working config)
    (Edit3: Cleaning up and polishing my explanations)

  • Digital_Beast added the tags Enhancment New Mar 26, 2019
  • Digital_Beast edited description Mar 26, 2019
  • Digital_Beast edited description Mar 26, 2019
  • Digital_Beast edited description Mar 26, 2019
  • ivanfromitaly posted a comment Mar 30, 2019

    The script line for the "contains" is "$Script$%if%$arg1.contains=&1" and not "$arg1.contains==&1", one = (equal) less.

     

    Anyway, i tested and doesn't work completly fine leaving here only the &. A Workaround for now is doing this :

     

    - "$Script$%if%$arg1.contains=&1<or>$arg1.contains=&2<or>$arg1.contains=&3" ecc ecc. In this way works. I'll see to make a better "contains" later, but for now, you can use this way here.


    Edited Mar 30, 2019
  • Digital_Beast posted a comment Apr 1, 2019

    Thank you Ivanpro, hearing you looking into this in the future is great news! :) 
    Also many thanks for providing me with a workaround, i will get to testing it right away!
    Thanks again :)


To post a comment, please login or register a new account.