mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-23 09:37:39 +01:00
Cleanup old methods and fix NPC error, fixes #220. Bump version number
This commit is contained in:
parent
226860d2a1
commit
be2f8d6d60
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<groupId>me.blackvein.quests</groupId>
|
<groupId>me.blackvein.quests</groupId>
|
||||||
<artifactId>quests</artifactId>
|
<artifactId>quests</artifactId>
|
||||||
<version>3.1.8</version>
|
<version>3.1.9</version>
|
||||||
<name>quests</name>
|
<name>quests</name>
|
||||||
<url>https://github.com/FlyingPikachu/Quests/</url>
|
<url>https://github.com/FlyingPikachu/Quests/</url>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
@ -308,7 +308,7 @@ public class Quester {
|
|||||||
public void takeQuest(Quest q, boolean override) {
|
public void takeQuest(Quest q, boolean override) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
if (q.testRequirements(player) == true || override) {
|
if (q.testRequirements(player) == true || override) {
|
||||||
addEmpties(q);
|
addEmptiesFor(q, 0);
|
||||||
currentQuests.put(q, 0);
|
currentQuests.put(q, 0);
|
||||||
Stage stage = q.getStage(0);
|
Stage stage = q.getStage(0);
|
||||||
if (!override) {
|
if (!override) {
|
||||||
@ -606,11 +606,13 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String s : getCurrentStage(quest).passwordDisplays) {
|
for (String s : getCurrentStage(quest).passwordDisplays) {
|
||||||
Boolean b = getQuestData(quest).passwordsSaid.get(s);
|
if (getQuestData(quest).passwordsSaid.containsKey(s)) {
|
||||||
if (b != null && !b) {
|
Boolean b = getQuestData(quest).passwordsSaid.get(s);
|
||||||
unfinishedObjectives.add(ChatColor.GREEN + s);
|
if (b != null && !b) {
|
||||||
} else {
|
unfinishedObjectives.add(ChatColor.GREEN + s);
|
||||||
finishedObjectives.add(ChatColor.GRAY + s);
|
} else {
|
||||||
|
finishedObjectives.add(ChatColor.GRAY + s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@ -902,18 +904,13 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void interactWithNPC(Quest quest, NPC n) {
|
public void interactWithNPC(Quest quest, NPC n) {
|
||||||
try {
|
if (getQuestData(quest).citizensInteracted.containsKey(n.getId())) {
|
||||||
Boolean b = getQuestData(quest).citizensInteracted.containsKey(n.getId());
|
Boolean b = getQuestData(quest).citizensInteracted.get(n.getId());
|
||||||
if (b != null && !b) {
|
if (b != null && !b) {
|
||||||
getQuestData(quest).citizensInteracted.put(n.getId(), true);
|
getQuestData(quest).citizensInteracted.put(n.getId(), true);
|
||||||
finishObjective(quest, "talkToNPC", null, null, null, null, null, n, null, null, null, null);
|
finishObjective(quest, "talkToNPC", null, null, null, null, null, n, null, null, null, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (NullPointerException e) {
|
|
||||||
//TODO Github ticket #220
|
|
||||||
plugin.getLogger().severe("An error has occurred with Quests. Please report on Github. Include the info below");
|
|
||||||
plugin.getLogger().severe("npc + id = " + n.getName() + " + " + n.getId());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void killNPC(Quest quest, NPC n) {
|
public void killNPC(Quest quest, NPC n) {
|
||||||
@ -1234,143 +1231,18 @@ public class Quester {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEmpties(Quest quest) {
|
/**
|
||||||
QuestData data = new QuestData(this);
|
* Add empty map values per Quest stage
|
||||||
data.setDoJournalUpdate(false);
|
*
|
||||||
if (quest.getStage(0).blocksToBreak.isEmpty() == false) {
|
* @param quest Quest with at least one stage
|
||||||
for (ItemStack i : quest.getStage(0).blocksToBreak) {
|
* @param stage Where first stage is '0'
|
||||||
if (data.blocksBroken.indexOf(i) != -1) {
|
*/
|
||||||
// TODO Will this ever happen?
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
|
||||||
data.blocksBroken.set(data.blocksBroken.indexOf(temp), temp);
|
|
||||||
} else {
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
|
||||||
data.blocksBroken.add(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.getStage(0).blocksToDamage.isEmpty() == false) {
|
|
||||||
for (ItemStack i : quest.getStage(0).blocksToDamage) {
|
|
||||||
if (data.blocksDamaged.indexOf(i) != -1) {
|
|
||||||
// TODO Will this ever happen?
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
|
||||||
data.blocksDamaged.set(data.blocksDamaged.indexOf(temp), temp);
|
|
||||||
} else {
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
|
||||||
data.blocksDamaged.add(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.getStage(0).blocksToPlace.isEmpty() == false) {
|
|
||||||
for (ItemStack i : quest.getStage(0).blocksToPlace) {
|
|
||||||
if (data.blocksPlaced.indexOf(i) != -1) {
|
|
||||||
// TODO Will this ever happen?
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
|
||||||
data.blocksPlaced.set(data.blocksPlaced.indexOf(temp), temp);
|
|
||||||
} else {
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
|
||||||
data.blocksPlaced.add(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.getStage(0).blocksToUse.isEmpty() == false) {
|
|
||||||
for (ItemStack i : quest.getStage(0).blocksToUse) {
|
|
||||||
if (data.blocksUsed.indexOf(i) != -1) {
|
|
||||||
// TODO Will this ever happen?
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
|
||||||
data.blocksUsed.set(data.blocksUsed.indexOf(temp), temp);
|
|
||||||
} else {
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
|
||||||
data.blocksUsed.add(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.getStage(0).blocksToCut.isEmpty() == false) {
|
|
||||||
for (ItemStack i : quest.getStage(0).blocksToCut) {
|
|
||||||
if (data.blocksCut.indexOf(i) != -1) {
|
|
||||||
// TODO Will this ever happen?
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
|
||||||
data.blocksCut.set(data.blocksCut.indexOf(temp), temp);
|
|
||||||
} else {
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
|
||||||
data.blocksCut.add(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data.setFishCaught(0);
|
|
||||||
if (quest.getStage(0).itemsToEnchant.isEmpty() == false) {
|
|
||||||
for (Entry<Map<Enchantment, Material>, Integer> e : quest.getStage(0).itemsToEnchant.entrySet()) {
|
|
||||||
Map<Enchantment, Material> map = (Map<Enchantment, Material>) e.getKey();
|
|
||||||
data.itemsEnchanted.put(map, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.getStage(0).mobsToKill.isEmpty() == false) {
|
|
||||||
for (EntityType e : quest.getStage(0).mobsToKill) {
|
|
||||||
data.mobsKilled.add(e);
|
|
||||||
data.mobNumKilled.add(0);
|
|
||||||
if (quest.getStage(0).locationsToKillWithin.isEmpty() == false) {
|
|
||||||
data.locationsToKillWithin.add(quest.getStage(0).locationsToKillWithin.get(data.mobsKilled.indexOf(e)));
|
|
||||||
}
|
|
||||||
if (quest.getStage(0).radiiToKillWithin.isEmpty() == false) {
|
|
||||||
data.radiiToKillWithin.add(quest.getStage(0).radiiToKillWithin.get(data.mobsKilled.indexOf(e)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data.setPlayersKilled(0);
|
|
||||||
if (quest.getStage(0).itemsToDeliver.isEmpty() == false) {
|
|
||||||
for (ItemStack is : quest.getStage(0).itemsToDeliver) {
|
|
||||||
data.itemsDelivered.put(is, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.getStage(0).citizensToInteract.isEmpty() == false) {
|
|
||||||
for (Integer n : quest.getStage(0).citizensToInteract) {
|
|
||||||
data.citizensInteracted.put(n, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.getStage(0).citizensToKill.isEmpty() == false) {
|
|
||||||
for (Integer n : quest.getStage(0).citizensToKill) {
|
|
||||||
data.citizensKilled.add(n);
|
|
||||||
data.citizenNumKilled.add(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.getStage(0).locationsToReach.isEmpty() == false) {
|
|
||||||
for (Location l : quest.getStage(0).locationsToReach) {
|
|
||||||
data.locationsReached.add(l);
|
|
||||||
data.hasReached.add(false);
|
|
||||||
data.radiiToReachWithin.add(quest.getStage(0).radiiToReachWithin.get(data.locationsReached.indexOf(l)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.getStage(0).mobsToTame.isEmpty() == false) {
|
|
||||||
for (EntityType e : quest.getStage(0).mobsToTame.keySet()) {
|
|
||||||
data.mobsTamed.put(e, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.getStage(0).sheepToShear.isEmpty() == false) {
|
|
||||||
for (DyeColor d : quest.getStage(0).sheepToShear.keySet()) {
|
|
||||||
data.sheepSheared.put(d, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.getStage(0).passwordDisplays.isEmpty() == false) {
|
|
||||||
for (String display : quest.getStage(0).passwordDisplays) {
|
|
||||||
data.passwordsSaid.put(display, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (quest.getStage(0).customObjectives.isEmpty() == false) {
|
|
||||||
for (CustomObjective co : quest.getStage(0).customObjectives) {
|
|
||||||
data.customObjectiveCounts.put(co.getName(), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data.setDoJournalUpdate(true);
|
|
||||||
hardDataPut(quest, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addEmptiesFor(Quest quest, int stage) {
|
public void addEmptiesFor(Quest quest, int stage) {
|
||||||
QuestData data = new QuestData(this);
|
QuestData data = new QuestData(this);
|
||||||
data.setDoJournalUpdate(false);
|
data.setDoJournalUpdate(false);
|
||||||
if (quest.getStage(stage).blocksToBreak.isEmpty() == false) {
|
if (quest.getStage(stage).blocksToBreak.isEmpty() == false) {
|
||||||
for (ItemStack i : quest.getStage(stage).blocksToBreak) {
|
for (ItemStack i : quest.getStage(stage).blocksToBreak) {
|
||||||
if (data.blocksBroken.indexOf(i) != -1) {
|
if (data.blocksBroken.indexOf(i) != -1) {
|
||||||
// TODO Will this ever happen?
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
||||||
data.blocksBroken.set(data.blocksBroken.indexOf(temp), temp);
|
data.blocksBroken.set(data.blocksBroken.indexOf(temp), temp);
|
||||||
} else {
|
} else {
|
||||||
@ -1382,7 +1254,6 @@ public class Quester {
|
|||||||
if (quest.getStage(stage).blocksToDamage.isEmpty() == false) {
|
if (quest.getStage(stage).blocksToDamage.isEmpty() == false) {
|
||||||
for (ItemStack i : quest.getStage(stage).blocksToDamage) {
|
for (ItemStack i : quest.getStage(stage).blocksToDamage) {
|
||||||
if (data.blocksDamaged.indexOf(i) != -1) {
|
if (data.blocksDamaged.indexOf(i) != -1) {
|
||||||
// TODO Will this ever happen?
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
||||||
data.blocksDamaged.set(data.blocksDamaged.indexOf(temp), temp);
|
data.blocksDamaged.set(data.blocksDamaged.indexOf(temp), temp);
|
||||||
} else {
|
} else {
|
||||||
@ -1394,7 +1265,6 @@ public class Quester {
|
|||||||
if (quest.getStage(stage).blocksToPlace.isEmpty() == false) {
|
if (quest.getStage(stage).blocksToPlace.isEmpty() == false) {
|
||||||
for (ItemStack i : quest.getStage(stage).blocksToPlace) {
|
for (ItemStack i : quest.getStage(stage).blocksToPlace) {
|
||||||
if (data.blocksPlaced.indexOf(i) != -1) {
|
if (data.blocksPlaced.indexOf(i) != -1) {
|
||||||
// TODO Will this ever happen?
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
||||||
data.blocksPlaced.set(data.blocksPlaced.indexOf(temp), temp);
|
data.blocksPlaced.set(data.blocksPlaced.indexOf(temp), temp);
|
||||||
} else {
|
} else {
|
||||||
@ -1406,7 +1276,6 @@ public class Quester {
|
|||||||
if (quest.getStage(stage).blocksToUse.isEmpty() == false) {
|
if (quest.getStage(stage).blocksToUse.isEmpty() == false) {
|
||||||
for (ItemStack i : quest.getStage(stage).blocksToUse) {
|
for (ItemStack i : quest.getStage(stage).blocksToUse) {
|
||||||
if (data.blocksUsed.indexOf(i) != -1) {
|
if (data.blocksUsed.indexOf(i) != -1) {
|
||||||
// TODO Will this ever happen?
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
||||||
data.blocksUsed.set(data.blocksUsed.indexOf(temp), temp);
|
data.blocksUsed.set(data.blocksUsed.indexOf(temp), temp);
|
||||||
} else {
|
} else {
|
||||||
@ -1418,7 +1287,6 @@ public class Quester {
|
|||||||
if (quest.getStage(stage).blocksToCut.isEmpty() == false) {
|
if (quest.getStage(stage).blocksToCut.isEmpty() == false) {
|
||||||
for (ItemStack i : quest.getStage(stage).blocksToCut) {
|
for (ItemStack i : quest.getStage(stage).blocksToCut) {
|
||||||
if (data.blocksCut.indexOf(i) != -1) {
|
if (data.blocksCut.indexOf(i) != -1) {
|
||||||
// TODO Will this ever happen?
|
|
||||||
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
ItemStack temp = new ItemStack(i.getType(), 0, i.getDurability());
|
||||||
data.blocksCut.set(data.blocksCut.indexOf(temp), temp);
|
data.blocksCut.set(data.blocksCut.indexOf(temp), temp);
|
||||||
} else {
|
} else {
|
||||||
@ -1501,7 +1369,13 @@ public class Quester {
|
|||||||
return capitalized;
|
return capitalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Use ItemUtil.getString(itemStack) instead if possible
|
/**
|
||||||
|
* Cleans up item names. 'WOODEN_BUTTON' becomes 'Wooden Button'
|
||||||
|
*
|
||||||
|
* @deprecated Use ItemUtil.getString(itemStack) instead if possible
|
||||||
|
* @param itemName any item name, ideally
|
||||||
|
* @return cleaned-up string
|
||||||
|
*/
|
||||||
public static String prettyItemString(String itemName) {
|
public static String prettyItemString(String itemName) {
|
||||||
String baseString = Material.matchMaterial(itemName).toString();
|
String baseString = Material.matchMaterial(itemName).toString();
|
||||||
String[] substrings = baseString.split("_");
|
String[] substrings = baseString.split("_");
|
||||||
@ -1978,7 +1852,7 @@ public class Quester {
|
|||||||
plugin.getLogger().severe("[Quests] Invalid stage number for player: \"" + id + "\" on Quest \"" + quest.name + "\". Quest ended.");
|
plugin.getLogger().severe("[Quests] Invalid stage number for player: \"" + id + "\" on Quest \"" + quest.name + "\". Quest ended.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
addEmpties(quest);
|
addEmptiesFor(quest, 0);
|
||||||
if (questSec == null)
|
if (questSec == null)
|
||||||
continue;
|
continue;
|
||||||
if (questSec.contains("blocks-broken-names")) {
|
if (questSec.contains("blocks-broken-names")) {
|
||||||
|
@ -52,7 +52,7 @@ public class StageTimer implements Runnable {
|
|||||||
currentStage.finishEvent.fire(quester, quest);
|
currentStage.finishEvent.fire(quester, quest);
|
||||||
}
|
}
|
||||||
quester.hardStagePut(quest, stageNum);
|
quester.hardStagePut(quest, stageNum);
|
||||||
quester.addEmpties(quest);
|
quester.addEmptiesFor(quest, 0);
|
||||||
quester.getQuestData(quest).delayStartTime = 0;
|
quester.getQuestData(quest).delayStartTime = 0;
|
||||||
quester.getQuestData(quest).delayTimeLeft = -1;
|
quester.getQuestData(quest).delayTimeLeft = -1;
|
||||||
String msg = Lang.get("questObjectivesTitle");
|
String msg = Lang.get("questObjectivesTitle");
|
||||||
|
Loading…
Reference in New Issue
Block a user