Solved Command not executing

Discussion in 'Plugin Development' started by flash1110, Feb 1, 2015.

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

    flash1110

    Basically, I'm coding a plugin that when you do a command a region, using worldguard, becomes created.

    This is the code:

    Code:
    package me.flash1110.txplugin;
    
    import org.bukkit.ChatColor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.Command;
    import org.bukkit.entity.Player;
    
    import com.sk89q.worldedit.BlockVector;
    import com.sk89q.worldedit.bukkit.selections.Selection;
    import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
    
    public class SetCommand {
       
        public Selection sel;
       
       
       
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            if (!(sender instanceof Player)) {
                return true;
            }
            Player p = (Player) sender;
           
            if (cmd.getName().equalsIgnoreCase("setkoth")) {
                if (!p.hasPermission("koth.set")) {
                    p.sendMessage("Works");
                    p.sendMessage(ChatColor.RED + "You lack permission to use that command!");
                    return true;
                }
               
                sel = ((Main) Main.getPlugin()).getWorldEdit().getSelection(p);
               
                if (sel == null) {
                    p.sendMessage(ChatColor.RED + "You must select a region first!");
                    return true;
                }
               
                 ProtectedCuboidRegion region = new ProtectedCuboidRegion(
                          "koth",
                          new BlockVector(sel.getNativeMinimumPoint()),
                          new BlockVector(sel.getNativeMaximumPoint())
          );
                 
                  ((Main) Main.getPlugin()).getWorldGuard().getRegionManager(p.getWorld()).addRegion(region);
         }
            return true;
    }
    }
    
    However, when I install it onto my server, the output is just "/setkoth"
     
  2. Offline

    Skionz

    @flash1110 You never invoked the method and Bukkit will not invoke it either because it does not implement CommandExecutor and it is not registered.
     
  3. Offline

    flash1110

    @Skionz

    Ah alright, thanks so much. I fixed it.
     
Thread Status:
Not open for further replies.

Share This Page