package me.km.api;

import java.util.List;
import me.km.KajetansMod;
import me.km.permissions.Permissions;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;

public class WorldEditCommand extends ModuleCommand
{
    private final ICommand command;
    
    public WorldEditCommand(ICommand command, Module m) 
    {
        super(command.getName(), m);
        super.setDescription("A worldedit command");
        super.setUsage(command.getUsage(null));
        super.setPermission(Permissions.WORLDEDIT);
        this.command = command;
    }

    @Override
    public boolean execute(ICommandSender cs, String[] arg) 
    {
        try
        {
            command.execute(KajetansMod.server, cs, arg);
        }
        catch(Exception ex)
        {
            this.getModule().send(cs, "WorldEdit-Error");
        }
        return true;
    }

    @Override
    public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos targetPos) 
    {
        return command.getTabCompletions(server, sender, args, targetPos);
    }
    
    @Override
    public List<String> getAliases() 
    {
        return command.getAliases();
    }
}