mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-02 22:48:05 +01:00
Bugfixes
This commit is contained in:
parent
5b90901f37
commit
1ca1da2cf1
@ -5,6 +5,7 @@ import java.util.LinkedList;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.event.NPCDeathEvent;
|
||||
import net.citizensnpcs.api.event.NPCLeftClickEvent;
|
||||
import net.citizensnpcs.api.event.NPCRightClickEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -32,6 +33,11 @@ public class NpcListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onNPCRightClick(NPCRightClickEvent evt) {
|
||||
|
||||
if(plugin.questFactory.selectingNPCs.contains(evt.getClicker())){
|
||||
evt.getClicker().sendMessage(ChatColor.GREEN + evt.getNPC().getName() + ": " + ChatColor.DARK_GREEN + "ID " + evt.getNPC().getId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (evt.getClicker().isConversing() == false) {
|
||||
|
||||
final Player player = evt.getClicker();
|
||||
@ -163,6 +169,15 @@ public class NpcListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onNPCLeftClick(NPCLeftClickEvent evt){
|
||||
|
||||
if(plugin.questFactory.selectingNPCs.contains(evt.getClicker())){
|
||||
evt.getClicker().sendMessage(ChatColor.GREEN + evt.getNPC().getName() + ": " + ChatColor.DARK_GREEN + "ID " + evt.getNPC().getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onNPCDeath(NPCDeathEvent evt) {
|
||||
|
||||
|
@ -653,6 +653,8 @@ public class PlayerListener implements Listener {
|
||||
quester.saveData();
|
||||
}
|
||||
|
||||
if(plugin.questFactory.selectingNPCs.contains(evt.getPlayer()))
|
||||
plugin.questFactory.selectingNPCs.remove(evt.getPlayer());
|
||||
plugin.questers.remove(quester.name);
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import me.blackvein.quests.util.ColorUtil;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -37,6 +38,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
Map<Player, Block> selectedBlockStarts = new HashMap<Player, Block>();
|
||||
public Map<Player, Block> selectedKillLocations = new HashMap<Player, Block>();
|
||||
public Map<Player, Block> selectedReachLocations = new HashMap<Player, Block>();
|
||||
public HashSet<Player> selectingNPCs = new HashSet<Player>();
|
||||
public List<String> names = new LinkedList<String>();
|
||||
ConversationFactory convoCreator;
|
||||
File questsFile;
|
||||
@ -471,7 +473,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
|
||||
return ChatColor.YELLOW + Lang.get("questEditorEnterNPCStart");
|
||||
selectingNPCs.add((Player) context.getForWhom());
|
||||
return ChatColor.YELLOW + Lang.get("questEditorEnterNPCStart") + "\n" + ChatColor.GOLD + Lang.get("npcHint");
|
||||
|
||||
}
|
||||
|
||||
@ -486,12 +489,15 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
}
|
||||
|
||||
context.setSessionData(CK.Q_START_NPC, input.intValue());
|
||||
selectingNPCs.remove((Player) context.getForWhom());
|
||||
return new CreateMenuPrompt();
|
||||
|
||||
} else if (input.intValue() == -1) {
|
||||
context.setSessionData(CK.Q_START_NPC, null);
|
||||
selectingNPCs.remove((Player) context.getForWhom());
|
||||
return new CreateMenuPrompt();
|
||||
} else if (input.intValue() == -2) {
|
||||
selectingNPCs.remove((Player) context.getForWhom());
|
||||
return new CreateMenuPrompt();
|
||||
} else {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidNPC"));
|
||||
@ -1818,29 +1824,28 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
|
||||
LinkedList<String> used = new LinkedList<String>();
|
||||
|
||||
for (Quest quest : quests.quests) {
|
||||
Quest found = quests.findQuest(input);
|
||||
|
||||
if (quest.name.equalsIgnoreCase(input) || quest.name.toLowerCase().contains(input.toLowerCase())) {
|
||||
if (found != null) {
|
||||
|
||||
for (Quest q : quests.quests) {
|
||||
|
||||
if (q.neededQuests.contains(q.name) || q.blockQuests.contains(q.name)) {
|
||||
used.add(q.name);
|
||||
}
|
||||
for (Quest q : quests.quests) {
|
||||
|
||||
if (q.neededQuests.contains(q.name) || q.blockQuests.contains(q.name)) {
|
||||
used.add(q.name);
|
||||
}
|
||||
|
||||
if (used.isEmpty()) {
|
||||
context.setSessionData(CK.ED_QUEST_DELETE, quest.name);
|
||||
return new DeletePrompt();
|
||||
} else {
|
||||
((Player) context.getForWhom()).sendMessage(RED + Lang.get("questEditorQuestAsRequirement1") + " \"" + PURPLE + context.getSessionData(CK.ED_QUEST_DELETE) + RED + "\" " + Lang.get("questEditorQuestAsRequirement2"));
|
||||
for (String s : used) {
|
||||
((Player) context.getForWhom()).sendMessage(RED + "- " + DARKRED + s);
|
||||
}
|
||||
((Player) context.getForWhom()).sendMessage(RED + Lang.get("questEditorQuestAsRequirement3"));
|
||||
return new SelectDeletePrompt();
|
||||
}
|
||||
|
||||
if (used.isEmpty()) {
|
||||
context.setSessionData(CK.ED_QUEST_DELETE, found.name);
|
||||
return new DeletePrompt();
|
||||
} else {
|
||||
((Player) context.getForWhom()).sendMessage(RED + Lang.get("questEditorQuestAsRequirement1") + " \"" + PURPLE + context.getSessionData(CK.ED_QUEST_DELETE) + RED + "\" " + Lang.get("questEditorQuestAsRequirement2"));
|
||||
for (String s : used) {
|
||||
((Player) context.getForWhom()).sendMessage(RED + "- " + DARKRED + s);
|
||||
}
|
||||
((Player) context.getForWhom()).sendMessage(RED + Lang.get("questEditorQuestAsRequirement3"));
|
||||
return new SelectDeletePrompt();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1862,7 +1867,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
|
||||
String text
|
||||
= RED + Lang.get("questEditorDeleted") + " \"" + GOLD + (String) context.getSessionData(CK.ED_QUEST_DELETE) + RED + "\"?\n";
|
||||
text += YELLOW + Lang.get("yes") + "/" + Lang.get(Lang.get("no"));
|
||||
text += YELLOW + Lang.get("yes") + "/" + Lang.get("no");
|
||||
|
||||
return text;
|
||||
|
||||
@ -1874,7 +1879,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
if (input.equalsIgnoreCase(Lang.get("yes"))) {
|
||||
deleteQuest(context);
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
} else if (input.equalsIgnoreCase(Lang.get(Lang.get("no")))) {
|
||||
} else if (input.equalsIgnoreCase(Lang.get("no"))) {
|
||||
return new MenuPrompt();
|
||||
} else {
|
||||
return new DeletePrompt();
|
||||
|
@ -511,16 +511,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
}
|
||||
}
|
||||
|
||||
Quest quest = null;
|
||||
|
||||
for (Quest q : quests) {
|
||||
|
||||
if (q.name.toLowerCase().contains(name)) {
|
||||
quest = q;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
Quest quest = findQuest(name);
|
||||
|
||||
if (quest != null) {
|
||||
|
||||
@ -815,16 +806,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
}
|
||||
|
||||
Quest questToFind = null;
|
||||
|
||||
for (Quest q : quests) {
|
||||
|
||||
if (q.name.toLowerCase().contains(name)) {
|
||||
questToFind = q;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
Quest questToFind = findQuest(name);
|
||||
|
||||
if (questToFind != null) {
|
||||
|
||||
@ -1407,14 +1389,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
}
|
||||
|
||||
for (Quest q : quests) {
|
||||
|
||||
if (q.name.toLowerCase().contains(name)) {
|
||||
questToGive = q;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
questToGive = findQuest(name);
|
||||
|
||||
if (questToGive == null) {
|
||||
|
||||
@ -4264,6 +4239,22 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
return null;
|
||||
}
|
||||
|
||||
public Quest findQuest(String s) {
|
||||
|
||||
for(Quest q : quests) {
|
||||
if(q.name.equalsIgnoreCase(s))
|
||||
return q;
|
||||
}
|
||||
|
||||
for(Quest q : quests) {
|
||||
if(q.name.toLowerCase().contains(s.toLowerCase()))
|
||||
return q;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public Event getEvent(String s) {
|
||||
|
||||
for (Event e : events) {
|
||||
|
@ -1 +0,0 @@
|
||||
Add Heroes class requirements to the RequirementsPrompt, saveQuest() and loadQuest() stages etc. etc.
|
@ -1769,7 +1769,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
String text = GOLD + "- " + Lang.get("stageEditorDeliverItems") + " -\n";
|
||||
if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) {
|
||||
text += GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorAddItem") + "\n";
|
||||
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorDeliveryAddItem") + "\n";
|
||||
text += GRAY + "2 - " + Lang.get("stageEditorDeliveryNPCs") + " (" + Lang.get("stageEditorNoItemsSet") + ")\n";
|
||||
if (context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) == null) {
|
||||
text += BLUE + "3 - " + Lang.get("stageEditorDeliveryMessages") + " (" + Lang.get("noneSet") + ")\n";
|
||||
@ -1792,7 +1792,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
|
||||
}
|
||||
|
||||
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorAddItem") + "\n";
|
||||
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorDeliveryAddItem") + "\n";
|
||||
|
||||
if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) == null) {
|
||||
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("stageEditorDeliveryNPCs") + " (" + Lang.get("noneSet") + ")\n";
|
||||
@ -1956,7 +1956,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
|
||||
if (input.equalsIgnoreCase("cmdCancel") == false) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
|
||||
String[] args = input.split(";");
|
||||
LinkedList<String> messages = new LinkedList<String>();
|
||||
@ -1976,7 +1976,8 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
|
||||
return YELLOW + Lang.get("stageEditorNPCToTalkToPrompt");
|
||||
questFactory.selectingNPCs.add((Player) context.getForWhom());
|
||||
return YELLOW + Lang.get("stageEditorNPCToTalkToPrompt") + "\n" + GOLD + Lang.get("npcHint");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2008,6 +2009,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
|
||||
}
|
||||
|
||||
questFactory.selectingNPCs.remove((Player) context.getForWhom());
|
||||
context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, npcs);
|
||||
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
@ -2016,6 +2018,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
|
||||
}
|
||||
|
||||
|
||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||
|
||||
}
|
||||
@ -2073,13 +2076,13 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||
|
||||
if (input.equalsIgnoreCase("1")) {
|
||||
return new npcIdsToKillPrompt();
|
||||
return new NpcIdsToKillPrompt();
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) {
|
||||
context.getForWhom().sendRawMessage(RED + Lang.get("stageEditorNoNPCs"));
|
||||
return new NPCKillListPrompt();
|
||||
} else {
|
||||
return new npcAmountsToKillPrompt();
|
||||
return new NpcAmountsToKillPrompt();
|
||||
}
|
||||
} else if (input.equalsIgnoreCase("3")) {
|
||||
context.getForWhom().sendRawMessage(YELLOW + Lang.get("stageEditorKillNPCsCleared"));
|
||||
@ -2123,12 +2126,13 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private class npcIdsToKillPrompt extends StringPrompt {
|
||||
private class NpcIdsToKillPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
|
||||
return YELLOW + Lang.get("stageEditorNPCPrompt");
|
||||
questFactory.selectingNPCs.add((Player) context.getForWhom());
|
||||
return YELLOW + Lang.get("stageEditorNPCPrompt") + "\n" + GOLD + Lang.get("npcHint");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2148,13 +2152,13 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
npcs.add(i);
|
||||
} else {
|
||||
context.getForWhom().sendRawMessage(PINK + "" + i + RED + " " + Lang.get("stageEditorInvalidNPC"));
|
||||
return new npcIdsToKillPrompt();
|
||||
return new NpcIdsToKillPrompt();
|
||||
}
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new npcIdsToKillPrompt();
|
||||
return new NpcIdsToKillPrompt();
|
||||
|
||||
}
|
||||
|
||||
@ -2164,12 +2168,13 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
|
||||
}
|
||||
|
||||
questFactory.selectingNPCs.remove((Player) context.getForWhom());
|
||||
return new NPCKillListPrompt();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class npcAmountsToKillPrompt extends StringPrompt {
|
||||
private class NpcAmountsToKillPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
@ -2191,12 +2196,12 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
amounts.add(Integer.parseInt(s));
|
||||
} else {
|
||||
context.getForWhom().sendRawMessage(PINK + s + RED + " " + Lang.get("stageEditorNotGreaterThanZero"));
|
||||
return new npcAmountsToKillPrompt();
|
||||
return new NpcAmountsToKillPrompt();
|
||||
}
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new npcAmountsToKillPrompt();
|
||||
return new NpcAmountsToKillPrompt();
|
||||
}
|
||||
|
||||
}
|
||||
@ -2295,7 +2300,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
|
||||
}
|
||||
|
||||
text += DARKGRAY + "|--------------------------|";
|
||||
text += DARKGRAY + "|--------------------------|\n";
|
||||
|
||||
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
|
||||
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - " + Lang.get("done");
|
||||
@ -2486,7 +2491,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
|
||||
if (Quests.getMobType(s) != null) {
|
||||
|
||||
mobTypes.add(Quester.prettyMobString(Quests.getMobType(s)));
|
||||
mobTypes.add(s);
|
||||
context.setSessionData(pref + CK.S_MOB_TYPES, mobTypes);
|
||||
|
||||
} else {
|
||||
|
@ -174,7 +174,7 @@ public class Lang {
|
||||
en.put("stageEditorItemIDsPrompt", "Enter item IDs, separating each one by a space, or enter \'cancel\' to return.");
|
||||
en.put("stageEditorNPCPrompt", "Enter NPC ids, separating each one by a space, or enter \'cancel\' to return.");
|
||||
en.put("stageEditorNPCToTalkToPrompt", "Enter NPC IDs, separating each one by a space, or enter \'clear\' to clear the NPC ID list, or \'cancel\' to return.");
|
||||
en.put("stageEditorDeliveryMessagesPrompt", "Enter delivery messages, separating each one by a \"semi-colon\" or enter \'cancel\' to return");
|
||||
en.put("stageEditorDeliveryMessagesPrompt", "Enter delivery messages, separating each one by a semi-colon or enter \'cancel\' to return");
|
||||
en.put("stageEditorKillNPCsPrompt", "Enter kill amounts (numbers), separating each one by a space, or enter \'cancel\' to return.");
|
||||
en.put("stageEditorMobsPrompt", "Enter mob names separating each one by a space, or enter \"cancel\" to return");
|
||||
en.put("stageEditorMobAmountsPrompt", "Enter mob amounts separating each one by a space, or enter \"cancel\" to return");
|
||||
@ -482,6 +482,7 @@ public class Lang {
|
||||
en.put("worlds", "Worlds");
|
||||
en.put("mobs", "Mobs");
|
||||
en.put("invalidOption", "Invalid option!");
|
||||
en.put("npcHint", "Note: You can left or right click on NPC's to get their ID.");
|
||||
//
|
||||
//
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user