Search in sources :

Example 16 with IQuestLine

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

the class LegacyLoader_v0 method readLineDatabase.

public void readLineDatabase(JsonArray jAry) {
    QuestLineDatabase.INSTANCE.reset();
    for (JsonElement je : jAry) {
        if (je == null || !je.isJsonObject()) {
            continue;
        }
        IQuestLine qLine = new QuestLine();
        readLine(qLine, je.getAsJsonObject());
        QuestLineDatabase.INSTANCE.add(qLine, QuestLineDatabase.INSTANCE.nextKey());
    }
}
Also used : JsonElement(com.google.gson.JsonElement) IQuestLine(betterquesting.api.questing.IQuestLine) QuestLine(betterquesting.questing.QuestLine) IQuestLine(betterquesting.api.questing.IQuestLine)

Example 17 with IQuestLine

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

the class QuestLineDatabase method getAllValues.

@Override
public List<IQuestLine> getAllValues() {
    List<IQuestLine> list = new ArrayList<IQuestLine>(questLines.values());
    Collections.sort(list, new QuestLineSortByValue(this));
    return list;
}
Also used : QuestLineSortByValue(betterquesting.misc.QuestLineSortByValue) IQuestLine(betterquesting.api.questing.IQuestLine) ArrayList(java.util.ArrayList)

Example 18 with IQuestLine

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

the class PktHandlerLineSync method handleClient.

@Override
public void handleClient(NBTTagCompound tag) {
    int id = !tag.hasKey("lineID") ? -1 : tag.getInteger("lineID");
    IQuestLine questLine = QuestLineDatabase.INSTANCE.getValue(id);
    if (questLine == null) {
        questLine = new QuestLine();
        QuestLineDatabase.INSTANCE.add(questLine, id);
    }
    questLine.readPacket(tag);
    MinecraftForge.EVENT_BUS.post(new DatabaseEvent.Update());
}
Also used : IQuestLine(betterquesting.api.questing.IQuestLine) QuestLine(betterquesting.questing.QuestLine) IQuestLine(betterquesting.api.questing.IQuestLine) DatabaseEvent(betterquesting.api.events.DatabaseEvent)

Example 19 with IQuestLine

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

the class PktHandlerImport method handleServer.

