Solved custom command in config

Discussion in 'Plugin Development' started by YoloSanta, Jun 14, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    YoloSanta

    hey guys I was just wondering, if I were to make a plugin to where I have a player make up a command to be able to put it in the config how could I do that for example
    Config.yml (open)

    Code:java
    1. # KillsCommand by YoloSanta v1
    2.  
    3. # Number is kills and after colon is command
    4. # Ex, 3:give %user% diamond 1
    5. Commands:
    6. 3:give %user% diamond 1
    7. 5:effect %user% minecraft:REGENERATION 5 3
    8.  
    9.  


    I have not started making this plugin but is a question off the top of my head and I don't know how I would even start
     
  2. Offline

    Zombie_Striker

    @YoloSanta
    Using command maps, you can register a new aliases for all custom commands to one command class, and then let that class handle executing/setting things depending on the config values.
     
    RcExtract likes this.
  3. Offline

    RcExtract

    You should save them into a list. Then when a player performs a command, check if the command label is the same. Then check the argument. If the custom command provided has a placeholder for example %player%, find the player and cancel command if not found. If the placeholder is %item% give them the item by finding the item from the enum with the value, etc.

    Sent from my LG-H860 using Tapatalk
     
  4. Offline

    YoloSanta

    Thanks I think I semi understand!
     
  5. Offline

    Horsey

    @Zombie_Striker a tardy, but much easier method is to listen for a PlayerCommandEvent and if the command executed matches the alias you want to use, you could cancel the command and use Player#performCommand("command");
     
Thread Status:
Not open for further replies.

Share This Page