Should I use PlayerCommandPreprocessEvent as a bypass to plugin.yml?

Discussion in 'Plugin Development' started by dingus007, Aug 20, 2013.

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

    dingus007

    So the plugin that I'm creating allows you to set custom commands to teleport to warps. I have everything with the config all set up, but I am using PlayerCommandPreproccessEvent as a bypass for adding commands to plugin.yml. Should I use that or another method? I am using this method because it is the method used before sending a command, so I am using player.performCommand( String command ) to send the command.
     
  2. Offline

    Rockon999

    dingus007
    Well if you are allowing users to set their own commands I'd recommend using the event. Others may disagree, but that is my opinion :)
     
    Samthelord1 likes this.
  3. Offline

    Samthelord1

  4. Offline

    Saposhiente

    Allowing users to set their own commands is dangerous; they might overwrite vital server operation commands with their custom commands. CommandPreprocessEvent is not the only way to do that; better would be, after registering the command, getCommand("commandName").setExecutor(myCommandExecutor) and use the CommandExecutor onCommand(...) function. Better than having users register their own commands, however, is to have one main command which accepts an argument that correspond to what the users have set. For warps, you would have one command to create eg /makeWarp warpName, and then users can use /warp warpName. Or, you can reserve certain warp names to combine those functions into one command, with /warp create warpName and /warp warpName
    CommandPreprocessEvent is primarily for when users are using commands of *other* plugins, and you want to sometimes detect and/or prevent the command use in a way that the other plugin doesn't support.
     
Thread Status:
Not open for further replies.

Share This Page