package me.km.api; import java.util.List; import me.km.KajetansMod; import me.km.permissions.Permissions; import net.minecraft.command.CommandException; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextFormatting; public class VanillaModuleCommand extends ModuleCommand { private final ICommand vanillaCommand; public VanillaModuleCommand(ICommand command, Module m, Permissions perm) { super(command.getName(), m); super.setDescription("A vanilla command"); TextComponentTranslation text = new TextComponentTranslation(command.getUsage(null)); super.setUsage(text.getFormattedText()); super.setPermission(perm); vanillaCommand = command; } @Override public boolean execute(ICommandSender cs, String[] arg) { try { vanillaCommand.execute(KajetansMod.server, cs, arg); } catch (CommandException ex) { TextComponentTranslation text = new TextComponentTranslation(ex.getMessage(), ex.getErrorObjects()); text.getStyle().setColor(TextFormatting.RED); cs.sendMessage(text); } return true; } @Override public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos targetPos) { return vanillaCommand.getTabCompletions(server, sender, args, targetPos); } @Override public List getAliases() { return vanillaCommand.getAliases(); } }