use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.
the class QuestInstance method readFromJson_Config.
private void readFromJson_Config(NBTTagCompound jObj) {
this.qInfo.readFromNBT(jObj.getCompoundTag("properties"), EnumSaveType.CONFIG);
this.tasks.readFromNBT(jObj.getTagList("tasks", 10), EnumSaveType.CONFIG);
this.rewards.readFromNBT(jObj.getTagList("rewards", 10), EnumSaveType.CONFIG);
preRequisites.clear();
if (// Native NBT
jObj.getTagId("preRequisites") == 11) {
for (int prID : jObj.getIntArray("preRequisites")) {
if (prID < 0) {
continue;
}
IQuest tmp = parentDB.getValue(prID);
if (tmp == null) {
tmp = parentDB.createNew();
parentDB.add(tmp, prID);
}
preRequisites.add(tmp);
}
} else // Probably an NBTTagList
{
NBTTagList rList = jObj.getTagList("preRequisites", 4);
for (int i = 0; i < rList.tagCount(); i++) {
NBTBase pTag = rList.get(i);
int prID = pTag instanceof NBTPrimitive ? ((NBTPrimitive) pTag).getInt() : -1;
if (prID < 0) {
continue;
}
IQuest tmp = parentDB.getValue(prID);
if (tmp == null) {
tmp = parentDB.createNew();
parentDB.add(tmp, prID);
}
preRequisites.add(tmp);
}
}
this.setupProps();
}
use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.
the class GuiPrerequisiteEditor method refreshGui.
@Override
public void refreshGui() {
IQuest tmp = QuestDatabase.INSTANCE.getValue(questID);
if (tmp == null) {
mc.displayGuiScreen(parent);
return;
}
quest = tmp;
RefreshSearch();
RefreshColumns();
}
use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.
the class GuiQuestLineEditorB 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);
}
}
}
use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.
the class GuiQuestLineEditorB method RefreshColumns.
public void RefreshColumns() {
if (line == null) {
lineQuests.clear();
} else {
lineQuests = line.getAllKeys();
}
qlBtnList.getEntryList().clear();
for (int qID : lineQuests) {
IQuest quest = QuestDatabase.INSTANCE.getValue(qID);
if (quest == null) {
continue;
}
int bWidth = qlBtnList.getListWidth();
// First 3 bits reserved for column index
int bID = (2 + qID) << 3;
GuiButtonThemed btn1 = new GuiButtonThemed(bID + 0, 0, 0, bWidth - 20, 20, I18n.format(quest.getUnlocalisedName()));
GuiButtonThemed btn2 = new GuiButtonThemed(bID + 1, 0, 0, 20, 20, TextFormatting.YELLOW + ">");
qlBtnList.addButtonRow(btn1, btn2);
}
dbBtnList.getEntryList().clear();
for (int qID : searchResults) {
IQuest quest = QuestDatabase.INSTANCE.getValue(qID);
if (quest == null) {
continue;
}
int bWidth = dbBtnList.getListWidth();
// First 3 bits reserved for column index
int bID = (2 + qID) << 3;
GuiButtonThemed btn3 = new GuiButtonThemed(bID + 2, 0, 0, 20, 20, TextFormatting.GREEN + "<");
btn3.enabled = line != null && !lineQuests.contains(qID);
GuiButtonThemed btn4 = new GuiButtonThemed(bID + 3, 0, 0, bWidth - 40, 20, I18n.format(quest.getUnlocalisedName()));
GuiButtonThemed btn5 = new GuiButtonThemed(bID + 4, 0, 0, 20, 20, "" + TextFormatting.BOLD + TextFormatting.RED + "x");
dbBtnList.addButtonRow(btn3, btn4, btn5);
}
}
use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.
the class QuestCache method getActiveTasks.
/**
* Returns a cached list of active tasks of the given type with references to their parent quest
*/
@SuppressWarnings("unchecked")
public <T extends ITask> Map<T, IQuest> getActiveTasks(UUID uuid, Class<T> type) {
Map<T, IQuest> list = new HashMap<T, IQuest>();
HashMap<Integer, List<Integer>> pCache = rawCache.get(uuid);
pCache = pCache != null ? pCache : new HashMap<Integer, List<Integer>>();
for (Entry<Integer, List<Integer>> entry : pCache.entrySet()) {
IQuest quest = QuestingAPI.getAPI(ApiReference.QUEST_DB).getValue(entry.getKey());
if (quest == null) {
continue;
}
for (int tID : entry.getValue()) {
ITask task = quest.getTasks().getValue(tID);
if (task != null && type.isAssignableFrom(task.getClass())) {
list.put((T) task, quest);
}
}
}
return list;
}
Aggregations