Solved Cancel command execution

Discussion in 'Plugin Development' started by Xp10d3, Feb 24, 2020.

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

    Xp10d3

    Hello,
    Is it possible to cancel the execution of a command? Like in general? I have this:
    Code:
    package per.world.commands;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    
    public class Commands implements CommandExecutor {
       
        Core core = Core.getPlugin(Core.class);
        public Commands(Core core) {
            this.core = core;
        }
       
        FileConfiguration config = core.getConfig();
       
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String lable, String[] args) {
            int i = 0;
            for (String key : config.getConfigurationSection("per.commands").getKeys(false)) {
                if (cmd.getName().equalsIgnoreCase(key)) {
                   
                }
                i++;
            }
            return false;
        }
       
    }
    
    
    And was wondering if I can cancel the command. I am basically trying to make PerWorldCommands. The current one doesn't work.
     
  2. Offline

    KarimAKL

    Xp10d3 likes this.
  3. Offline

    Xp10d3

    How would I get the command that has been run then? Cause if I am checking for specific commands and I use PlayerCommandPreprocessEvent that listens on every single command, how would I use the listener to get the command?
     
  4. Offline

    wand555

    You do event.getMessage()
     
  5. Offline

    Xp10d3

    Okay, thanks! Marking thread as solved :D
     
Thread Status:
Not open for further replies.

Share This Page