diff --git a/dist/pom.xml b/dist/pom.xml
index 27bd667b5..f06aef4c9 100644
--- a/dist/pom.xml
+++ b/dist/pom.xml
@@ -5,7 +5,7 @@
me.blackvein.quests
quests-parent
- 3.8.1
+ 3.8.2
quests-dist
pom
diff --git a/main/pom.xml b/main/pom.xml
index 10bbef23e..938f149dd 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -4,7 +4,7 @@
me.blackvein.quests
quests-parent
- 3.8.1
+ 3.8.2
quests-main
diff --git a/main/src/main/java/me/blackvein/quests/Dependencies.java b/main/src/main/java/me/blackvein/quests/Dependencies.java
index de32622cb..2218c5299 100644
--- a/main/src/main/java/me/blackvein/quests/Dependencies.java
+++ b/main/src/main/java/me/blackvein/quests/Dependencies.java
@@ -12,9 +12,14 @@
package me.blackvein.quests;
+import java.util.UUID;
+
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import me.blackvein.quests.util.DenizenAPI;
+import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.WorldGuardAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import net.citizensnpcs.api.CitizensPlugin;
@@ -27,7 +32,11 @@ import com.alessiodp.parties.api.Parties;
import com.alessiodp.parties.api.interfaces.PartiesAPI;
import com.codisimus.plugins.phatloots.PhatLoots;
import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.datatypes.player.McMMOPlayer;
+import com.gmail.nossr50.datatypes.skills.SkillType;
+import com.gmail.nossr50.util.player.UserManager;
import com.herocraftonline.heroes.Heroes;
+import com.herocraftonline.heroes.characters.Hero;
import de.erethon.dungeonsxl.DungeonsXL;
@@ -40,7 +49,7 @@ public class Dependencies {
private static mcMMO mcmmo = null;
private static Heroes heroes = null;
private static PhatLoots phatLoots = null;
- private static PlaceholderAPIPlugin placeholder = null;
+ public static PlaceholderAPIPlugin placeholder = null;
private static CitizensPlugin citizens = null;
private static DenizenAPI denizenApi = null;
private static CitizensBooksAPI citizensBooks = null;
@@ -215,7 +224,61 @@ public class Dependencies {
return (permission != null);
}
+ public String getCurrency(boolean plural) {
+ if (getVaultEconomy() == null) {
+ return Lang.get("money");
+ }
+ if (plural) {
+ if (getVaultEconomy().currencyNamePlural().trim().isEmpty()) {
+ return Lang.get("money");
+ } else {
+ return getVaultEconomy().currencyNamePlural();
+ }
+ } else {
+ if (getVaultEconomy().currencyNameSingular().trim().isEmpty()) {
+ return Lang.get("money");
+ } else {
+ return getVaultEconomy().currencyNameSingular();
+ }
+ }
+ }
+
public boolean runDenizenScript(String scriptName, Quester quester) {
return plugin.getDenizenTrigger().runDenizenScript(scriptName, quester);
}
+
+ public Location getNPCLocation(int id) {
+ return citizens.getNPCRegistry().getById(id).getStoredLocation();
+ }
+
+ public String getNPCName(int id) {
+ return citizens.getNPCRegistry().getById(id).getName();
+ }
+
+ public int getMcmmoSkillLevel(SkillType st, String player) {
+ McMMOPlayer mPlayer = UserManager.getPlayer(player);
+ if (mPlayer == null) {
+ return -1;
+ }
+ return mPlayer.getProfile().getSkillLevel(st);
+ }
+
+ public Hero getHero(UUID uuid) {
+ Player p = plugin.getServer().getPlayer(uuid);
+ if (p == null) {
+ return null;
+ }
+ return heroes.getCharacterManager().getHero(p);
+ }
+
+ public boolean testPrimaryHeroesClass(String primaryClass, UUID uuid) {
+ Hero hero = getHero(uuid);
+ return hero.getHeroClass().getName().equalsIgnoreCase(primaryClass);
+ }
+
+ @SuppressWarnings("deprecation")
+ public boolean testSecondaryHeroesClass(String secondaryClass, UUID uuid) {
+ Hero hero = getHero(uuid);
+ return hero.getSecondClass().getName().equalsIgnoreCase(secondaryClass);
+ }
}
diff --git a/main/src/main/java/me/blackvein/quests/Quest.java b/main/src/main/java/me/blackvein/quests/Quest.java
index 3097f2433..e59ce1dce 100644
--- a/main/src/main/java/me/blackvein/quests/Quest.java
+++ b/main/src/main/java/me/blackvein/quests/Quest.java
@@ -41,6 +41,8 @@ import me.blackvein.quests.events.quester.QuesterPreChangeStageEvent;
import me.blackvein.quests.events.quester.QuesterPreCompleteQuestEvent;
import me.blackvein.quests.events.quester.QuesterPreFailQuestEvent;
import me.blackvein.quests.exceptions.InvalidStageException;
+import me.blackvein.quests.util.ConfigUtil;
+import me.blackvein.quests.util.InventoryUtil;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import me.clip.placeholderapi.PlaceholderAPI;
@@ -53,11 +55,11 @@ public class Quest {
private String name;
protected String description;
protected String finished;
- protected String region = null;
protected ItemStack guiDisplay = null;
private LinkedList orderedStages = new LinkedList();
protected NPC npcStart;
protected Location blockStart;
+ protected String regionStart = null;
protected Action initialAction;
private Requirements reqs = new Requirements();
private Planner pln = new Planner();
@@ -92,12 +94,26 @@ public class Quest {
this.finished = finished;
}
- public String getRegion() {
- return region;
+ public String getRegionStart() {
+ return regionStart;
}
+ public void setRegionStart(String regionStart) {
+ this.regionStart = regionStart;
+ }
+
+ /**
+ * @deprecated Use {@link #getRegionStart()}
+ */
+ public String getRegion() {
+ return getRegionStart();
+ }
+
+ /**
+ * @deprecated Use {@link #setRegion(String)}
+ */
public void setRegion(String region) {
- this.region = region;
+ setRegionStart(region);
}
public ItemStack getGUIDisplay() {
@@ -184,7 +200,7 @@ public class Quest {
}
String stageCompleteMessage = currentStage.completeMessage;
if (stageCompleteMessage != null) {
- quester.getPlayer().sendMessage(plugin.parseStringWithPossibleLineBreaks(stageCompleteMessage,
+ quester.getPlayer().sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(stageCompleteMessage,
this, quester.getPlayer()));
}
if (plugin.getSettings().canUseCompass()) {
@@ -260,7 +276,7 @@ public class Quest {
plugin.showObjectives(this, quester, false);
String stageStartMessage = quester.getCurrentStage(this).startMessage;
if (stageStartMessage != null) {
- quester.getPlayer().sendMessage(plugin.parseStringWithPossibleLineBreaks(stageStartMessage, this,
+ quester.getPlayer().sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(stageStartMessage, this,
quester.getPlayer()));
}
quester.updateJournal();
@@ -289,9 +305,9 @@ public class Quest {
}
Location targetLocation = null;
if (nextStage.citizensToInteract != null && nextStage.citizensToInteract.size() > 0) {
- targetLocation = plugin.getNPCLocation(nextStage.citizensToInteract.getFirst());
+ targetLocation = plugin.getDependencies().getNPCLocation(nextStage.citizensToInteract.getFirst());
} else if (nextStage.citizensToKill != null && nextStage.citizensToKill.size() > 0) {
- targetLocation = plugin.getNPCLocation(nextStage.citizensToKill.getFirst());
+ targetLocation = plugin.getDependencies().getNPCLocation(nextStage.citizensToKill.getFirst());
} else if (nextStage.locationsToReach != null && nextStage.locationsToReach.size() > 0) {
targetLocation = nextStage.locationsToReach.getFirst();
} else if (nextStage.itemDeliveryTargets != null && nextStage.itemDeliveryTargets.size() > 0) {
@@ -359,12 +375,14 @@ public class Quest {
}
}
if (reqs.getHeroesPrimaryClass() != null) {
- if (plugin.testPrimaryHeroesClass(reqs.getHeroesPrimaryClass(), player.getUniqueId()) == false) {
+ if (plugin.getDependencies()
+ .testPrimaryHeroesClass(reqs.getHeroesPrimaryClass(), player.getUniqueId()) == false) {
return false;
}
}
if (reqs.getHeroesSecondaryClass() != null) {
- if (plugin.testSecondaryHeroesClass(reqs.getHeroesSecondaryClass(), player.getUniqueId()) == false) {
+ if (plugin.getDependencies()
+ .testSecondaryHeroesClass(reqs.getHeroesSecondaryClass(), player.getUniqueId()) == false) {
return false;
}
}
@@ -447,7 +465,7 @@ public class Quest {
}
for (ItemStack i : rews.getItems()) {
try {
- Quests.addItem(player, i);
+ InventoryUtil.addItem(player, i);
} catch (Exception e) {
plugin.getLogger().severe("Unable to add null reward item to inventory of "
+ player.getName() + " upon completion of quest " + name);
@@ -511,7 +529,7 @@ public class Quest {
phatLootItems.addAll(lb.getItemList());
for (ItemStack is : lb.getItemList()) {
try {
- Quests.addItem(player, is);
+ InventoryUtil.addItem(player, is);
} catch (Exception e) {
plugin.getLogger().severe("Unable to add PhatLoots item to inventory of " + player.getName()
+ " upon completion of quest " + name);
@@ -653,12 +671,10 @@ public class Quest {
int index = 0;
for (String s : rews.getCommands()) {
if (rews.getCommandsOverrideDisplay().isEmpty() == false && rews.getCommandsOverrideDisplay().size()
- >= index) {
- if (rews.getCommandsOverrideDisplay().size() > index) {
- if (!rews.getCommandsOverrideDisplay().get(index).trim().equals("")) {
- player.sendMessage("- " + ChatColor.DARK_GREEN
- + rews.getCommandsOverrideDisplay().get(index));
- }
+ > index) {
+ if (!rews.getCommandsOverrideDisplay().get(index).trim().equals("")) {
+ player.sendMessage("- " + ChatColor.DARK_GREEN
+ + rews.getCommandsOverrideDisplay().get(index));
}
} else {
player.sendMessage("- " + ChatColor.DARK_GREEN + s);
@@ -779,11 +795,11 @@ public class Quest {
* @return true if player is in region
*/
private boolean isInRegion(Player player) {
- if (region == null) {
+ if (regionStart == null) {
return false;
}
if (plugin.getDependencies().getWorldGuardApi()
- .getApplicableRegionsIDs(player.getWorld(), player.getLocation()).contains(region)) {
+ .getApplicableRegionsIDs(player.getWorld(), player.getLocation()).contains(regionStart)) {
return true;
}
return false;
diff --git a/main/src/main/java/me/blackvein/quests/QuestData.java b/main/src/main/java/me/blackvein/quests/QuestData.java
index 3b62b0155..26e1a4cf8 100644
--- a/main/src/main/java/me/blackvein/quests/QuestData.java
+++ b/main/src/main/java/me/blackvein/quests/QuestData.java
@@ -398,21 +398,29 @@ public class QuestData {
}
};
- public LinkedHashMap itemsDelivered = new LinkedHashMap() {
+ public LinkedList itemsDelivered = new LinkedList() {
private static final long serialVersionUID = 2712497347022734646L;
@Override
- public Integer put(ItemStack key, Integer val) {
- Integer data = super.put(key, val);
+ public ItemStack set(int index, ItemStack key) {
+ ItemStack data = super.set(index, key);
if (doJournalUpdate)
quester.updateJournal();
return data;
}
@Override
- public Integer remove(Object key) {
- Integer i = super.remove(key);
+ public boolean add(ItemStack key) {
+ boolean data = super.add(key);
+ if (doJournalUpdate)
+ quester.updateJournal();
+ return data;
+ }
+
+ @Override
+ public boolean remove(Object key) {
+ boolean i = super.remove(key);
if (doJournalUpdate)
quester.updateJournal();
return i;
@@ -426,10 +434,11 @@ public class QuestData {
}
@Override
- public void putAll(Map extends ItemStack, ? extends Integer> m) {
- super.putAll(m);
+ public boolean addAll(Collection extends ItemStack> m) {
+ boolean i = super.addAll(m);
if (doJournalUpdate)
quester.updateJournal();
+ return i;
}
};
diff --git a/main/src/main/java/me/blackvein/quests/QuestFactory.java b/main/src/main/java/me/blackvein/quests/QuestFactory.java
index 10dcfee35..445742da6 100644
--- a/main/src/main/java/me/blackvein/quests/QuestFactory.java
+++ b/main/src/main/java/me/blackvein/quests/QuestFactory.java
@@ -58,6 +58,7 @@ import me.blackvein.quests.prompts.RewardsPrompt;
import me.blackvein.quests.prompts.PlannerPrompt;
import me.blackvein.quests.prompts.StagesPrompt;
import me.blackvein.quests.util.CK;
+import me.blackvein.quests.util.ConfigUtil;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil;
@@ -431,7 +432,7 @@ public class QuestFactory implements ConversationAbandonedListener {
+ ChatColor.GOLD + " -\n";
for (int i = 1; i <= size; i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
- + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
+ + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
}
return text;
}
@@ -496,7 +497,7 @@ public class QuestFactory implements ConversationAbandonedListener {
for (Quest q : plugin.getQuests()) {
s += ChatColor.GRAY + "- " + ChatColor.YELLOW + q.getName() + "\n";
}
- return s + ChatColor.GOLD + Lang.get("questEditorEditEnterQuestName");
+ return s + ChatColor.GOLD + Lang.get("questEditorEnterQuestName");
}
@Override
@@ -513,6 +514,382 @@ public class QuestFactory implements ConversationAbandonedListener {
}
}
}
+
+ @SuppressWarnings("deprecation")
+ public static void loadQuest(ConversationContext cc, Quest q) {
+ cc.setSessionData(CK.ED_QUEST_EDIT, q.getName());
+ cc.setSessionData(CK.Q_NAME, q.getName());
+ if (q.npcStart != null) {
+ cc.setSessionData(CK.Q_START_NPC, q.npcStart.getId());
+ }
+ cc.setSessionData(CK.Q_START_BLOCK, q.blockStart);
+ cc.setSessionData(CK.Q_ASK_MESSAGE, q.description);
+ cc.setSessionData(CK.Q_FINISH_MESSAGE, q.finished);
+ if (q.initialAction != null) {
+ cc.setSessionData(CK.Q_INITIAL_EVENT, q.initialAction.getName());
+ }
+ if (q.regionStart != null) {
+ cc.setSessionData(CK.Q_REGION, q.regionStart);
+ }
+ if (q.guiDisplay != null) {
+ cc.setSessionData(CK.Q_GUIDISPLAY, q.guiDisplay);
+ }
+ Requirements reqs = q.getRequirements();
+ if (reqs.getMoney() != 0) {
+ cc.setSessionData(CK.REQ_MONEY, reqs.getMoney());
+ }
+ if (reqs.getQuestPoints() != 0) {
+ cc.setSessionData(CK.REQ_QUEST_POINTS, reqs.getQuestPoints());
+ }
+ if (reqs.getItems().isEmpty() == false) {
+ cc.setSessionData(CK.REQ_ITEMS, reqs.getItems());
+ cc.setSessionData(CK.REQ_ITEMS_REMOVE, reqs.getRemoveItems());
+ }
+ if (reqs.getNeededQuests().isEmpty() == false) {
+ cc.setSessionData(CK.REQ_QUEST, reqs.getNeededQuests());
+ }
+ if (reqs.getBlockQuests().isEmpty() == false) {
+ cc.setSessionData(CK.REQ_QUEST_BLOCK, reqs.getBlockQuests());
+ }
+ if (reqs.getMcmmoSkills().isEmpty() == false) {
+ cc.setSessionData(CK.REQ_MCMMO_SKILLS, reqs.getMcmmoAmounts());
+ cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, reqs.getMcmmoAmounts());
+ }
+ if (reqs.getPermissions().isEmpty() == false) {
+ cc.setSessionData(CK.REQ_PERMISSION, reqs.getPermissions());
+ }
+ if (reqs.getHeroesPrimaryClass() != null) {
+ cc.setSessionData(CK.REQ_HEROES_PRIMARY_CLASS, reqs.getHeroesPrimaryClass());
+ }
+ if (reqs.getHeroesSecondaryClass() != null) {
+ cc.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, reqs.getHeroesSecondaryClass());
+ }
+ if (reqs.getFailRequirements() != null) {
+ cc.setSessionData(CK.Q_FAIL_MESSAGE, reqs.getFailRequirements());
+ }
+ if (reqs.getCustomRequirements().isEmpty() == false) {
+ LinkedList list = new LinkedList();
+ LinkedList