use of betterquesting.api.questing.IQuestLineDatabase in project BetterQuesting by Funwayguy.
the class GuiImporters method setValues.
@Override
public void setValues(File[] files) {
if (selected != null) {
IQuestDatabase questDB = new ImportedQuests();
IQuestLineDatabase lineDB = new ImportedQuestLines();
selected.loadFiles(questDB, lineDB, files);
if (questDB.size() > 0 || lineDB.size() > 0) {
NBTTagCompound jsonBase = new NBTTagCompound();
jsonBase.setTag("quests", questDB.writeToNBT(new NBTTagList(), EnumSaveType.CONFIG));
jsonBase.setTag("lines", lineDB.writeToNBT(new NBTTagList(), EnumSaveType.CONFIG));
NBTTagCompound tag = new NBTTagCompound();
tag.setTag("data", jsonBase);
PacketSender.INSTANCE.sendToServer(new QuestingPacket(PacketTypeNative.IMPORT.GetLocation(), tag));
mc.displayGuiScreen(parent);
}
}
}
use of betterquesting.api.questing.IQuestLineDatabase 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());
}
Aggregations