Search in sources :

Example 1 with AbstractWrapper

use of logisticspipes.asm.wrapper.AbstractWrapper in project LogisticsPipes by RS485.

the class EnableCommand method executeCommand.

@Override
public void executeCommand(ICommandSender sender, String[] args) {
    if (args.length != 1) {
        sender.addChatMessage(new ChatComponentText("Wrong amount of arguments"));
        return;
    }
    String name = args[0];
    List<AbstractWrapper> list = new ArrayList<>(LogisticsWrapperHandler.wrapperController);
    Iterator<AbstractWrapper> iter = list.iterator();
    while (iter.hasNext()) {
        AbstractWrapper item = iter.next();
        if (item.getState() != WrapperState.Exception) {
            iter.remove();
        }
    }
    iter = list.iterator();
    while (iter.hasNext()) {
        AbstractWrapper item = iter.next();
        if (!(item.getName() + item.getTypeName()).startsWith(name)) {
            iter.remove();
        }
    }
    if (list.size() > 1) {
        sender.addChatMessage(new ChatComponentText("Possible: "));
        for (AbstractWrapper can : list) {
            sender.addChatMessage(new ChatComponentText(can.getName() + can.getTypeName()));
        }
    } else if (list.isEmpty()) {
        sender.addChatMessage(new ChatComponentText("No match found"));
    } else {
        AbstractWrapper wrapper = list.get(0);
        wrapper.reEnable();
    }
}
Also used : AbstractWrapper(logisticspipes.asm.wrapper.AbstractWrapper) ArrayList(java.util.ArrayList) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 2 with AbstractWrapper

use of logisticspipes.asm.wrapper.AbstractWrapper in project LogisticsPipes by RS485.

the class ListCommand method executeCommand.

@Override
public void executeCommand(ICommandSender sender, String[] args) {
    MorePageDisplay display = new MorePageDisplay(new String[] { "|< Wrapper status - Page: %/$ >|" }, sender);
    for (AbstractWrapper controller : LogisticsWrapperHandler.wrapperController) {
        StringBuilder builder = new StringBuilder();
        builder.append(ChatColor.AQUA);
        builder.append(controller.getName());
        builder.append(controller.getTypeName());
        builder.append(": ");
        if (controller.getState() == WrapperState.Enabled) {
            builder.append(ChatColor.GREEN);
            builder.append("enabled");
        } else if (controller.getState() == WrapperState.ModMissing) {
            builder.append(ChatColor.GRAY);
            builder.append("disabled (mod not found)");
        } else if (controller.getState() == WrapperState.Exception) {
            builder.append(ChatColor.RED);
            builder.append("disabled (exception)");
        } else {
            builder.append(ChatColor.BLUE);
            builder.append("disabled (" + controller.getReason() + ")");
        }
        display.append(builder.toString());
    }
    display.display(sender);
}
Also used : AbstractWrapper(logisticspipes.asm.wrapper.AbstractWrapper) MorePageDisplay(logisticspipes.commands.chathelper.MorePageDisplay)

Example 3 with AbstractWrapper

use of logisticspipes.asm.wrapper.AbstractWrapper in project LogisticsPipes by RS485.

the class ShowCommand method executeCommand.

@Override
public void executeCommand(ICommandSender sender, String[] args) {
    if (args.length != 1) {
        sender.addChatMessage(new ChatComponentText("Wrong amount of arguments"));
        return;
    }
    String name = args[0];
    List<AbstractWrapper> list = new ArrayList<>(LogisticsWrapperHandler.wrapperController);
    Iterator<AbstractWrapper> iter = list.iterator();
    while (iter.hasNext()) {
        AbstractWrapper item = iter.next();
        if (item.getState() != WrapperState.Exception) {
            iter.remove();
        }
    }
    iter = list.iterator();
    while (iter.hasNext()) {
        AbstractWrapper item = iter.next();
        if (!(item.getName() + item.getTypeName()).startsWith(name)) {
            iter.remove();
        }
    }
    if (list.size() > 1) {
        sender.addChatMessage(new ChatComponentText("Possible: "));
        for (AbstractWrapper can : list) {
            sender.addChatMessage(new ChatComponentText(can.getName() + can.getTypeName()));
        }
    } else if (list.isEmpty()) {
        sender.addChatMessage(new ChatComponentText("No match found"));
    } else {
        AbstractWrapper wrapper = list.get(0);
        Throwable t = wrapper.getReason();
        if (t == null) {
            sender.addChatMessage(new ChatComponentText("null"));
            return;
        } else {
            sender.addChatMessage(new ChatComponentText("-----------------------------------------------------"));
            sender.addChatMessage(new ChatComponentText(t.toString()));
            for (StackTraceElement s : t.getStackTrace()) {
                sender.addChatMessage(new ChatComponentText(" " + s.toString()));
            }
            t.printStackTrace();
        }
    }
}
Also used : AbstractWrapper(logisticspipes.asm.wrapper.AbstractWrapper) ArrayList(java.util.ArrayList) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

AbstractWrapper (logisticspipes.asm.wrapper.AbstractWrapper)3 ArrayList (java.util.ArrayList)2 ChatComponentText (net.minecraft.util.ChatComponentText)2 MorePageDisplay (logisticspipes.commands.chathelper.MorePageDisplay)1