mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-08 17:37:37 +01:00
Update GUI implementation and correct some text, fixes #34
This commit is contained in:
parent
72f0416dd9
commit
45e52d8030
src/main/java/me/blackvein/quests
@ -36,18 +36,18 @@ public class NpcListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onNPCRightClick(NPCRightClickEvent evt) {
|
public void onNPCRightClick(NPCRightClickEvent evt) {
|
||||||
|
|
||||||
if (plugin.questFactory.selectingNPCs.contains(evt.getClicker())) {
|
if (plugin.questFactory.selectingNPCs.contains(evt.getClicker())) {
|
||||||
evt.getClicker().sendMessage(ChatColor.GREEN + evt.getNPC().getName() + ": " + ChatColor.DARK_GREEN + "ID " + evt.getNPC().getId());
|
evt.getClicker().sendMessage(ChatColor.GREEN + evt.getNPC().getName() + ": " + ChatColor.DARK_GREEN + "ID " + evt.getNPC().getId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt.getClicker().isConversing() == false) {
|
if (evt.getClicker().isConversing() == false) {
|
||||||
|
|
||||||
final Player player = evt.getClicker();
|
final Player player = evt.getClicker();
|
||||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||||
boolean delivery = false;
|
boolean delivery = false;
|
||||||
|
|
||||||
for (Quest quest : quester.currentQuests.keySet()) {
|
for (Quest quest : quester.currentQuests.keySet()) {
|
||||||
|
|
||||||
if (quester.hasObjective(quest, "deliverItem") && player.getItemInHand() != null) {
|
if (quester.hasObjective(quest, "deliverItem") && player.getItemInHand() != null) {
|
||||||
@ -111,7 +111,7 @@ public class NpcListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.questNPCs.contains(evt.getNPC()) && delivery == false) {
|
if (plugin.questNPCs.contains(evt.getNPC()) && delivery == false) {
|
||||||
|
|
||||||
if (plugin.checkQuester(player.getUniqueId()) == false) {
|
if (plugin.checkQuester(player.getUniqueId()) == false) {
|
||||||
|
|
||||||
boolean hasObjective = false;
|
boolean hasObjective = false;
|
||||||
@ -131,14 +131,12 @@ public class NpcListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!hasObjective) {
|
if (!hasObjective) {
|
||||||
|
|
||||||
LinkedList<Quest> npcQuests = new LinkedList<Quest>();
|
LinkedList<Quest> npcQuests = new LinkedList<Quest>();
|
||||||
|
|
||||||
for (Quest q : plugin.getQuests()) {
|
for (Quest q : plugin.getQuests()) {
|
||||||
|
|
||||||
if(quester.currentQuests.containsKey(q))
|
if(quester.currentQuests.containsKey(q))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (q.npcStart != null && q.npcStart.getId() == evt.getNPC().getId()) {
|
if (q.npcStart != null && q.npcStart.getId() == evt.getNPC().getId()) {
|
||||||
if (Quests.ignoreLockedQuests && (quester.completedQuests.contains(q.name) == false || q.redoDelay > -1)) {
|
if (Quests.ignoreLockedQuests && (quester.completedQuests.contains(q.name) == false || q.redoDelay > -1)) {
|
||||||
if (q.testRequirements(quester)) {
|
if (q.testRequirements(quester)) {
|
||||||
@ -150,13 +148,12 @@ public class NpcListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (npcQuests.isEmpty() == false && npcQuests.size() > 1) {
|
if (npcQuests.isEmpty() == false && npcQuests.size() >= 1) {
|
||||||
|
|
||||||
if (plugin.questNPCGUIs.contains(evt.getNPC().getId())) {
|
if (plugin.questNPCGUIs.contains(evt.getNPC().getId())) {
|
||||||
quester.showGUIDisplay(evt.getNPC(), npcQuests);
|
quester.showGUIDisplay(evt.getNPC(), npcQuests);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Conversation c = plugin.NPCConversationFactory.buildConversation((Conversable) player);
|
Conversation c = plugin.NPCConversationFactory.buildConversation((Conversable) player);
|
||||||
@ -165,7 +162,7 @@ public class NpcListener implements Listener {
|
|||||||
c.begin();
|
c.begin();
|
||||||
|
|
||||||
} else if (npcQuests.size() == 1) {
|
} else if (npcQuests.size() == 1) {
|
||||||
|
|
||||||
Quest q = npcQuests.get(0);
|
Quest q = npcQuests.get(0);
|
||||||
|
|
||||||
if (!quester.completedQuests.contains(q.name)) {
|
if (!quester.completedQuests.contains(q.name)) {
|
||||||
|
@ -175,7 +175,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) {
|
if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) {
|
||||||
text += BLUE + "" + BOLD + "3" + RESET + RED + " - " + Lang.get("questEditorFinishMessage") + " " + DARKRED + Lang.get("questRequiredNoneSet") + "\n";
|
text += BLUE + "" + BOLD + "3" + RESET + RED + " - " + Lang.get("questEditorFinishMessage") + " " + DARKRED + "(" + Lang.get("questRequiredNoneSet") + ")\n";
|
||||||
} else {
|
} else {
|
||||||
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("questEditorFinishMessage") + " (\"" + context.getSessionData(CK.Q_FINISH_MESSAGE) + "\")\n";
|
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("questEditorFinishMessage") + " (\"" + context.getSessionData(CK.Q_FINISH_MESSAGE) + "\")\n";
|
||||||
}
|
}
|
||||||
@ -861,7 +861,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
|||||||
return new GUIDisplayPrompt();
|
return new GUIDisplayPrompt();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return new CreateMenuPrompt();
|
return new CreateMenuPrompt();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1037,6 +1037,13 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
|||||||
ConfigurationSection newSection = questSection.createSection("custom" + customNum);
|
ConfigurationSection newSection = questSection.createSection("custom" + customNum);
|
||||||
saveQuest(context, newSection);
|
saveQuest(context, newSection);
|
||||||
data.save(new File(quests.getDataFolder(), "quests.yml"));
|
data.save(new File(quests.getDataFolder(), "quests.yml"));
|
||||||
|
if (context.getSessionData(CK.Q_START_NPC) != null && context.getSessionData(CK.Q_GUIDISPLAY) != null) {
|
||||||
|
int i = (Integer) context.getSessionData(CK.Q_START_NPC);
|
||||||
|
if (!quests.questNPCGUIs.contains(i)) {
|
||||||
|
quests.questNPCGUIs.add(i);
|
||||||
|
}
|
||||||
|
quests.updateData();
|
||||||
|
}
|
||||||
context.getForWhom().sendRawMessage(BOLD + Lang.get("questEditorSaved"));
|
context.getForWhom().sendRawMessage(BOLD + Lang.get("questEditorSaved"));
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -1277,7 +1284,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
|||||||
cs.set("finish-message", finish);
|
cs.set("finish-message", finish);
|
||||||
cs.set("initial-event", initialEvent);
|
cs.set("initial-event", initialEvent);
|
||||||
cs.set("region", region);
|
cs.set("region", region);
|
||||||
cs.set("guiDisplay", ItemUtil.serialize(guiDisplay));
|
cs.set("gui-display", ItemUtil.serialize(guiDisplay));
|
||||||
|
|
||||||
if (moneyReq != null || questPointsReq != null || itemReqs != null && itemReqs.isEmpty() == false || permReqs != null && permReqs.isEmpty() == false || (questReqs != null && questReqs.isEmpty() == false) || (questBlocks != null && questBlocks.isEmpty() == false) || (mcMMOSkillReqs != null && mcMMOSkillReqs.isEmpty() == false) || heroesPrimaryReq != null || heroesSecondaryReq != null || customReqs != null) {
|
if (moneyReq != null || questPointsReq != null || itemReqs != null && itemReqs.isEmpty() == false || permReqs != null && permReqs.isEmpty() == false || (questReqs != null && questReqs.isEmpty() == false) || (questBlocks != null && questBlocks.isEmpty() == false) || (mcMMOSkillReqs != null && mcMMOSkillReqs.isEmpty() == false) || heroesPrimaryReq != null || heroesSecondaryReq != null || customReqs != null) {
|
||||||
|
|
||||||
|
@ -1457,7 +1457,7 @@ public class Quester {
|
|||||||
|
|
||||||
} else if (objective.equalsIgnoreCase("killMob")) {
|
} else if (objective.equalsIgnoreCase("killMob")) {
|
||||||
|
|
||||||
String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("kill") + mob.name();
|
String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("kill") + " " + mob.name();
|
||||||
message = message + " " + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob)) + "/" + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob));
|
message = message + " " + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob)) + "/" + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob));
|
||||||
p.sendMessage(message);
|
p.sendMessage(message);
|
||||||
if (testComplete(quest)) {
|
if (testComplete(quest)) {
|
||||||
@ -1485,7 +1485,7 @@ public class Quester {
|
|||||||
|
|
||||||
} else if (objective.equalsIgnoreCase("killNPC")) {
|
} else if (objective.equalsIgnoreCase("killNPC")) {
|
||||||
|
|
||||||
String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("kill") + npc.getName();
|
String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("kill") + " " + npc.getName();
|
||||||
message = message + " " + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(npc.getId())) + "/" + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(npc.getId()));
|
message = message + " " + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(npc.getId())) + "/" + getCurrentStage(quest).citizenNumToKill.get(getCurrentStage(quest).citizensToKill.indexOf(npc.getId()));
|
||||||
p.sendMessage(message);
|
p.sendMessage(message);
|
||||||
if (testComplete(quest)) {
|
if (testComplete(quest)) {
|
||||||
@ -1494,7 +1494,7 @@ public class Quester {
|
|||||||
|
|
||||||
} else if (objective.equalsIgnoreCase("tameMob")) {
|
} else if (objective.equalsIgnoreCase("tameMob")) {
|
||||||
|
|
||||||
String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("tame") + getCapitalized(mob.name());
|
String message = ChatColor.GREEN + "(" + Lang.get("completed") + ") " + Lang.get("tame") + " " + getCapitalized(mob.name());
|
||||||
message = message + " " + getCurrentStage(quest).mobsToTame.get(mob) + "/" + getCurrentStage(quest).mobsToTame.get(mob);
|
message = message + " " + getCurrentStage(quest).mobsToTame.get(mob) + "/" + getCurrentStage(quest).mobsToTame.get(mob);
|
||||||
p.sendMessage(message);
|
p.sendMessage(message);
|
||||||
if (testComplete(quest)) {
|
if (testComplete(quest)) {
|
||||||
|
@ -445,7 +445,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
quester.saveData();
|
quester.saveData();
|
||||||
|
|
||||||
}
|
}
|
||||||
getLogger().info("Disabled.");
|
updateData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2459,6 +2459,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
quests.clear();
|
quests.clear();
|
||||||
events.clear();
|
events.clear();
|
||||||
loadQuests();
|
loadQuests();
|
||||||
|
loadData();
|
||||||
loadEvents();
|
loadEvents();
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
@ -2606,9 +2607,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.contains("quests." + questName + ".guiDisplay")) {
|
if (config.contains("quests." + questName + ".gui-display")) {
|
||||||
|
|
||||||
String item = config.getString("quests." + questName + ".guiDisplay");
|
String item = config.getString("quests." + questName + ".gui-display");
|
||||||
try {
|
try {
|
||||||
ItemStack stack = ItemUtil.readItemStack(item);
|
ItemStack stack = ItemUtil.readItemStack(item);
|
||||||
|
|
||||||
@ -2616,7 +2617,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
quest.guiDisplay = stack;
|
quest.guiDisplay = stack;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
instance.getLogger().warning(item + " in items: Gui Display in Quest " + quest.name + "is not properly formatted!");
|
instance.getLogger().warning(item + " in items: GUI Display in Quest " + quest.name + "is not properly formatted!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user