mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-03 15:08:10 +01:00
Refactoring for getter/setter methods, part 1. Bump version number
This commit is contained in:
parent
b5e948845e
commit
3d4f94e0ef
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.5.9</version>
|
<version>3.6.0</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>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests;
|
package me.blackvein.listeners;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -30,6 +30,9 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||||
|
|
||||||
|
import me.blackvein.quests.Quest;
|
||||||
|
import me.blackvein.quests.Quester;
|
||||||
|
import me.blackvein.quests.Quests;
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
import me.blackvein.quests.util.Lang;
|
import me.blackvein.quests.util.Lang;
|
||||||
import me.blackvein.quests.util.RomanNumeral;
|
import me.blackvein.quests.util.RomanNumeral;
|
||||||
@ -63,7 +66,7 @@ public class NpcListener implements Listener {
|
|||||||
ItemStack hand = player.getItemInHand();
|
ItemStack hand = player.getItemInHand();
|
||||||
ItemStack found = null;
|
ItemStack found = null;
|
||||||
int reasonCode = 0;
|
int reasonCode = 0;
|
||||||
for (ItemStack is : quester.getCurrentStage(quest).itemsToDeliver) {
|
for (ItemStack is : quester.getCurrentStage(quest).getItemsToDeliver()) {
|
||||||
reasonCode = ItemUtil.compareItems(is, hand, true);
|
reasonCode = ItemUtil.compareItems(is, hand, true);
|
||||||
if (reasonCode == 0) {
|
if (reasonCode == 0) {
|
||||||
found = is;
|
found = is;
|
||||||
@ -72,7 +75,7 @@ public class NpcListener implements Listener {
|
|||||||
}
|
}
|
||||||
NPC clicked = evt.getNPC();
|
NPC clicked = evt.getNPC();
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
for (Integer n : quester.getCurrentStage(quest).itemDeliveryTargets) {
|
for (Integer n : quester.getCurrentStage(quest).getItemDeliveryTargets()) {
|
||||||
if (n.equals(clicked.getId())) {
|
if (n.equals(clicked.getId())) {
|
||||||
quester.deliverItem(quest, hand);
|
quester.deliverItem(quest, hand);
|
||||||
delivery = true;
|
delivery = true;
|
||||||
@ -81,7 +84,7 @@ public class NpcListener implements Listener {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else if (!hand.getType().equals(Material.AIR)) {
|
} else if (!hand.getType().equals(Material.AIR)) {
|
||||||
for (Integer n : quester.getCurrentStage(quest).itemDeliveryTargets) {
|
for (Integer n : quester.getCurrentStage(quest).getItemDeliveryTargets()) {
|
||||||
if (n.equals(clicked.getId())) {
|
if (n.equals(clicked.getId())) {
|
||||||
String text = "";
|
String text = "";
|
||||||
if (hand.hasItemMeta()) {
|
if (hand.hasItemMeta()) {
|
||||||
@ -92,27 +95,36 @@ public class NpcListener implements Listener {
|
|||||||
text += (hand.getItemMeta().hasDisplayName() ? ")" : "");
|
text += (hand.getItemMeta().hasDisplayName() ? ")" : "");
|
||||||
}
|
}
|
||||||
text += " x " + ChatColor.DARK_AQUA + hand.getAmount() + ChatColor.GRAY;
|
text += " x " + ChatColor.DARK_AQUA + hand.getAmount() + ChatColor.GRAY;
|
||||||
plugin.query.sendMessage(player, Lang.get(player, "difference").replace("<item>", text), hand.getType(), hand.getDurability());
|
plugin.query.sendMessage(player, Lang.get(player, "questInvalidDeliveryItem").replace("<item>", text), hand.getType(), hand.getDurability());
|
||||||
switch(reasonCode) {
|
switch(reasonCode) {
|
||||||
case 1:
|
case 1:
|
||||||
player.sendMessage(Lang.get(player, "difference").replace("<data>", "one item is null"));
|
player.sendMessage(Lang.get(player, "difference").replace("<data>", "one item is null"));
|
||||||
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
// Should never happen
|
// Should never happen
|
||||||
player.sendMessage(Lang.get(player, "difference").replace("<data>", "ERROR"));
|
player.sendMessage(Lang.get(player, "difference").replace("<data>", "ERROR"));
|
||||||
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
player.sendMessage(Lang.get(player, "difference").replace("<data>", "name"));
|
player.sendMessage(Lang.get(player, "difference").replace("<data>", "name"));
|
||||||
|
break;
|
||||||
case -2:
|
case -2:
|
||||||
player.sendMessage(Lang.get(player, "difference").replace("<data>", "amount"));
|
player.sendMessage(Lang.get(player, "difference").replace("<data>", "amount"));
|
||||||
|
break;
|
||||||
case -3:
|
case -3:
|
||||||
player.sendMessage(Lang.get(player, "difference").replace("<data>", "durability"));
|
player.sendMessage(Lang.get(player, "difference").replace("<data>", "durability"));
|
||||||
|
break;
|
||||||
case -4:
|
case -4:
|
||||||
player.sendMessage(Lang.get(player, "difference").replace("<data>", "display name or lore"));
|
player.sendMessage(Lang.get(player, "difference").replace("<data>", "display name or lore"));
|
||||||
|
break;
|
||||||
case -5:
|
case -5:
|
||||||
player.sendMessage(Lang.get(player, "difference").replace("<data>", "enchantments"));
|
player.sendMessage(Lang.get(player, "difference").replace("<data>", "enchantments"));
|
||||||
|
break;
|
||||||
case -6:
|
case -6:
|
||||||
player.sendMessage(Lang.get(player, "difference").replace("<data>", "stored enchants"));
|
player.sendMessage(Lang.get(player, "difference").replace("<data>", "stored enchants"));
|
||||||
|
break;
|
||||||
case -7:
|
case -7:
|
||||||
player.sendMessage(Lang.get(player, "difference").replace("<data>", "item flags"));
|
player.sendMessage(Lang.get(player, "difference").replace("<data>", "item flags"));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
player.sendMessage(Lang.get(player, "difference").replace("<data>", "unknown"));
|
player.sendMessage(Lang.get(player, "difference").replace("<data>", "unknown"));
|
||||||
}
|
}
|
||||||
@ -149,7 +161,7 @@ public class NpcListener implements Listener {
|
|||||||
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.getNpcStart() != null && q.getNpcStart().getId() == evt.getNPC().getId()) {
|
||||||
if (plugin.ignoreLockedQuests && (quester.completedQuests.contains(q.getName()) == false || q.cooldownPlanner > -1)) {
|
if (plugin.ignoreLockedQuests && (quester.completedQuests.contains(q.getName()) == false || q.cooldownPlanner > -1)) {
|
||||||
if (q.testRequirements(quester)) {
|
if (q.testRequirements(quester)) {
|
||||||
npcQuests.add(q);
|
npcQuests.add(q);
|
||||||
@ -267,6 +279,6 @@ public class NpcListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String extracted(final Quester quester) {
|
private String extracted(final Quester quester) {
|
||||||
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, quester.questToTake, ChatColor.GOLD, ChatColor.RESET, plugin.getQuest(quester.questToTake).description);
|
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, quester.questToTake, ChatColor.GOLD, ChatColor.RESET, plugin.getQuest(quester.questToTake).getDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,7 +10,7 @@
|
|||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*******************************************************************************************************/
|
*******************************************************************************************************/
|
||||||
|
|
||||||
package me.blackvein.quests;
|
package me.blackvein.listeners;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -64,6 +64,10 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
|
import me.blackvein.quests.Quest;
|
||||||
|
import me.blackvein.quests.Quester;
|
||||||
|
import me.blackvein.quests.Quests;
|
||||||
|
import me.blackvein.quests.Stage;
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
import me.blackvein.quests.util.Lang;
|
import me.blackvein.quests.util.Lang;
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
@ -107,8 +111,8 @@ public class PlayerListener implements Listener {
|
|||||||
ItemStack clicked = evt.getCurrentItem();
|
ItemStack clicked = evt.getCurrentItem();
|
||||||
if (clicked != null) {
|
if (clicked != null) {
|
||||||
for (Quest quest : plugin.quests) {
|
for (Quest quest : plugin.quests) {
|
||||||
if (quest.guiDisplay != null) {
|
if (quest.getGUIDisplay() != null) {
|
||||||
if (ItemUtil.compareItems(clicked, quest.guiDisplay, false) == 0) {
|
if (ItemUtil.compareItems(clicked, quest.getGUIDisplay(), false) == 0) {
|
||||||
if (quester.currentQuests.size() >= plugin.maxQuests && plugin.maxQuests > 0) {
|
if (quester.currentQuests.size() >= plugin.maxQuests && plugin.maxQuests > 0) {
|
||||||
String msg = Lang.get(player, "questMaxAllowed");
|
String msg = Lang.get(player, "questMaxAllowed");
|
||||||
msg = msg.replace("<number>", String.valueOf(plugin.maxQuests));
|
msg = msg.replace("<number>", String.valueOf(plugin.maxQuests));
|
||||||
@ -128,14 +132,14 @@ public class PlayerListener implements Listener {
|
|||||||
takeable = false;
|
takeable = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (quest.region != null) {
|
if (quest.getRegion() != null) {
|
||||||
boolean inRegion = false;
|
boolean inRegion = false;
|
||||||
Player p = quester.getPlayer();
|
Player p = quester.getPlayer();
|
||||||
RegionManager rm = Quests.worldGuard.getRegionManager(p.getWorld());
|
RegionManager rm = Quests.worldGuard.getRegionManager(p.getWorld());
|
||||||
Iterator<ProtectedRegion> it = rm.getApplicableRegions(p.getLocation()).iterator();
|
Iterator<ProtectedRegion> it = rm.getApplicableRegions(p.getLocation()).iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
ProtectedRegion pr = it.next();
|
ProtectedRegion pr = it.next();
|
||||||
if (pr.getId().equalsIgnoreCase(quest.region)) {
|
if (pr.getId().equalsIgnoreCase(quest.getRegion())) {
|
||||||
inRegion = true;
|
inRegion = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -252,8 +256,8 @@ public class PlayerListener implements Listener {
|
|||||||
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get(player, "questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
|
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get(player, "questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
|
||||||
} else if (player.isConversing() == false) {
|
} else if (player.isConversing() == false) {
|
||||||
for (final Quest q : plugin.quests) {
|
for (final Quest q : plugin.quests) {
|
||||||
if (q.blockStart != null) {
|
if (q.getBlockStart() != null) {
|
||||||
if (q.blockStart.equals(evt.getClickedBlock().getLocation())) {
|
if (q.getBlockStart().equals(evt.getClickedBlock().getLocation())) {
|
||||||
if (quester.currentQuests.size() >= plugin.maxQuests && plugin.maxQuests > 0) {
|
if (quester.currentQuests.size() >= plugin.maxQuests && plugin.maxQuests > 0) {
|
||||||
String msg = Lang.get(player, "questMaxAllowed");
|
String msg = Lang.get(player, "questMaxAllowed");
|
||||||
msg = msg.replace("<number>", String.valueOf(plugin.maxQuests));
|
msg = msg.replace("<number>", String.valueOf(plugin.maxQuests));
|
||||||
@ -274,7 +278,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
quester.questToTake = q.getName();
|
quester.questToTake = q.getName();
|
||||||
String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE + quester.questToTake + ChatColor.GOLD + " -\n" + "\n" + ChatColor.RESET + plugin.getQuest(quester.questToTake).description + "\n";
|
String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE + quester.questToTake + ChatColor.GOLD + " -\n" + "\n" + ChatColor.RESET + plugin.getQuest(quester.questToTake).getDescription() + "\n";
|
||||||
for (String msg : s.split("<br>")) {
|
for (String msg : s.split("<br>")) {
|
||||||
player.sendMessage(msg);
|
player.sendMessage(msg);
|
||||||
}
|
}
|
@ -57,11 +57,11 @@ public class EventFactory implements ConversationAbandonedListener {
|
|||||||
|
|
||||||
Quests quests;
|
Quests quests;
|
||||||
Map<UUID, Quest> editSessions = new HashMap<UUID, Quest>();
|
Map<UUID, Quest> editSessions = new HashMap<UUID, Quest>();
|
||||||
Map<UUID, Block> selectedExplosionLocations = new HashMap<UUID, Block>();
|
public Map<UUID, Block> selectedExplosionLocations = new HashMap<UUID, Block>();
|
||||||
Map<UUID, Block> selectedEffectLocations = new HashMap<UUID, Block>();
|
public Map<UUID, Block> selectedEffectLocations = new HashMap<UUID, Block>();
|
||||||
Map<UUID, Block> selectedMobLocations = new HashMap<UUID, Block>();
|
public Map<UUID, Block> selectedMobLocations = new HashMap<UUID, Block>();
|
||||||
Map<UUID, Block> selectedLightningLocations = new HashMap<UUID, Block>();
|
public Map<UUID, Block> selectedLightningLocations = new HashMap<UUID, Block>();
|
||||||
Map<UUID, Block> selectedTeleportLocations = new HashMap<UUID, Block>();
|
public Map<UUID, Block> selectedTeleportLocations = new HashMap<UUID, Block>();
|
||||||
List<String> names = new LinkedList<String>();
|
List<String> names = new LinkedList<String>();
|
||||||
ConversationFactory convoCreator;
|
ConversationFactory convoCreator;
|
||||||
File eventsFile;
|
File eventsFile;
|
||||||
|
@ -45,32 +45,17 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
|
|
||||||
public class Quest {
|
public class Quest {
|
||||||
|
|
||||||
public String name;
|
protected Quests plugin;
|
||||||
public String description;
|
private String name;
|
||||||
public String finished;
|
protected String description;
|
||||||
public String region = null;
|
protected String finished;
|
||||||
public ItemStack guiDisplay = null;
|
protected String region = null;
|
||||||
public int parties = 0;
|
protected ItemStack guiDisplay = null;
|
||||||
|
//private int parties = 0;
|
||||||
private LinkedList<Stage> orderedStages = new LinkedList<Stage>();
|
private LinkedList<Stage> orderedStages = new LinkedList<Stage>();
|
||||||
NPC npcStart;
|
protected NPC npcStart;
|
||||||
Location blockStart;
|
protected Location blockStart;
|
||||||
Quests plugin;
|
protected Event initialEvent;
|
||||||
Event initialEvent;
|
|
||||||
// Requirements
|
|
||||||
int moneyReq = 0;
|
|
||||||
int questPointsReq = 0;
|
|
||||||
List<ItemStack> items = new LinkedList<ItemStack>();
|
|
||||||
List<Boolean> removeItems = new LinkedList<Boolean>();
|
|
||||||
List<String> neededQuests = new LinkedList<String>();
|
|
||||||
List<String> blockQuests = new LinkedList<String>();
|
|
||||||
List<String> permissionReqs = new LinkedList<String>();
|
|
||||||
List<String> mcMMOSkillReqs = new LinkedList<String>();
|
|
||||||
List<Integer> mcMMOAmountReqs = new LinkedList<Integer>();
|
|
||||||
String heroesPrimaryClassReq = null;
|
|
||||||
String heroesSecondaryClassReq = null;
|
|
||||||
Map<String, Map<String, Object>> customRequirements = new HashMap<String, Map<String, Object>>();
|
|
||||||
Map<String, Map<String, Object>> customRewards = new HashMap<String, Map<String, Object>>();
|
|
||||||
public String failRequirements = null;
|
|
||||||
// Planner
|
// Planner
|
||||||
public String startPlanner = null;
|
public String startPlanner = null;
|
||||||
public String endPlanner = null;
|
public String endPlanner = null;
|
||||||
@ -88,6 +73,13 @@ public class Quest {
|
|||||||
List<String> heroesClasses = new LinkedList<String>();
|
List<String> heroesClasses = new LinkedList<String>();
|
||||||
List<Double> heroesAmounts = new LinkedList<Double>();
|
List<Double> heroesAmounts = new LinkedList<Double>();
|
||||||
List<String> phatLootRewards = new LinkedList<String>();
|
List<String> phatLootRewards = new LinkedList<String>();
|
||||||
|
Map<String, Map<String, Object>> customRewards = new HashMap<String, Map<String, Object>>();
|
||||||
|
|
||||||
|
private Requirements reqs = new Requirements();
|
||||||
|
|
||||||
|
public Requirements getRequirements() {
|
||||||
|
return reqs;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
@ -97,6 +89,38 @@ public class Quest {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFinished() {
|
||||||
|
return finished;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFinished(String finished) {
|
||||||
|
this.finished = finished;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRegion() {
|
||||||
|
return region;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegion(String region) {
|
||||||
|
this.region = region;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getGUIDisplay() {
|
||||||
|
return guiDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGUIDisplay(ItemStack guiDisplay) {
|
||||||
|
this.guiDisplay = guiDisplay;
|
||||||
|
}
|
||||||
|
|
||||||
public Stage getStage(int index) {
|
public Stage getStage(int index) {
|
||||||
try {
|
try {
|
||||||
return orderedStages.get(index);
|
return orderedStages.get(index);
|
||||||
@ -109,6 +133,35 @@ public class Quest {
|
|||||||
return orderedStages;
|
return orderedStages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NPC getNpcStart() {
|
||||||
|
return npcStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNpcStart(NPC npcStart) {
|
||||||
|
this.npcStart = npcStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getBlockStart() {
|
||||||
|
return blockStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockStart(Location blockStart) {
|
||||||
|
this.blockStart = blockStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Event getInitialEvent() {
|
||||||
|
return initialEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInitialEvent(Event initialEvent) {
|
||||||
|
this.initialEvent = initialEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force player to proceed to the next ordered stage
|
||||||
|
*
|
||||||
|
* @param q Player to force
|
||||||
|
*/
|
||||||
public void nextStage(Quester q) {
|
public void nextStage(Quester q) {
|
||||||
String stageCompleteMessage = q.getCurrentStage(this).completeMessage;
|
String stageCompleteMessage = q.getCurrentStage(this).completeMessage;
|
||||||
if (stageCompleteMessage != null) {
|
if (stageCompleteMessage != null) {
|
||||||
@ -152,6 +205,12 @@ public class Quest {
|
|||||||
q.updateJournal();
|
q.updateJournal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force player to proceed to the specified stage
|
||||||
|
* @param quester Player to force
|
||||||
|
* @param stage Stage number to specify
|
||||||
|
* @throws InvalidStageException if stage does not exist
|
||||||
|
*/
|
||||||
public void setStage(Quester quester, int stage) throws InvalidStageException {
|
public void setStage(Quester quester, int stage) throws InvalidStageException {
|
||||||
if (orderedStages.size() - 1 < stage) {
|
if (orderedStages.size() - 1 < stage) {
|
||||||
throw new InvalidStageException(this, stage);
|
throw new InvalidStageException(this, stage);
|
||||||
@ -253,16 +312,16 @@ public class Quest {
|
|||||||
return testRequirements(quester.getPlayer());
|
return testRequirements(quester.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean testRequirements(Player player) {
|
protected boolean testRequirements(Player player) {
|
||||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||||
if (moneyReq != 0 && Quests.economy != null) {
|
if (reqs.getMoney() != 0 && Quests.economy != null) {
|
||||||
if (Quests.economy.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId())) < moneyReq) {
|
if (Quests.economy.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId())) < reqs.getMoney()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayerInventory inventory = player.getInventory();
|
PlayerInventory inventory = player.getInventory();
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for (ItemStack is : items) {
|
for (ItemStack is : reqs.getItems()) {
|
||||||
for (ItemStack stack : inventory.getContents()) {
|
for (ItemStack stack : inventory.getContents()) {
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
if (ItemUtil.compareItems(is, stack, true) == 0) {
|
if (ItemUtil.compareItems(is, stack, true) == 0) {
|
||||||
@ -275,29 +334,29 @@ public class Quest {
|
|||||||
}
|
}
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
for (String s : permissionReqs) {
|
for (String s : reqs.getPermissions()) {
|
||||||
if (player.hasPermission(s) == false) {
|
if (player.hasPermission(s) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String s : mcMMOSkillReqs) {
|
for (String s : reqs.getMcmmoSkills()) {
|
||||||
final SkillType st = Quests.getMcMMOSkill(s);
|
final SkillType st = Quests.getMcMMOSkill(s);
|
||||||
final int lvl = mcMMOAmountReqs.get(mcMMOSkillReqs.indexOf(s));
|
final int lvl = reqs.getMcmmoAmounts().get(reqs.getMcmmoSkills().indexOf(s));
|
||||||
if (UserManager.getPlayer(player).getProfile().getSkillLevel(st) < lvl) {
|
if (UserManager.getPlayer(player).getProfile().getSkillLevel(st) < lvl) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (heroesPrimaryClassReq != null) {
|
if (reqs.getHeroesPrimaryClass() != null) {
|
||||||
if (plugin.testPrimaryHeroesClass(heroesPrimaryClassReq, player.getUniqueId()) == false) {
|
if (plugin.testPrimaryHeroesClass(reqs.getHeroesPrimaryClass(), player.getUniqueId()) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (heroesSecondaryClassReq != null) {
|
if (reqs.getHeroesSecondaryClass() != null) {
|
||||||
if (plugin.testSecondaryHeroesClass(heroesSecondaryClassReq, player.getUniqueId()) == false) {
|
if (plugin.testSecondaryHeroesClass(reqs.getHeroesSecondaryClass(), player.getUniqueId()) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String s : customRequirements.keySet()) {
|
for (String s : reqs.getCustomRequirements().keySet()) {
|
||||||
CustomRequirement found = null;
|
CustomRequirement found = null;
|
||||||
for (CustomRequirement cr : plugin.customRequirements) {
|
for (CustomRequirement cr : plugin.customRequirements) {
|
||||||
if (cr.getName().equalsIgnoreCase(s)) {
|
if (cr.getName().equalsIgnoreCase(s)) {
|
||||||
@ -306,7 +365,7 @@ public class Quest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
if (found.testRequirement(player, customRequirements.get(s)) == false) {
|
if (found.testRequirement(player, reqs.getCustomRequirements().get(s)) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -314,13 +373,13 @@ public class Quest {
|
|||||||
+ "\" could not be found. Does it still exist?");
|
+ "\" could not be found. Does it still exist?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (quester.questPoints < questPointsReq) {
|
if (quester.questPoints < reqs.getQuestPoints()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (quester.completedQuests.containsAll(neededQuests) == false) {
|
if (quester.completedQuests.containsAll(reqs.getNeededQuests()) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (String q : blockQuests) {
|
for (String q : reqs.getBlockQuests()) {
|
||||||
Quest questObject = new Quest();
|
Quest questObject = new Quest();
|
||||||
questObject.name = q;
|
questObject.name = q;
|
||||||
if (quester.completedQuests.contains(q) || quester.currentQuests.containsKey(questObject)) {
|
if (quester.completedQuests.contains(q) || quester.currentQuests.containsKey(questObject)) {
|
||||||
@ -613,7 +672,11 @@ public class Quest {
|
|||||||
q.updateJournal();
|
q.updateJournal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInRegion(Player player) {
|
public boolean isInRegion(Quester quester) {
|
||||||
|
return isInRegion(quester.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isInRegion(Player player) {
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -60,7 +60,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
|
|
||||||
public final Quests plugin;
|
public final Quests plugin;
|
||||||
Map<UUID, Quest> editSessions = new HashMap<UUID, Quest>();
|
Map<UUID, Quest> editSessions = new HashMap<UUID, Quest>();
|
||||||
Map<UUID, Block> selectedBlockStarts = new HashMap<UUID, Block>();
|
public Map<UUID, Block> selectedBlockStarts = new HashMap<UUID, Block>();
|
||||||
public Map<UUID, Block> selectedKillLocations = new HashMap<UUID, Block>();
|
public Map<UUID, Block> selectedKillLocations = new HashMap<UUID, Block>();
|
||||||
public Map<UUID, Block> selectedReachLocations = new HashMap<UUID, Block>();
|
public Map<UUID, Block> selectedReachLocations = new HashMap<UUID, Block>();
|
||||||
public HashSet<Player> selectingNPCs = new HashSet<Player>();
|
public HashSet<Player> selectingNPCs = new HashSet<Player>();
|
||||||
@ -1313,46 +1313,43 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
cc.setSessionData(CK.Q_GUIDISPLAY, q.guiDisplay);
|
cc.setSessionData(CK.Q_GUIDISPLAY, q.guiDisplay);
|
||||||
}
|
}
|
||||||
// Requirements
|
// Requirements
|
||||||
if (q.moneyReq != 0) {
|
Requirements reqs = q.getRequirements();
|
||||||
cc.setSessionData(CK.REQ_MONEY, q.moneyReq);
|
if (reqs.getMoney() != 0) {
|
||||||
|
cc.setSessionData(CK.REQ_MONEY, reqs.getMoney());
|
||||||
}
|
}
|
||||||
if (q.questPointsReq != 0) {
|
if (reqs.getQuestPoints() != 0) {
|
||||||
cc.setSessionData(CK.REQ_QUEST_POINTS, q.questPointsReq);
|
cc.setSessionData(CK.REQ_QUEST_POINTS, reqs.getQuestPoints());
|
||||||
}
|
}
|
||||||
if (q.items.isEmpty() == false) {
|
if (reqs.getItems().isEmpty() == false) {
|
||||||
cc.setSessionData(CK.REQ_ITEMS, q.items);
|
cc.setSessionData(CK.REQ_ITEMS, reqs.getItems());
|
||||||
cc.setSessionData(CK.REQ_ITEMS_REMOVE, q.removeItems);
|
cc.setSessionData(CK.REQ_ITEMS_REMOVE, reqs.getRemoveItems());
|
||||||
}
|
}
|
||||||
if (q.neededQuests.isEmpty() == false) {
|
if (reqs.getNeededQuests().isEmpty() == false) {
|
||||||
cc.setSessionData(CK.REQ_QUEST, q.neededQuests);
|
cc.setSessionData(CK.REQ_QUEST, reqs.getNeededQuests());
|
||||||
}
|
}
|
||||||
if (q.blockQuests.isEmpty() == false) {
|
if (reqs.getBlockQuests().isEmpty() == false) {
|
||||||
cc.setSessionData(CK.REQ_QUEST_BLOCK, q.blockQuests);
|
cc.setSessionData(CK.REQ_QUEST_BLOCK, reqs.getBlockQuests());
|
||||||
}
|
}
|
||||||
if (q.mcMMOSkillReqs.isEmpty() == false) {
|
if (reqs.getMcmmoSkills().isEmpty() == false) {
|
||||||
cc.setSessionData(CK.REQ_MCMMO_SKILLS, q.mcMMOSkillReqs);
|
cc.setSessionData(CK.REQ_MCMMO_SKILLS, reqs.getMcmmoAmounts());
|
||||||
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, q.mcMMOAmountReqs);
|
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, reqs.getMcmmoAmounts());
|
||||||
}
|
}
|
||||||
if (q.permissionReqs.isEmpty() == false) {
|
if (reqs.getPermissions().isEmpty() == false) {
|
||||||
cc.setSessionData(CK.REQ_PERMISSION, q.permissionReqs);
|
cc.setSessionData(CK.REQ_PERMISSION, reqs.getPermissions());
|
||||||
}
|
}
|
||||||
if (q.heroesPrimaryClassReq != null) {
|
if (reqs.getHeroesPrimaryClass() != null) {
|
||||||
cc.setSessionData(CK.REQ_HEROES_PRIMARY_CLASS, q.heroesPrimaryClassReq);
|
cc.setSessionData(CK.REQ_HEROES_PRIMARY_CLASS, reqs.getHeroesPrimaryClass());
|
||||||
}
|
}
|
||||||
if (q.heroesSecondaryClassReq != null) {
|
if (reqs.getHeroesSecondaryClass() != null) {
|
||||||
cc.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, q.heroesSecondaryClassReq);
|
cc.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, reqs.getHeroesSecondaryClass());
|
||||||
}
|
}
|
||||||
if (q.mcMMOSkillReqs.isEmpty() == false) {
|
if (reqs.getFailRequirements() != null) {
|
||||||
cc.setSessionData(CK.REQ_MCMMO_SKILLS, q.mcMMOSkillReqs);
|
cc.setSessionData(CK.Q_FAIL_MESSAGE, reqs.getFailRequirements());
|
||||||
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, q.mcMMOAmountReqs);
|
|
||||||
}
|
}
|
||||||
if (q.failRequirements != null) {
|
if (reqs.getCustomRequirements().isEmpty() == false) {
|
||||||
cc.setSessionData(CK.Q_FAIL_MESSAGE, q.failRequirements);
|
|
||||||
}
|
|
||||||
if (q.customRequirements.isEmpty() == false) {
|
|
||||||
LinkedList<String> list = new LinkedList<String>();
|
LinkedList<String> list = new LinkedList<String>();
|
||||||
LinkedList<Map<String, Object>> datamapList = new LinkedList<Map<String, Object>>();
|
LinkedList<Map<String, Object>> datamapList = new LinkedList<Map<String, Object>>();
|
||||||
for (Entry<String, Map<String, Object>> entry : q.customRequirements.entrySet()) {
|
for (Entry<String, Map<String, Object>> entry : reqs.getCustomRequirements().entrySet()) {
|
||||||
list.add(entry.getKey());
|
list.add(entry.getKey());
|
||||||
datamapList.add(entry.getValue());
|
datamapList.add(entry.getValue());
|
||||||
}
|
}
|
||||||
@ -1505,13 +1502,13 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
cc.setSessionData(pref + CK.S_ENCHANT_NAMES, names);
|
cc.setSessionData(pref + CK.S_ENCHANT_NAMES, names);
|
||||||
cc.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, amounts);
|
cc.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, amounts);
|
||||||
}
|
}
|
||||||
if (stage.itemsToDeliver.isEmpty() == false) {
|
if (stage.getItemsToDeliver().isEmpty() == false) {
|
||||||
LinkedList<ItemStack> items = new LinkedList<ItemStack>();
|
LinkedList<ItemStack> items = new LinkedList<ItemStack>();
|
||||||
LinkedList<Integer> npcs = new LinkedList<Integer>();
|
LinkedList<Integer> npcs = new LinkedList<Integer>();
|
||||||
for (ItemStack is : stage.itemsToDeliver) {
|
for (ItemStack is : stage.getItemsToDeliver()) {
|
||||||
items.add(is);
|
items.add(is);
|
||||||
}
|
}
|
||||||
for (Integer n : stage.itemDeliveryTargets) {
|
for (Integer n : stage.getItemDeliveryTargets()) {
|
||||||
npcs.add(n);
|
npcs.add(n);
|
||||||
}
|
}
|
||||||
cc.setSessionData(pref + CK.S_DELIVERY_ITEMS, items);
|
cc.setSessionData(pref + CK.S_DELIVERY_ITEMS, items);
|
||||||
@ -1669,7 +1666,7 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
Quest found = plugin.findQuest(input);
|
Quest found = plugin.findQuest(input);
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
for (Quest q : plugin.quests) {
|
for (Quest q : plugin.quests) {
|
||||||
if (q.neededQuests.contains(q.getName()) || q.blockQuests.contains(q.getName())) {
|
if (q.getRequirements().getNeededQuests().contains(q.getName()) || q.getRequirements().getBlockQuests().contains(q.getName())) {
|
||||||
used.add(q.getName());
|
used.add(q.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,9 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
|
|
||||||
public class Quester {
|
public class Quester {
|
||||||
|
|
||||||
UUID id;
|
public UUID id;
|
||||||
boolean editorMode = false;
|
boolean editorMode = false;
|
||||||
boolean hasJournal = false;
|
public boolean hasJournal = false;
|
||||||
public String questToTake;
|
public String questToTake;
|
||||||
public ConcurrentHashMap<Integer, Quest> timers = new ConcurrentHashMap<Integer, Quest>();
|
public ConcurrentHashMap<Integer, Quest> timers = new ConcurrentHashMap<Integer, Quest>();
|
||||||
public ConcurrentHashMap<Quest, Integer> currentQuests = new ConcurrentHashMap<Quest, Integer>() {
|
public ConcurrentHashMap<Quest, Integer> currentQuests = new ConcurrentHashMap<Quest, Integer>() {
|
||||||
@ -150,7 +150,7 @@ public class Quester {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Map<String, Long> completedTimes = new HashMap<String, Long>();
|
public Map<String, Long> completedTimes = new HashMap<String, Long>();
|
||||||
Map<String, Integer> amountsCompleted = new HashMap<String, Integer>() {
|
Map<String, Integer> amountsCompleted = new HashMap<String, Integer>() {
|
||||||
|
|
||||||
private static final long serialVersionUID = 5475202358792520975L;
|
private static final long serialVersionUID = 5475202358792520975L;
|
||||||
@ -391,14 +391,15 @@ public class Quester {
|
|||||||
+ ". Consider resetting player data or report on Github");
|
+ ". Consider resetting player data or report on Github");
|
||||||
}
|
}
|
||||||
Stage stage = q.getStage(0);
|
Stage stage = q.getStage(0);
|
||||||
|
Requirements reqs = q.getRequirements();
|
||||||
if (!override) {
|
if (!override) {
|
||||||
if (q.moneyReq > 0) {
|
if (reqs.getMoney() > 0) {
|
||||||
if (Quests.economy != null) {
|
if (Quests.economy != null) {
|
||||||
Quests.economy.withdrawPlayer(getOfflinePlayer(), q.moneyReq);
|
Quests.economy.withdrawPlayer(getOfflinePlayer(), reqs.getMoney());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ItemStack is : q.items) {
|
for (ItemStack is : reqs.getItems()) {
|
||||||
if (q.removeItems.get(q.items.indexOf(is)) == true) {
|
if (reqs.getRemoveItems().get(reqs.getItems().indexOf(is)) == true) {
|
||||||
Quests.removeItem(player.getInventory(), is);
|
Quests.removeItem(player.getInventory(), is);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,7 +442,7 @@ public class Quester {
|
|||||||
q.updateGPS(this);
|
q.updateGPS(this);
|
||||||
saveData();
|
saveData();
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(q.failRequirements);
|
player.sendMessage(q.getRequirements().getFailRequirements());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,13 +609,13 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int index2 = 0;
|
int index2 = 0;
|
||||||
for (ItemStack is : getCurrentStage(quest).itemsToDeliver) {
|
for (ItemStack is : getCurrentStage(quest).getItemsToDeliver()) {
|
||||||
int delivered = 0;
|
int delivered = 0;
|
||||||
if (getQuestData(quest).itemsDelivered.containsKey(is)) {
|
if (getQuestData(quest).itemsDelivered.containsKey(is)) {
|
||||||
delivered = getQuestData(quest).itemsDelivered.get(is);
|
delivered = getQuestData(quest).itemsDelivered.get(is);
|
||||||
}
|
}
|
||||||
int amt = is.getAmount();
|
int amt = is.getAmount();
|
||||||
Integer npc = getCurrentStage(quest).itemDeliveryTargets.get(index2);
|
Integer npc = getCurrentStage(quest).getItemDeliveryTargets().get(index2);
|
||||||
index2++;
|
index2++;
|
||||||
if (delivered < amt) {
|
if (delivered < amt) {
|
||||||
String obj = Lang.get(getPlayer(), "deliver");
|
String obj = Lang.get(getPlayer(), "deliver");
|
||||||
@ -791,7 +792,7 @@ public class Quester {
|
|||||||
} else if (s.equalsIgnoreCase("killMob")) {
|
} else if (s.equalsIgnoreCase("killMob")) {
|
||||||
return !getCurrentStage(quest).mobsToKill.isEmpty();
|
return !getCurrentStage(quest).mobsToKill.isEmpty();
|
||||||
} else if (s.equalsIgnoreCase("deliverItem")) {
|
} else if (s.equalsIgnoreCase("deliverItem")) {
|
||||||
return !getCurrentStage(quest).itemsToDeliver.isEmpty();
|
return !getCurrentStage(quest).getItemsToDeliver().isEmpty();
|
||||||
} else if (s.equalsIgnoreCase("killPlayer")) {
|
} else if (s.equalsIgnoreCase("killPlayer")) {
|
||||||
return getCurrentStage(quest).playersToKill != null;
|
return getCurrentStage(quest).playersToKill != null;
|
||||||
} else if (s.equalsIgnoreCase("talkToNPC")) {
|
} else if (s.equalsIgnoreCase("talkToNPC")) {
|
||||||
@ -1244,14 +1245,14 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
int amount = getQuestData(quest).itemsDelivered.get(found);
|
int amount = getQuestData(quest).itemsDelivered.get(found);
|
||||||
if (getCurrentStage(quest).itemsToDeliver.indexOf(found) < 0) {
|
if (getCurrentStage(quest).getItemsToDeliver().indexOf(found) < 0) {
|
||||||
plugin.getLogger().severe("Index out of bounds while delivering " + found.getType() + " x " + found.getAmount() + " for quest "
|
plugin.getLogger().severe("Index out of bounds while delivering " + found.getType() + " x " + found.getAmount() + " for quest "
|
||||||
+ quest.getName() + " with " + i.getType() + " x " + i.getAmount() + " already delivered. Int -amount- reports value of " +
|
+ quest.getName() + " with " + i.getType() + " x " + i.getAmount() + " already delivered. Int -amount- reports value of " +
|
||||||
+ amount + ". Please report this error on Github issue #448");
|
+ amount + ". Please report this error on Github issue #448");
|
||||||
player.sendMessage("Quests had a problem delivering your item, please contact an administrator!");
|
player.sendMessage("Quests had a problem delivering your item, please contact an administrator!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int req = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(found)).getAmount();
|
int req = getCurrentStage(quest).getItemsToDeliver().get(getCurrentStage(quest).getItemsToDeliver().indexOf(found)).getAmount();
|
||||||
Material m = i.getType();
|
Material m = i.getType();
|
||||||
if (amount < req) {
|
if (amount < req) {
|
||||||
if ((i.getAmount() + amount) > req) {
|
if ((i.getAmount() + amount) > req) {
|
||||||
@ -1270,7 +1271,7 @@ public class Quester {
|
|||||||
getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount()));
|
getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount()));
|
||||||
player.getInventory().setItem(player.getInventory().first(i), null);
|
player.getInventory().setItem(player.getInventory().first(i), null);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
String message = Quests.parseString(getCurrentStage(quest).deliverMessages.get(random.nextInt(getCurrentStage(quest).deliverMessages.size())), Quests.citizens.getNPCRegistry().getById(getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(found))));
|
String message = Quests.parseString(getCurrentStage(quest).deliverMessages.get(random.nextInt(getCurrentStage(quest).deliverMessages.size())), Quests.citizens.getNPCRegistry().getById(getCurrentStage(quest).getItemDeliveryTargets().get(getCurrentStage(quest).getItemsToDeliver().indexOf(found))));
|
||||||
player.sendMessage(message);
|
player.sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1409,9 +1410,9 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
} else if (objective.equalsIgnoreCase("deliverItem")) {
|
} else if (objective.equalsIgnoreCase("deliverItem")) {
|
||||||
String obj = Lang.get(p, "deliver");
|
String obj = Lang.get(p, "deliver");
|
||||||
obj = obj.replace("<npc>", plugin.getNPCName(getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(delivery))));
|
obj = obj.replace("<npc>", plugin.getNPCName(getCurrentStage(quest).getItemDeliveryTargets().get(getCurrentStage(quest).getItemsToDeliver().indexOf(delivery))));
|
||||||
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj;
|
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj;
|
||||||
ItemStack is = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(delivery));
|
ItemStack is = getCurrentStage(quest).getItemsToDeliver().get(getCurrentStage(quest).getItemsToDeliver().indexOf(delivery));
|
||||||
plugin.query.sendMessage(p, message, is.getType(), is.getDurability());
|
plugin.query.sendMessage(p, message, is.getType(), is.getDurability());
|
||||||
if (testComplete(quest)) {
|
if (testComplete(quest)) {
|
||||||
quest.nextStage(this);
|
quest.nextStage(this);
|
||||||
@ -1586,8 +1587,8 @@ public class Quester {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.setPlayersKilled(0);
|
data.setPlayersKilled(0);
|
||||||
if (quest.getStage(stage).itemsToDeliver.isEmpty() == false) {
|
if (quest.getStage(stage).getItemsToDeliver().isEmpty() == false) {
|
||||||
for (ItemStack is : quest.getStage(stage).itemsToDeliver) {
|
for (ItemStack is : quest.getStage(stage).getItemsToDeliver()) {
|
||||||
data.itemsDelivered.put(is, 0);
|
data.itemsDelivered.put(is, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2289,8 +2290,8 @@ public class Quester {
|
|||||||
if (questSec.contains("item-delivery-amounts")) {
|
if (questSec.contains("item-delivery-amounts")) {
|
||||||
List<Integer> deliveryAmounts = questSec.getIntegerList("item-delivery-amounts");
|
List<Integer> deliveryAmounts = questSec.getIntegerList("item-delivery-amounts");
|
||||||
for (int i = 0; i < deliveryAmounts.size(); i++) {
|
for (int i = 0; i < deliveryAmounts.size(); i++) {
|
||||||
if (i < getCurrentStage(quest).itemsToDeliver.size()) {
|
if (i < getCurrentStage(quest).getItemsToDeliver().size()) {
|
||||||
getQuestData(quest).itemsDelivered.put(getCurrentStage(quest).itemsToDeliver.get(i), deliveryAmounts.get(i));
|
getQuestData(quest).itemsDelivered.put(getCurrentStage(quest).getItemsToDeliver().get(i), deliveryAmounts.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,8 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
|||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
|
import me.blackvein.listeners.NpcListener;
|
||||||
|
import me.blackvein.listeners.PlayerListener;
|
||||||
import me.blackvein.quests.exceptions.InvalidStageException;
|
import me.blackvein.quests.exceptions.InvalidStageException;
|
||||||
import me.blackvein.quests.prompts.QuestAcceptPrompt;
|
import me.blackvein.quests.prompts.QuestAcceptPrompt;
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
@ -1795,8 +1797,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
cs.sendMessage(" ");
|
cs.sendMessage(" ");
|
||||||
if (showQuestReqs == true) {
|
if (showQuestReqs == true) {
|
||||||
cs.sendMessage(ChatColor.GOLD + Lang.get("requirements"));
|
cs.sendMessage(ChatColor.GOLD + Lang.get("requirements"));
|
||||||
if (q.permissionReqs.isEmpty() == false) {
|
Requirements reqs = q.getRequirements();
|
||||||
for (String perm : q.permissionReqs) {
|
if (reqs.getPermissions().isEmpty() == false) {
|
||||||
|
for (String perm : reqs.getPermissions()) {
|
||||||
if (permission.has(player, perm)) {
|
if (permission.has(player, perm)) {
|
||||||
cs.sendMessage(ChatColor.GREEN + Lang.get("permissionDisplay") + " " + perm);
|
cs.sendMessage(ChatColor.GREEN + Lang.get("permissionDisplay") + " " + perm);
|
||||||
} else {
|
} else {
|
||||||
@ -1804,24 +1807,24 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (q.heroesPrimaryClassReq != null) {
|
if (reqs.getHeroesPrimaryClass() != null) {
|
||||||
if (this.testPrimaryHeroesClass(q.heroesPrimaryClassReq, player.getUniqueId())) {
|
if (this.testPrimaryHeroesClass(reqs.getHeroesPrimaryClass(), player.getUniqueId())) {
|
||||||
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + q.heroesPrimaryClassReq + ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + Lang.get("heroesClass"));
|
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + reqs.getHeroesPrimaryClass() + ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + Lang.get("heroesClass"));
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + q.heroesPrimaryClassReq + ChatColor.RESET + "" + ChatColor.RED + " " + Lang.get("heroesClass"));
|
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + reqs.getHeroesPrimaryClass() + ChatColor.RESET + "" + ChatColor.RED + " " + Lang.get("heroesClass"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (q.heroesSecondaryClassReq != null) {
|
if (reqs.getHeroesSecondaryClass() != null) {
|
||||||
if (this.testSecondaryHeroesClass(q.heroesSecondaryClassReq, player.getUniqueId())) {
|
if (this.testSecondaryHeroesClass(reqs.getHeroesSecondaryClass(), player.getUniqueId())) {
|
||||||
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + q.heroesSecondaryClassReq + ChatColor.RESET + "" + ChatColor.RED + " " + Lang.get("heroesClass"));
|
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + reqs.getHeroesSecondaryClass() + ChatColor.RESET + "" + ChatColor.RED + " " + Lang.get("heroesClass"));
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + q.heroesSecondaryClassReq + ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + Lang.get("heroesClass"));
|
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + reqs.getHeroesSecondaryClass() + ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + Lang.get("heroesClass"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (q.mcMMOSkillReqs.isEmpty() == false) {
|
if (reqs.getMcmmoSkills().isEmpty() == false) {
|
||||||
for (String skill : q.mcMMOSkillReqs) {
|
for (String skill : reqs.getMcmmoSkills()) {
|
||||||
int level = Quests.getMCMMOSkillLevel(Quests.getMcMMOSkill(skill), player.getName());
|
int level = Quests.getMCMMOSkillLevel(Quests.getMcMMOSkill(skill), player.getName());
|
||||||
int req = q.mcMMOAmountReqs.get(q.mcMMOSkillReqs.indexOf(skill));
|
int req = reqs.getMcmmoAmounts().get(reqs.getMcmmoSkills().indexOf(skill));
|
||||||
String skillName = MiscUtil.getCapitalized(skill);
|
String skillName = MiscUtil.getCapitalized(skill);
|
||||||
if (level >= req) {
|
if (level >= req) {
|
||||||
cs.sendMessage(ChatColor.GREEN + skillName + " " + Lang.get("mcMMOLevel") + " " + req);
|
cs.sendMessage(ChatColor.GREEN + skillName + " " + Lang.get("mcMMOLevel") + " " + req);
|
||||||
@ -1830,30 +1833,30 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (q.questPointsReq != 0) {
|
if (reqs.getQuestPoints() != 0) {
|
||||||
if (quester.questPoints >= q.questPointsReq) {
|
if (quester.questPoints >= reqs.getQuestPoints()) {
|
||||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + q.questPointsReq + " " + Lang.get("questPoints"));
|
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getQuestPoints() + " " + Lang.get("questPoints"));
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + q.questPointsReq + " " + Lang.get("questPoints"));
|
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getQuestPoints() + " " + Lang.get("questPoints"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (q.moneyReq != 0) {
|
if (reqs.getMoney() != 0) {
|
||||||
if (economy != null && economy.getBalance(quester.getOfflinePlayer()) >= q.moneyReq) {
|
if (economy != null && economy.getBalance(quester.getOfflinePlayer()) >= reqs.getMoney()) {
|
||||||
if (q.moneyReq == 1) {
|
if (reqs.getMoney() == 1) {
|
||||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + q.moneyReq + " " + Quests.getCurrency(false));
|
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " " + Quests.getCurrency(false));
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + q.moneyReq + " " + Quests.getCurrency(true));
|
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " " + Quests.getCurrency(true));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (q.moneyReq == 1) {
|
if (reqs.getMoney() == 1) {
|
||||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + q.moneyReq + " " + Quests.getCurrency(false));
|
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " " + Quests.getCurrency(false));
|
||||||
} else {
|
} else {
|
||||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + q.moneyReq + " " + Quests.getCurrency(true));
|
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " " + Quests.getCurrency(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (q.items.isEmpty() == false) {
|
if (reqs.getItems().isEmpty() == false) {
|
||||||
for (ItemStack is : q.items) {
|
for (ItemStack is : reqs.getItems()) {
|
||||||
if (hasItem(player, is) == true) {
|
if (hasItem(player, is) == true) {
|
||||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + ItemUtil.getString(is));
|
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + ItemUtil.getString(is));
|
||||||
} else {
|
} else {
|
||||||
@ -1861,8 +1864,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (q.neededQuests.isEmpty() == false) {
|
if (reqs.getNeededQuests().isEmpty() == false) {
|
||||||
for (String s : q.neededQuests) {
|
for (String s : reqs.getNeededQuests()) {
|
||||||
if (quester.completedQuests.contains(s)) {
|
if (quester.completedQuests.contains(s)) {
|
||||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + Lang.get("complete") + " " + ChatColor.ITALIC + s);
|
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + Lang.get("complete") + " " + ChatColor.ITALIC + s);
|
||||||
} else {
|
} else {
|
||||||
@ -1870,8 +1873,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (q.blockQuests.isEmpty() == false) {
|
if (reqs.getBlockQuests().isEmpty() == false) {
|
||||||
for (String s : q.blockQuests) {
|
for (String s : reqs.getBlockQuests()) {
|
||||||
if (quester.completedQuests.contains(s)) {
|
if (quester.completedQuests.contains(s)) {
|
||||||
String msg = Lang.get("haveCompleted");
|
String msg = Lang.get("haveCompleted");
|
||||||
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE + s + ChatColor.RED);
|
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE + s + ChatColor.RED);
|
||||||
@ -1961,7 +1964,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
//TODO find a better way to detect a deliver objective
|
//TODO find a better way to detect a deliver objective
|
||||||
else if (obj.contains(Lang.get(quester.getPlayer(), "deliver").split(" ")[0])) {
|
else if (obj.contains(Lang.get(quester.getPlayer(), "deliver").split(" ")[0])) {
|
||||||
for (ItemStack is : stage.itemsToDeliver) {
|
for (ItemStack is : stage.getItemsToDeliver()) {
|
||||||
if (Material.matchMaterial(serial) != null) {
|
if (Material.matchMaterial(serial) != null) {
|
||||||
if (Material.matchMaterial(serial).equals(is.getType())) {
|
if (Material.matchMaterial(serial).equals(is.getType())) {
|
||||||
String enchant = "";
|
String enchant = "";
|
||||||
@ -2472,8 +2475,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadQuestRequirements(FileConfiguration config, ConfigurationSection questsSection) throws SkipQuest {
|
private void loadQuestRequirements(FileConfiguration config, ConfigurationSection questsSection) throws SkipQuest {
|
||||||
|
Requirements reqs = quest.getRequirements();
|
||||||
if (config.contains("quests." + questName + ".requirements.fail-requirement-message")) {
|
if (config.contains("quests." + questName + ".requirements.fail-requirement-message")) {
|
||||||
quest.failRequirements = parseString(config.getString("quests." + questName + ".requirements.fail-requirement-message"), quest);
|
reqs.setFailRequirements(parseString(config.getString("quests." + questName + ".requirements.fail-requirement-message"), quest));
|
||||||
} else {
|
} else {
|
||||||
skipQuestProcess("Requirements for Quest " + quest.getName() + " is missing fail-requirement-message:");
|
skipQuestProcess("Requirements for Quest " + quest.getName() + " is missing fail-requirement-message:");
|
||||||
}
|
}
|
||||||
@ -2481,15 +2485,17 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (Quests.checkList(config.getList("quests." + questName + ".requirements.items"), String.class)) {
|
if (Quests.checkList(config.getList("quests." + questName + ".requirements.items"), String.class)) {
|
||||||
List<String> itemReqs = config.getStringList("quests." + questName + ".requirements.items");
|
List<String> itemReqs = config.getStringList("quests." + questName + ".requirements.items");
|
||||||
boolean failed = false;
|
boolean failed = false;
|
||||||
|
List<ItemStack> temp = reqs.getItems();
|
||||||
for (String item : itemReqs) {
|
for (String item : itemReqs) {
|
||||||
ItemStack stack = ItemUtil.readItemStack(item);
|
ItemStack stack = ItemUtil.readItemStack(item);
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
quest.items.add(stack);
|
temp.add(stack);
|
||||||
} else {
|
} else {
|
||||||
failed = true;
|
failed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
reqs.setItems(temp);
|
||||||
if (failed == true) {
|
if (failed == true) {
|
||||||
skipQuestProcess("items: Requirement for Quest " + quest.getName() + " is not formatted correctly!");
|
skipQuestProcess("items: Requirement for Quest " + quest.getName() + " is not formatted correctly!");
|
||||||
}
|
}
|
||||||
@ -2498,8 +2504,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
if (config.contains("quests." + questName + ".requirements.remove-items")) {
|
if (config.contains("quests." + questName + ".requirements.remove-items")) {
|
||||||
if (Quests.checkList(config.getList("quests." + questName + ".requirements.remove-items"), Boolean.class)) {
|
if (Quests.checkList(config.getList("quests." + questName + ".requirements.remove-items"), Boolean.class)) {
|
||||||
quest.removeItems.clear();
|
reqs.setRemoveItems(config.getBooleanList("quests." + questName + ".requirements.remove-items"));
|
||||||
quest.removeItems.addAll(config.getBooleanList("quests." + questName + ".requirements.remove-items"));
|
|
||||||
} else {
|
} else {
|
||||||
skipQuestProcess("remove-items: Requirement for Quest " + quest.getName() + " is not a list of true/false values!");
|
skipQuestProcess("remove-items: Requirement for Quest " + quest.getName() + " is not a list of true/false values!");
|
||||||
}
|
}
|
||||||
@ -2509,14 +2514,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
if (config.contains("quests." + questName + ".requirements.money")) {
|
if (config.contains("quests." + questName + ".requirements.money")) {
|
||||||
if (config.getInt("quests." + questName + ".requirements.money", -999) != -999) {
|
if (config.getInt("quests." + questName + ".requirements.money", -999) != -999) {
|
||||||
quest.moneyReq = config.getInt("quests." + questName + ".requirements.money");
|
reqs.setMoney(config.getInt("quests." + questName + ".requirements.money"));
|
||||||
} else {
|
} else {
|
||||||
skipQuestProcess("money: Requirement for Quest " + quest.getName() + " is not a number!");
|
skipQuestProcess("money: Requirement for Quest " + quest.getName() + " is not a number!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.contains("quests." + questName + ".requirements.quest-points")) {
|
if (config.contains("quests." + questName + ".requirements.quest-points")) {
|
||||||
if (config.getInt("quests." + questName + ".requirements.quest-points", -999) != -999) {
|
if (config.getInt("quests." + questName + ".requirements.quest-points", -999) != -999) {
|
||||||
quest.questPointsReq = config.getInt("quests." + questName + ".requirements.quest-points");
|
reqs.setQuestPoints(config.getInt("quests." + questName + ".requirements.quest-points"));
|
||||||
} else {
|
} else {
|
||||||
skipQuestProcess("quest-points: Requirement for Quest " + quest.getName() + " is not a number!");
|
skipQuestProcess("quest-points: Requirement for Quest " + quest.getName() + " is not a number!");
|
||||||
}
|
}
|
||||||
@ -2526,11 +2531,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
List<String> names = config.getStringList("quests." + questName + ".requirements.quest-blocks");
|
List<String> names = config.getStringList("quests." + questName + ".requirements.quest-blocks");
|
||||||
boolean failed = false;
|
boolean failed = false;
|
||||||
String failedQuest = "NULL";
|
String failedQuest = "NULL";
|
||||||
|
List<String> temp = new LinkedList<String>();
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
for (String string : questsSection.getKeys(false)) {
|
for (String string : questsSection.getKeys(false)) {
|
||||||
if (config.getString("quests." + string + ".name").equalsIgnoreCase(name)) {
|
if (config.getString("quests." + string + ".name").equalsIgnoreCase(name)) {
|
||||||
quest.blockQuests.add(name);
|
temp.add(name);
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2541,6 +2547,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
reqs.setNeededQuests(temp);
|
||||||
if (failed) {
|
if (failed) {
|
||||||
skipQuestProcess(new String[] { "" + ChatColor.LIGHT_PURPLE + failedQuest + " inside quests: Requirement for Quest "
|
skipQuestProcess(new String[] { "" + ChatColor.LIGHT_PURPLE + failedQuest + " inside quests: Requirement for Quest "
|
||||||
+ quest.getName() + " is not a valid Quest name!", "Make sure you aren\'t using the config section identifier." });
|
+ quest.getName() + " is not a valid Quest name!", "Make sure you aren\'t using the config section identifier." });
|
||||||
@ -2554,11 +2561,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
List<String> names = config.getStringList("quests." + questName + ".requirements.quests");
|
List<String> names = config.getStringList("quests." + questName + ".requirements.quests");
|
||||||
boolean failed = false;
|
boolean failed = false;
|
||||||
String failedQuest = "NULL";
|
String failedQuest = "NULL";
|
||||||
|
List<String> temp = new LinkedList<String>();
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
for (String string : questsSection.getKeys(false)) {
|
for (String string : questsSection.getKeys(false)) {
|
||||||
if (config.getString("quests." + string + ".name").equalsIgnoreCase(name)) {
|
if (config.getString("quests." + string + ".name").equalsIgnoreCase(name)) {
|
||||||
quest.neededQuests.add(name);
|
temp.add(name);
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2569,6 +2577,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
reqs.setNeededQuests(temp);
|
||||||
if (failed) {
|
if (failed) {
|
||||||
skipQuestProcess(new String[] { "" + failedQuest + " inside quests: Requirement for Quest "
|
skipQuestProcess(new String[] { "" + failedQuest + " inside quests: Requirement for Quest "
|
||||||
+ quest.getName() + " is not a valid Quest name!", "Make sure you aren\'t using the config section identifier." });
|
+ quest.getName() + " is not a valid Quest name!", "Make sure you aren\'t using the config section identifier." });
|
||||||
@ -2579,8 +2588,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
if (config.contains("quests." + questName + ".requirements.permissions")) {
|
if (config.contains("quests." + questName + ".requirements.permissions")) {
|
||||||
if (Quests.checkList(config.getList("quests." + questName + ".requirements.permissions"), String.class)) {
|
if (Quests.checkList(config.getList("quests." + questName + ".requirements.permissions"), String.class)) {
|
||||||
quest.permissionReqs.clear();
|
reqs.setPermissions(config.getStringList("quests." + questName + ".requirements.permissions"));
|
||||||
quest.permissionReqs.addAll(config.getStringList("quests." + questName + ".requirements.permissions"));
|
|
||||||
} else {
|
} else {
|
||||||
skipQuestProcess("permissions: Requirement for Quest " + quest.getName() + " is not a list of permissions!");
|
skipQuestProcess("permissions: Requirement for Quest " + quest.getName() + " is not a list of permissions!");
|
||||||
}
|
}
|
||||||
@ -2594,8 +2602,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (skills.size() != amounts.size()) {
|
if (skills.size() != amounts.size()) {
|
||||||
skipQuestProcess("mcmmo-skills: and mcmmo-amounts: in requirements: for Quest " + quest.getName() + " are not the same size!");
|
skipQuestProcess("mcmmo-skills: and mcmmo-amounts: in requirements: for Quest " + quest.getName() + " are not the same size!");
|
||||||
}
|
}
|
||||||
quest.mcMMOSkillReqs.addAll(skills);
|
reqs.setMcmmoSkills(skills);
|
||||||
quest.mcMMOAmountReqs.addAll(amounts);
|
reqs.setMcmmoAmounts(amounts);
|
||||||
} else {
|
} else {
|
||||||
skipQuestProcess("mcmmo-amounts: Requirement for Quest " + quest.getName() + " is not a list of numbers!");
|
skipQuestProcess("mcmmo-amounts: Requirement for Quest " + quest.getName() + " is not a list of numbers!");
|
||||||
}
|
}
|
||||||
@ -2610,7 +2618,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
String className = config.getString("quests." + questName + ".requirements.heroes-primary-class");
|
String className = config.getString("quests." + questName + ".requirements.heroes-primary-class");
|
||||||
HeroClass hc = heroes.getClassManager().getClass(className);
|
HeroClass hc = heroes.getClassManager().getClass(className);
|
||||||
if (hc != null && hc.isPrimary()) {
|
if (hc != null && hc.isPrimary()) {
|
||||||
quest.heroesPrimaryClassReq = hc.getName();
|
reqs.setHeroesPrimaryClass(hc.getName());
|
||||||
} else if (hc != null) {
|
} else if (hc != null) {
|
||||||
skipQuestProcess("heroes-primary-class: Requirement for Quest " + quest.getName() + " is not a primary Heroes class!");
|
skipQuestProcess("heroes-primary-class: Requirement for Quest " + quest.getName() + " is not a primary Heroes class!");
|
||||||
} else {
|
} else {
|
||||||
@ -2621,7 +2629,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
String className = config.getString("quests." + questName + ".requirements.heroes-secondary-class");
|
String className = config.getString("quests." + questName + ".requirements.heroes-secondary-class");
|
||||||
HeroClass hc = heroes.getClassManager().getClass(className);
|
HeroClass hc = heroes.getClassManager().getClass(className);
|
||||||
if (hc != null && hc.isSecondary()) {
|
if (hc != null && hc.isSecondary()) {
|
||||||
quest.heroesSecondaryClassReq = hc.getName();
|
reqs.setHeroesSecondaryClass(hc.getName());
|
||||||
} else if (hc != null) {
|
} else if (hc != null) {
|
||||||
skipQuestProcess("heroes-secondary-class: Requirement for Quest " + quest.getName() + " is not a secondary Heroes class!");
|
skipQuestProcess("heroes-secondary-class: Requirement for Quest " + quest.getName() + " is not a secondary Heroes class!");
|
||||||
} else {
|
} else {
|
||||||
@ -2630,6 +2638,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}
|
}
|
||||||
if (config.contains("quests." + questName + ".requirements.custom-requirements")) {
|
if (config.contains("quests." + questName + ".requirements.custom-requirements")) {
|
||||||
ConfigurationSection sec = config.getConfigurationSection("quests." + questName + ".requirements.custom-requirements");
|
ConfigurationSection sec = config.getConfigurationSection("quests." + questName + ".requirements.custom-requirements");
|
||||||
|
Map<String, Map<String, Object>> temp = new HashMap<String, Map<String, Object>>();
|
||||||
for (String path : sec.getKeys(false)) {
|
for (String path : sec.getKeys(false)) {
|
||||||
String name = sec.getString(path + ".name");
|
String name = sec.getString(path + ".name");
|
||||||
Optional<CustomRequirement>found=Optional.empty();
|
Optional<CustomRequirement>found=Optional.empty();
|
||||||
@ -2645,10 +2654,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
}else {
|
}else {
|
||||||
ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data");
|
ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data");
|
||||||
Map<String, Object> data=populateCustoms(sec2,found.get().datamap);
|
Map<String, Object> data=populateCustoms(sec2,found.get().datamap);
|
||||||
quest.customRequirements.put(name, data);
|
temp.put(name, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
reqs.setCustomRequirements(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3049,8 +3058,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
if (is != null) {
|
if (is != null) {
|
||||||
NPC npc = CitizensAPI.getNPCRegistry().getById(npcId);
|
NPC npc = CitizensAPI.getNPCRegistry().getById(npcId);
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
oStage.itemsToDeliver.add(is);
|
oStage.getItemsToDeliver().add(is);
|
||||||
oStage.itemDeliveryTargets.add(npcId);
|
oStage.getItemDeliveryTargets().add(npcId);
|
||||||
oStage.deliverMessages = deliveryMessages;
|
oStage.deliverMessages = deliveryMessages;
|
||||||
} else {
|
} else {
|
||||||
stageFailed("" + npcId + " inside npc-delivery-ids: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a valid NPC id!");
|
stageFailed("" + npcId + " inside npc-delivery-ids: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a valid NPC id!");
|
||||||
|
104
src/main/java/me/blackvein/quests/Requirements.java
Normal file
104
src/main/java/me/blackvein/quests/Requirements.java
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
package me.blackvein.quests;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class Requirements {
|
||||||
|
private int money = 0;
|
||||||
|
private int questPoints = 0;
|
||||||
|
private List<ItemStack> items = new LinkedList<ItemStack>();
|
||||||
|
private List<Boolean> removeItems = new LinkedList<Boolean>();
|
||||||
|
private List<String> neededQuests = new LinkedList<String>();
|
||||||
|
private List<String> blockQuests = new LinkedList<String>();
|
||||||
|
private List<String> permissions = new LinkedList<String>();
|
||||||
|
private List<String> mcmmoSkills = new LinkedList<String>();
|
||||||
|
private List<Integer> mcmmoAmounts = new LinkedList<Integer>();
|
||||||
|
private String heroesPrimaryClass = null;
|
||||||
|
private String heroesSecondaryClass = null;
|
||||||
|
private Map<String, Map<String, Object>> customRequirements = new HashMap<String, Map<String, Object>>();
|
||||||
|
private String failRequirements = null;
|
||||||
|
|
||||||
|
public int getMoney() {
|
||||||
|
return money;
|
||||||
|
}
|
||||||
|
public void setMoney(int money) {
|
||||||
|
this.money = money;
|
||||||
|
}
|
||||||
|
public int getQuestPoints() {
|
||||||
|
return questPoints;
|
||||||
|
}
|
||||||
|
public void setQuestPoints(int questPoints) {
|
||||||
|
this.questPoints = questPoints;
|
||||||
|
}
|
||||||
|
public List<ItemStack> getItems() {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
public void setItems(List<ItemStack> items) {
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
public List<Boolean> getRemoveItems() {
|
||||||
|
return removeItems;
|
||||||
|
}
|
||||||
|
public void setRemoveItems(List<Boolean> removeItems) {
|
||||||
|
this.removeItems = removeItems;
|
||||||
|
}
|
||||||
|
public List<String> getNeededQuests() {
|
||||||
|
return neededQuests;
|
||||||
|
}
|
||||||
|
public void setNeededQuests(List<String> neededQuests) {
|
||||||
|
this.neededQuests = neededQuests;
|
||||||
|
}
|
||||||
|
public List<String> getBlockQuests() {
|
||||||
|
return blockQuests;
|
||||||
|
}
|
||||||
|
public void setBlockQuests(List<String> blockQuests) {
|
||||||
|
this.blockQuests = blockQuests;
|
||||||
|
}
|
||||||
|
public List<String> getPermissions() {
|
||||||
|
return permissions;
|
||||||
|
}
|
||||||
|
public void setPermissions(List<String> permissions) {
|
||||||
|
this.permissions = permissions;
|
||||||
|
}
|
||||||
|
public List<String> getMcmmoSkills() {
|
||||||
|
return mcmmoSkills;
|
||||||
|
}
|
||||||
|
public void setMcmmoSkills(List<String> mcmmoSkills) {
|
||||||
|
this.mcmmoSkills = mcmmoSkills;
|
||||||
|
}
|
||||||
|
public List<Integer> getMcmmoAmounts() {
|
||||||
|
return mcmmoAmounts;
|
||||||
|
}
|
||||||
|
public void setMcmmoAmounts(List<Integer> mcmmoAmounts) {
|
||||||
|
this.mcmmoAmounts = mcmmoAmounts;
|
||||||
|
}
|
||||||
|
public String getHeroesPrimaryClass() {
|
||||||
|
return heroesPrimaryClass;
|
||||||
|
}
|
||||||
|
public void setHeroesPrimaryClass(String heroesPrimaryClass) {
|
||||||
|
this.heroesPrimaryClass = heroesPrimaryClass;
|
||||||
|
}
|
||||||
|
public String getHeroesSecondaryClass() {
|
||||||
|
return heroesSecondaryClass;
|
||||||
|
}
|
||||||
|
public void setHeroesSecondaryClass(String heroesSecondaryClass) {
|
||||||
|
this.heroesSecondaryClass = heroesSecondaryClass;
|
||||||
|
}
|
||||||
|
public Map<String, Map<String, Object>> getCustomRequirements() {
|
||||||
|
return customRequirements;
|
||||||
|
}
|
||||||
|
protected void setCustomRequirements(
|
||||||
|
Map<String, Map<String, Object>> customRequirements) {
|
||||||
|
this.customRequirements = customRequirements;
|
||||||
|
}
|
||||||
|
public String getFailRequirements() {
|
||||||
|
return failRequirements;
|
||||||
|
}
|
||||||
|
public void setFailRequirements(String failRequirements) {
|
||||||
|
this.failRequirements = failRequirements;
|
||||||
|
}
|
||||||
|
}
|
@ -35,8 +35,8 @@ public class Stage {
|
|||||||
Integer fishToCatch;
|
Integer fishToCatch;
|
||||||
Integer playersToKill;
|
Integer playersToKill;
|
||||||
Map<Map<Enchantment, Material>, Integer> itemsToEnchant = new HashMap<Map<Enchantment, Material>, Integer>();
|
Map<Map<Enchantment, Material>, Integer> itemsToEnchant = new HashMap<Map<Enchantment, Material>, Integer>();
|
||||||
LinkedList<ItemStack> itemsToDeliver = new LinkedList<ItemStack>();
|
private LinkedList<ItemStack> itemsToDeliver = new LinkedList<ItemStack>();
|
||||||
LinkedList<Integer> itemDeliveryTargets = new LinkedList<Integer>() {
|
private LinkedList<Integer> itemDeliveryTargets = new LinkedList<Integer>() {
|
||||||
|
|
||||||
private static final long serialVersionUID = -2774443496142382127L;
|
private static final long serialVersionUID = -2774443496142382127L;
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ public class Stage {
|
|||||||
if (fishToCatch != null) { return true; }
|
if (fishToCatch != null) { return true; }
|
||||||
if (playersToKill != null) { return true; }
|
if (playersToKill != null) { return true; }
|
||||||
if (itemsToEnchant.isEmpty() == false) { return true; }
|
if (itemsToEnchant.isEmpty() == false) { return true; }
|
||||||
if (itemsToDeliver.isEmpty() == false) { return true; }
|
if (getItemsToDeliver().isEmpty() == false) { return true; }
|
||||||
if (citizensToInteract.isEmpty() == false) { return true; }
|
if (citizensToInteract.isEmpty() == false) { return true; }
|
||||||
if (citizensToKill.isEmpty() == false) { return true; }
|
if (citizensToKill.isEmpty() == false) { return true; }
|
||||||
if (locationsToReach.isEmpty() == false) { return true; }
|
if (locationsToReach.isEmpty() == false) { return true; }
|
||||||
@ -151,4 +151,20 @@ public class Stage {
|
|||||||
if (customObjectives.isEmpty() == false) { return true; }
|
if (customObjectives.isEmpty() == false) { return true; }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LinkedList<ItemStack> getItemsToDeliver() {
|
||||||
|
return itemsToDeliver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemsToDeliver(LinkedList<ItemStack> itemsToDeliver) {
|
||||||
|
this.itemsToDeliver = itemsToDeliver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedList<Integer> getItemDeliveryTargets() {
|
||||||
|
return itemDeliveryTargets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemDeliveryTargets(LinkedList<Integer> itemDeliveryTargets) {
|
||||||
|
this.itemDeliveryTargets = itemDeliveryTargets;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ public class QuestAcceptPrompt extends StringPrompt {
|
|||||||
plugin.conversationFactory.buildConversation((Conversable) player).begin();
|
plugin.conversationFactory.buildConversation((Conversable) player).begin();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(q.failRequirements);
|
player.sendMessage(q.getRequirements().getFailRequirements());
|
||||||
}
|
}
|
||||||
} else if (quester.currentQuests.containsKey(q) == false) {
|
} else if (quester.currentQuests.containsKey(q) == false) {
|
||||||
String msg = Lang.get("questMaxAllowed");
|
String msg = Lang.get("questMaxAllowed");
|
||||||
@ -156,6 +156,6 @@ public class QuestAcceptPrompt extends StringPrompt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String extracted(final Quester quester) {
|
private String extracted(final Quester quester) {
|
||||||
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, quester.questToTake, ChatColor.GOLD, ChatColor.RESET, plugin.getQuest(quester.questToTake).description);
|
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, quester.questToTake, ChatColor.GOLD, ChatColor.RESET, plugin.getQuest(quester.questToTake).getDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user