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());
}
}
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;
}
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());
}
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());
}
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);
}
}
Aggregations