@Override
public void handleServer(NBTTagCompound tag, EntityPlayerMP sender) {
    if (sender == null) {
        return;
    }
    boolean isOP = sender.world.getMinecraftServer().getPlayerList().canSendCommands(sender.getGameProfile());
    if (!isOP) {
        BetterQuesting.logger.log(Level.WARN, "Player " + sender.getName() + " (UUID:" + QuestingAPI.getQuestingUUID(sender) + ") tried to import quests without OP permissions!");
        sender.sendStatusMessage(new TextComponentString(TextFormatting.RED + "You need to be OP to edit quests!"), false);
        // Player is not operator. Do nothing
        return;
    }
    NBTTagCompound jsonBase = tag.getCompoundTag("data");
    IQuestDatabase impQuestDB = new ImportedQuests();
    IQuestLineDatabase impQuestLineDB = new ImportedQuestLines();
    impQuestDB.readFromNBT(jsonBase.getTagList("quests", 10), EnumSaveType.CONFIG);
    impQuestLineDB.readFromNBT(jsonBase.getTagList("lines", 10), EnumSaveType.CONFIG);
    BetterQuesting.logger.log(Level.INFO, "Importing " + impQuestDB.size() + " quest(s) and " + impQuestLineDB.size() + " quest line(s) from " + sender.getGameProfile().getName());
    HashMap<Integer, Integer> remapped = getRemappedIDs(impQuestDB.getAllKeys());
    for (Entry<Integer, Integer> entry : remapped.entrySet()) {
        QuestDatabase.INSTANCE.add(impQuestDB.getValue(entry.getKey()), entry.getValue());
    }
    for (IQuestLine questLine : impQuestLineDB.getAllValues()) {
        for (IQuestLineEntry qle : questLine.getAllValues()) {
            int oldID = questLine.getKey(qle);
            questLine.removeKey(oldID);
            questLine.add(qle, remapped.get(oldID));
        }
        QuestLineDatabase.INSTANCE.add(questLine, QuestLineDatabase.INSTANCE.nextKey());
    }
    PacketSender.INSTANCE.sendToAll(QuestDatabase.INSTANCE.getSyncPacket());
    PacketSender.INSTANCE.sendToAll(QuestLineDatabase.INSTANCE.getSyncPacket());
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ImportedQuestLines(betterquesting.client.importers.ImportedQuestLines) IQuestLineEntry(betterquesting.api.questing.IQuestLineEntry) ImportedQuests(betterquesting.client.importers.ImportedQuests) TextComponentString(net.minecraft.util.text.TextComponentString) IQuestDatabase(betterquesting.api.questing.IQuestDatabase) IQuestLine(betterquesting.api.questing.IQuestLine) IQuestLineDatabase(betterquesting.api.questing.IQuestLineDatabase)

Example 20 with IQuestLine

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

the class GuiQuestLineEditorA method RefreshColumns.

public void RefreshColumns() {
    questList = QuestLineDatabase.INSTANCE.getAllKeys();
    if (btnDesign != null) {
        btnDesign.enabled = selected != null;
    }
    btnList.getEntryList().clear();
    for (int qlid : questList) {
        IQuestLine line = QuestLineDatabase.INSTANCE.getValue(qlid);
        if (line == null) {
            continue;
        }
        int bWidth = btnList.getListWidth();
        // Offsets the quest line ID to avoid conflict with existing button IDs and reserves 2 bits for column index
        int bID = (5 + qlid) << 2;
        GuiButtonThemed btn1 = new GuiButtonThemed(bID + 0, 0, 0, bWidth - 40, 20, I18n.format(line.getUnlocalisedName()));
        btn1.enabled = line != selected;
        GuiButtonThemed btn2 = new GuiButtonThemed(bID + 1, 0, 0, 20, 20, "" + TextFormatting.RED + TextFormatting.BOLD + "x");
        GuiButtonThemed btn3 = new GuiButtonThemed(bID + 2, 0, 0, 20, 20, "" + TextFormatting.YELLOW + TextFormatting.BOLD + "^");
        btnList.addButtonRow(btn1, btn2, btn3);
    }
}
Also used : IQuestLine(betterquesting.api.questing.IQuestLine) GuiButtonThemed(betterquesting.api.client.gui.controls.GuiButtonThemed)

Aggregations

IQuestLine (betterquesting.api.questing.IQuestLine)20 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)11 QuestingPacket (betterquesting.api.network.QuestingPacket)6 IQuest (betterquesting.api.questing.IQuest)4 QuestLine (betterquesting.questing.QuestLine)4 GuiButtonQuestInstance (betterquesting.api.client.gui.controls.GuiButtonQuestInstance)3 IQuestLineEntry (betterquesting.api.questing.IQuestLineEntry)3 ArrayList (java.util.ArrayList)3 IPanelButton (betterquesting.api2.client.gui.controls.IPanelButton)2 PanelButtonStorage (betterquesting.api2.client.gui.controls.PanelButtonStorage)2 QuestInstance (betterquesting.questing.QuestInstance)2 QuestLineEntry (betterquesting.questing.QuestLineEntry)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 GuiButtonThemed (betterquesting.api.client.gui.controls.GuiButtonThemed)1 EnumPacketAction (betterquesting.api.enums.EnumPacketAction)1 DatabaseEvent (betterquesting.api.events.DatabaseEvent)1 IQuestDatabase (betterquesting.api.questing.IQuestDatabase)1 IQuestLineDatabase (betterquesting.api.questing.IQuestLineDatabase)1 PanelButton (betterquesting.api2.client.gui.controls.PanelButton)1 CanvasTextured (betterquesting.api2.client.gui.panels.CanvasTextured)1