Search in sources :

Example 11 with IQuest

use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.

the class GuiPrerequisiteEditor method RefreshSearch.

public void RefreshSearch() {
    searchResults.clear();
    String query = searchBox.getText().toLowerCase();
    for (int id : QuestDatabase.INSTANCE.getAllKeys()) {
        IQuest q = QuestDatabase.INSTANCE.getValue(id);
        if (query.length() <= 0 || q.getUnlocalisedName().toLowerCase().contains(query) || I18n.format(q.getUnlocalisedName()).toLowerCase().contains(query) || query.equalsIgnoreCase("" + id)) {
            searchResults.add(id);
        }
    }
}
Also used : IQuest(betterquesting.api.questing.IQuest)

Example 12 with IQuest

use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.

the class GuiPrerequisiteEditor method actionPerformed.

@Override
public void actionPerformed(GuiButton button) {
    super.actionPerformed(button);
    if (button.id == 1) {
        createQuest();
    } else if (button.id > 1) {
        int column = button.id & 7;
        int id = (button.id >> 3) - 2;
        IQuest q = QuestDatabase.INSTANCE.getValue(id);
        if (id < 0 || q == null) {
            // Invalid quest ID
            return;
        } else if (// Edit quest
        column == 0 || column == 3) {
            mc.displayGuiScreen(new GuiQuest(this, id));
        } else if (// Remove quest
        column == 1) {
            quest.getPrerequisites().remove(q);
            SendChanges();
        } else if (// Delete quest
        column == 4) {
            NBTTagCompound tags = new NBTTagCompound();
            // Delete quest
            tags.setInteger("action", EnumPacketAction.REMOVE.ordinal());
            tags.setInteger("questID", id);
            PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.QUEST_EDIT.GetLocation(), tags));
        } else if (// Add quest
        column == 2) {
            quest.getPrerequisites().add(q);
            SendChanges();
        }
    }
}
Also used : GuiQuest(betterquesting.client.gui2.GuiQuest) IQuest(betterquesting.api.questing.IQuest) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 13 with IQuest

use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.

the class GuiQuestLineEditorB method actionPerformed.

@Override
public void actionPerformed(GuiButton button) {
    super.actionPerformed(button);
    if (button.id == 1) {
        createQuest();
    } else if (button.id > 1) {
        // Line listing (0 = quest, 1 = quest delete, 2 = registry)
        int column = button.id & 7;
        int id = (button.id >> 3) - 2;
        if (// Edit quest
        column == 0 || column == 3) {
            if (id >= 0) {
                IQuest q = QuestDatabase.INSTANCE.getValue(id);
                if (q != null) {
                    mc.displayGuiScreen(new GuiQuest(this, id));
                }
            }
        } else if (// Remove quest
        column == 1 && line != null) {
            line.removeKey(id);
            // RefreshColumns();
            SendChanges(EnumPacketAction.EDIT, lineID);
        } else if (// Delete quest
        column == 4 && id >= 0) {
            NBTTagCompound tags = new NBTTagCompound();
            // Delete quest
            tags.setInteger("action", EnumPacketAction.REMOVE.ordinal());
            tags.setInteger("questID", id);
            PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.QUEST_EDIT.GetLocation(), tags));
        } else if (// Add quest
        column == 2 && line != null && id >= 0) {
            IQuestLineEntry qe = new QuestLineEntry(0, 0);
            int x1 = 0;
            int y1 = 0;
            topLoop: while (true) {
                for (IQuestLineEntry qe2 : line.getAllValues()) {
                    int x2 = qe2.getPosX();
                    int y2 = qe2.getPosY();
                    int s2 = qe2.getSize();
                    if (x1 >= x2 && x1 < x2 + s2 && y1 >= y2 && y1 < y2 + s2) {
                        x1 += s2;
                        x2 += s2;
                        // We're in the way, move over and try again
                        continue topLoop;
                    }
                }
                break;
            }
            qe.setPosition(x1, y1);
            line.add(qe, id);
            RefreshColumns();
            SendChanges(EnumPacketAction.EDIT, lineID);
        }
    }
}
Also used : GuiQuest(betterquesting.client.gui2.GuiQuest) IQuest(betterquesting.api.questing.IQuest) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry) QuestLineEntry(betterquesting.questing.QuestLineEntry) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry) QuestingPacket(betterquesting.api.network.QuestingPacket)

Example 14 with IQuest

use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.

the class GuiSubmitStation method initGui.

public void initGui() {
    super.initGui();
    if (tile == null) {
        mc.displayGuiScreen(parent);
        return;
    }
    activeQuests.clear();
    UUID pID = QuestingAPI.getQuestingUUID(mc.player);
    QuestCache.INSTANCE.updateCache(mc.player);
    activeQuests.addAll(QuestCache.INSTANCE.getActiveQuests(pID));
    Iterator<IQuest> qit = activeQuests.iterator();
    while (qit.hasNext()) {
        IQuest q = qit.next();
        if (q.getProperties().getProperty(NativeProps.VISIBILITY) == EnumQuestVisibility.HIDDEN) {
            // These should not be shown to players
            qit.remove();
        }
    }
    // Prev Quest
    buttonList.add(new GuiButtonThemed(1, guiLeft + sizeX / 2 - 120, guiTop + 32, 20, 20, "<", true));
    // Next Quest
    buttonList.add(new GuiButtonThemed(2, guiLeft + sizeX / 2 + 100, guiTop + 32, 20, 20, ">", true));
    // Prev Task
    buttonList.add(new GuiButtonThemed(3, guiLeft + sizeX / 2 - 120, guiTop + 52, 20, 20, "<", true));
    // Next Quest
    buttonList.add(new GuiButtonThemed(4, guiLeft + sizeX / 2 + 100, guiTop + 52, 20, 20, ">", true));
    // Select Task
    btnSelect = new GuiButtonThemed(5, guiLeft + sizeX / 2 - 20, guiTop + 72, 20, 20, TextFormatting.GREEN + "\u2714", true);
    // Remove Task
    btnRemove = new GuiButtonThemed(6, guiLeft + sizeX / 2 + 00, guiTop + 72, 20, 20, TextFormatting.RED + "x", true);
    buttonList.add(btnSelect);
    buttonList.add(btnRemove);
    int invX = 16 + (sizeX / 2 - 24) / 2 - 162 / 2;
    int invY = 92 + (sizeY - 108) / 2 - 98 / 2 + 22;
    subContainer.moveInventorySlots(invX + 1, invY + 1);
    invX += 18 * 3;
    invY -= 22;
    subContainer.moveSubmitSlot(invX + 1, invY + 1);
    invX += 18 * 2;
    subContainer.moveReturnSlot(invX + 1, invY + 1);
    RefreshValues();
}
Also used : IQuest(betterquesting.api.questing.IQuest) GuiButtonThemed(betterquesting.api.client.gui.controls.GuiButtonThemed) UUID(java.util.UUID)

Example 15 with IQuest

use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.

the class QuestCommandComplete method runCommand.

@Override
public void runCommand(MinecraftServer server, CommandBase command, ICommandSender sender, String[] args) throws CommandException {
    UUID uuid = null;
    if (args.length >= 3) {
        uuid = this.findPlayerID(server, sender, args[2]);
        if (uuid == null) {
            throw this.getException(command);
        }
    } else {
        uuid = this.findPlayerID(server, sender, sender.getName());
    }
    String pName = uuid == null ? "NULL" : NameCache.INSTANCE.getName(uuid);
    try {
        int id = Integer.parseInt(args[1].trim());
        IQuest quest = QuestDatabase.INSTANCE.getValue(id);
        quest.setComplete(uuid, 0);
        int done = 0;
        if (// Preliminary check
        !quest.getProperties().getProperty(NativeProps.LOGIC_TASK).getResult(done, quest.getTasks().size())) {
            for (ITask task : quest.getTasks().getAllValues()) {
                task.setComplete(uuid);
                done += 1;
                if (quest.getProperties().getProperty(NativeProps.LOGIC_TASK).getResult(done, quest.getTasks().size())) {
                    // Only complete enough quests to claim the reward
                    break;
                }
            }
        }
        sender.sendMessage(new TextComponentTranslation("betterquesting.cmd.complete", new TextComponentTranslation(quest.getUnlocalisedName()), pName));
    } catch (Exception e) {
        throw getException(command);
    }
    PacketSender.INSTANCE.sendToAll(QuestDatabase.INSTANCE.getSyncPacket());
}
Also used : ITask(betterquesting.api.questing.tasks.ITask) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IQuest(betterquesting.api.questing.IQuest) UUID(java.util.UUID) CommandException(net.minecraft.command.CommandException)

Aggregations

IQuest (betterquesting.api.questing.IQuest)44 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 ITask (betterquesting.api.questing.tasks.ITask)9 UUID (java.util.UUID)9 QuestInstance (betterquesting.questing.QuestInstance)8 ArrayList (java.util.ArrayList)6 GuiButtonQuestInstance (betterquesting.api.client.gui.controls.GuiButtonQuestInstance)5 QuestingPacket (betterquesting.api.network.QuestingPacket)4 IQuestLine (betterquesting.api.questing.IQuestLine)4 HashMap (java.util.HashMap)4 NBTBase (net.minecraft.nbt.NBTBase)4 GuiButtonThemed (betterquesting.api.client.gui.controls.GuiButtonThemed)3 IQuestLineEntry (betterquesting.api.questing.IQuestLineEntry)3 PanelButtonStorage (betterquesting.api2.client.gui.controls.PanelButtonStorage)3 QuestLineEntry (betterquesting.questing.QuestLineEntry)3 List (java.util.List)3 Minecraft (net.minecraft.client.Minecraft)3 CommandException (net.minecraft.command.CommandException)3 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)3 IPanelButton (betterquesting.api2.client.gui.controls.IPanelButton)2