Finished Quest Journal

This commit is contained in:
Blackvein 2014-08-22 01:01:09 -07:00
parent 821af639aa
commit d5b3513a2f
16 changed files with 1914 additions and 367 deletions

View File

@ -3,7 +3,7 @@
<groupId>me.blackvein.quests</groupId>
<artifactId>quests</artifactId>
<version>1.9.0</version>
<version>2.0.0</version>
<name>quests</name>
<url>http://dev.bukkit.org/server-mods/quests/</url>
<packaging>jar</packaging>

View File

@ -52,11 +52,11 @@ public class NpcEffectThread implements Runnable {
private static void showEffect(Player player, NPC npc) {
if (Bukkit.getVersion().contains("1.7.2")) {
if (Bukkit.getBukkitVersion().contains("1.7.2")) {
showEffect_R1(player, npc);
} else if (Bukkit.getVersion().contains("1.7.9")) {
} else if (Bukkit.getBukkitVersion().contains("1.7.9")) {
showEffect_R3(player, npc);
} else if (Bukkit.getVersion().contains("1.7.10")) {
} else if (Bukkit.getBukkitVersion().contains("1.7.10")) {
showEffect_R4(player, npc);
}

View File

@ -92,10 +92,11 @@ public class NpcListener implements Listener {
if (quester.hasObjective(quest, "talkToNPC")) {
quester.interactWithNPC(quest, evt.getNPC());
if (quester.getQuestData(quest).citizensInteracted.containsKey(evt.getNPC().getId()) && quester.getQuestData(quest).citizensInteracted.get(evt.getNPC().getId()) == false) {
if (quester.getQuestData(quest) != null && quester.getQuestData(quest).citizensInteracted.containsKey(evt.getNPC().getId()) && quester.getQuestData(quest).citizensInteracted.get(evt.getNPC().getId()) == false) {
hasObjective = true;
}
quester.interactWithNPC(quest, evt.getNPC());
}
@ -111,7 +112,7 @@ public class NpcListener implements Listener {
continue;
if (q.npcStart != null && q.npcStart.getId() == evt.getNPC().getId()) {
if (Quests.ignoreLockedQuests) {
if (Quests.ignoreLockedQuests && (quester.completedQuests.contains(q.name) == false || q.redoDelay > -1)) {
if (q.testRequirements(quester)) {
npcQuests.add(q);
}
@ -125,8 +126,7 @@ public class NpcListener implements Listener {
if (npcQuests.isEmpty() == false && npcQuests.size() > 1) {
if (plugin.questNPCGUIs.contains(evt.getNPC().getId())) {
quester.showGUIDisplay(npcQuests);
quester.showGUIDisplay(evt.getNPC(), npcQuests);
return;
}

View File

@ -28,6 +28,7 @@ import org.bukkit.event.entity.EntityTameEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerFishEvent.State;
@ -48,29 +49,31 @@ public class PlayerListener implements Listener, ColorUtil {
InventoryAction ac = evt.getAction();
if(evt.getCurrentItem() != null && ItemUtil.isJournal(evt.getCurrentItem())) {
if(ItemUtil.isItem(evt.getCurrentItem()) && ItemUtil.isJournal(evt.getCurrentItem())) {
if(ac.equals(InventoryAction.MOVE_TO_OTHER_INVENTORY)
|| ac.equals(InventoryAction.DROP_ALL_SLOT)
|| ac.equals(InventoryAction.DROP_ONE_SLOT)) {
evt.setCancelled(true);
return;
}
} else if(evt.getCurrentItem() != null && ItemUtil.isJournal(evt.getCursor())) {
} else if(ItemUtil.isItem(evt.getCurrentItem()) && ItemUtil.isJournal(evt.getCursor())) {
if(ac.equals(InventoryAction.MOVE_TO_OTHER_INVENTORY)
|| ac.equals(InventoryAction.DROP_ALL_CURSOR)
|| ac.equals(InventoryAction.DROP_ONE_CURSOR)) {
evt.setCancelled(true);
return;
}
}
if(evt.getCurrentItem() != null && ItemUtil.isJournal(evt.getCursor()) || evt.getCurrentItem() != null && ItemUtil.isJournal(evt.getCurrentItem())) {
if(ItemUtil.isItem(evt.getCurrentItem()) && ItemUtil.isJournal(evt.getCurrentItem()) || ItemUtil.isItem(evt.getCursor()) && ItemUtil.isJournal(evt.getCursor())) {
int upper = evt.getView().getTopInventory().getSize();
if(evt.getView().getTopInventory().getType().equals(InventoryType.CRAFTING))
@ -80,6 +83,117 @@ public class PlayerListener implements Listener, ColorUtil {
if(relative < 0 || relative >= (lower)) {
evt.setCancelled(true);
return;
}
}
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
Player player = (Player) evt.getWhoClicked();
if (evt.getInventory().getTitle().contains(Lang.get("quests"))) {
ItemStack clicked = evt.getCurrentItem();
if (clicked != null) {
for (Quest quest : plugin.quests) {
if (quest.guiDisplay != null) {
if (ItemUtil.compareItems(clicked, quest.guiDisplay, false) == 0) {
if (quester.currentQuests.size() >= Quests.maxQuests && Quests.maxQuests > 0) {
String msg = Lang.get("questMaxAllowed");
msg = msg.replaceAll("<number>", String.valueOf(Quests.maxQuests));
player.sendMessage(YELLOW + msg);
} else if (quester.completedQuests.contains(quest.name) && quest.redoDelay < 0) {
String completed = Lang.get("questAlreadyCompleted");
completed = completed.replaceAll("<quest>", ChatColor.AQUA + quest.name + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + completed);
} else {
boolean takeable = true;
if (quester.completedQuests.contains(quest.name)) {
if (quester.getDifference(quest) > 0) {
String early = Lang.get("questTooEarly");
early = early.replaceAll("<quest>", ChatColor.AQUA + quest.name + ChatColor.YELLOW);
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(quest)) + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + early);
takeable = false;
}
}
if (quest.region != null) {
boolean inRegion = false;
Player p = quester.getPlayer();
RegionManager rm = Quests.worldGuard.getRegionManager(p.getWorld());
Iterator<ProtectedRegion> it = rm.getApplicableRegions(p.getLocation()).iterator();
while (it.hasNext()) {
ProtectedRegion pr = it.next();
if (pr.getId().equalsIgnoreCase(quest.region)) {
inRegion = true;
break;
}
}
if (inRegion == false) {
String invalidLoc = Lang.get("questInvalidLocation");
invalidLoc = invalidLoc.replaceAll("<quest>", ChatColor.AQUA + quest.name + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + invalidLoc);
takeable = false;
}
}
if (takeable == true) {
quester.takeQuest(quest, false);
}
evt.getWhoClicked().closeInventory();
}
}
}
}
evt.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryDragEvent(InventoryDragEvent evt) {
if(ItemUtil.isItem(evt.getOldCursor()) && ItemUtil.isJournal(evt.getOldCursor()) || ItemUtil.isItem(evt.getCursor()) && ItemUtil.isJournal(evt.getCursor())) {
int upper = evt.getView().getTopInventory().getSize();
if(evt.getView().getTopInventory().getType().equals(InventoryType.CRAFTING))
upper += 4;
int lower = evt.getView().getBottomInventory().getSize();
for(int relative : evt.getRawSlots()) {
relative -= upper;
if(relative < 0 || relative >= (lower)) {
evt.setCancelled(true);
break;
}
}
}
@ -241,96 +355,6 @@ public class PlayerListener implements Listener, ColorUtil {
}
@EventHandler
public void onInventoryClick(InventoryClickEvent evt) {
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
Player player = (Player) evt.getWhoClicked();
if (evt.getInventory().getTitle().equals("Quests")) {
ItemStack clicked = evt.getCurrentItem();
if (clicked != null) {
for (Quest quest : plugin.quests) {
if (quest.guiDisplay != null) {
if (ItemUtil.compareItems(clicked, quest.guiDisplay, false) == 0) {
if (quester.currentQuests.size() >= Quests.maxQuests && Quests.maxQuests > 0) {
String msg = Lang.get("questMaxAllowed");
msg = msg.replaceAll("<number>", String.valueOf(Quests.maxQuests));
player.sendMessage(YELLOW + msg);
} else if (quester.completedQuests.contains(quest.name) && quest.redoDelay < 0) {
String completed = Lang.get("questAlreadyCompleted");
completed = completed.replaceAll("<quest>", ChatColor.AQUA + quest.name + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + completed);
} else {
boolean takeable = true;
if (quester.completedQuests.contains(quest.name)) {
if (quester.getDifference(quest) > 0) {
String early = Lang.get("questTooEarly");
early = early.replaceAll("<quest>", ChatColor.AQUA + quest.name + ChatColor.YELLOW);
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(quest)) + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + early);
takeable = false;
}
}
if (quest.region != null) {
boolean inRegion = false;
Player p = quester.getPlayer();
RegionManager rm = Quests.worldGuard.getRegionManager(p.getWorld());
Iterator<ProtectedRegion> it = rm.getApplicableRegions(p.getLocation()).iterator();
while (it.hasNext()) {
ProtectedRegion pr = it.next();
if (pr.getId().equalsIgnoreCase(quest.region)) {
inRegion = true;
break;
}
}
if (inRegion == false) {
String invalidLoc = Lang.get("questInvalidLocation");
invalidLoc = invalidLoc.replaceAll("<quest>", ChatColor.AQUA + quest.name + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + invalidLoc);
takeable = false;
}
}
if (takeable == true) {
quester.takeQuest(quest, false);
}
evt.getWhoClicked().closeInventory();
}
}
}
}
evt.setCancelled(true);
}
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent evt) {
@ -647,7 +671,7 @@ public class PlayerListener implements Listener, ColorUtil {
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "killPlayer")) {
quester.killPlayer(quest, evt.getEntity().getName());
quester.killPlayer(quest, (Player) evt.getEntity());
}
}
@ -681,7 +705,7 @@ public class PlayerListener implements Listener, ColorUtil {
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "killPlayer")) {
quester.killPlayer(quest, evt.getEntity().getName());
quester.killPlayer(quest, (Player) evt.getEntity());
}
}
@ -791,6 +815,9 @@ public class PlayerListener implements Listener, ColorUtil {
}
}
if(quester.hasJournal)
quester.updateJournal();
}

View File

@ -106,47 +106,56 @@ public class Quest {
} else {
q.currentQuests.put(this, q.currentQuests.get(this) + 1);
try {
setStage(q, q.currentQuests.get(this));
setStage(q, q.currentQuests.get(this) + 1);
} catch (InvalidStageException e) {
e.printStackTrace();
}
}
q.getQuestData(this).delayStartTime = 0;
q.getQuestData(this).delayTimeLeft = -1;
if(q.getQuestData(this) != null) {
q.getQuestData(this).delayStartTime = 0;
q.getQuestData(this).delayTimeLeft = -1;
}
} else {
q.startStageTimer(this);
}
q.updateJournal();
}
public void setStage(Quester quester, int stage) throws InvalidStageException {
quester.currentQuests.put(this, stage);
if (orderedStages.size() - 1 < stage) {
throw new InvalidStageException(this, stage);
}
quester.resetObjectives(this);
Stage currentStage = quester.getCurrentStage(this);
quester.hardQuit(this);
System.out.println("Going to hard put Quest " + getName() + " to Stage " + stage);
System.out.println("Stages: " + this.orderedStages.size());
quester.hardStagePut(this, stage);
quester.addEmptiesFor(this, stage);
if (quester.getCurrentStage(this).script != null) {
plugin.trigger.parseQuestTaskTrigger(quester.getCurrentStage(this).script, quester.getPlayer());
if (currentStage.script != null) {
plugin.trigger.parseQuestTaskTrigger(currentStage.script, quester.getPlayer());
}
/*if (quester.getCurrentStage(this).finishEvent != null) {
quester.getCurrentStage(this).finishEvent.fire(quester);
}*/
System.out.println("vvv Current Stage");
System.out.print(quester.getCurrentStage(this));
System.out.print("\n");
if (quester.getCurrentStage(this).startEvent != null) {
quester.getCurrentStage(this).startEvent.fire(quester, this);
}
quester.addEmpties(this);
String msg = Lang.get("questObjectivesTitle");
msg = msg.replaceAll("<quest>", name);
quester.getPlayer().sendMessage(ChatColor.GOLD + msg);
@ -160,6 +169,8 @@ public class Quest {
if (stageStartMessage != null) {
quester.getPlayer().sendMessage(Quests.parseString(stageStartMessage, this));
}
quester.updateJournal();
}
@ -174,7 +185,7 @@ public class Quest {
public boolean testRequirements(Player player) {
Quester quester = plugin.getQuester(player.getUniqueId());
if (moneyReq != 0 && Quests.economy.getBalance(player.getName()) < moneyReq) {
return false;
}
@ -277,7 +288,7 @@ public class Quest {
public void completeQuest(Quester q) {
Player player = plugin.getServer().getPlayer(q.id);
q.resetObjectives(this);
q.hardQuit(this);
q.completedQuests.add(name);
String none = ChatColor.GRAY + "- (" + Lang.get("none") + ")";
@ -515,30 +526,27 @@ public class Quest {
player.sendMessage(none);
}
q.currentQuests.remove(this);
q.questData.remove(this);
q.saveData();
player.updateInventory();
q.updateJournal();
}
public void failQuest(Quester q) {
Player player = plugin.getServer().getPlayer(q.id);
q.resetObjectives(this);
String title = Lang.get("questTitle");
title = title.replaceAll("<quest>", ChatColor.DARK_PURPLE + name + ChatColor.AQUA);
player.sendMessage(ChatColor.AQUA + title);
player.sendMessage(ChatColor.RED + Lang.get("questFailed"));
q.currentQuests.remove(this);
q.questData.remove(this);
q.hardQuit(this);
q.saveData();
player.updateInventory();
q.updateJournal();
}
@Override
@ -547,7 +555,10 @@ public class Quest {
if (o instanceof Quest) {
Quest other = (Quest) o;
System.out.println("COMPARING OTHER=" + other.name + " AGAINST SELF=" + name);
System.out.println("Here 1");
if (other.blockStart != null && blockStart != null) {
if (other.blockStart.equals(blockStart) == false) {
return false;
@ -558,6 +569,7 @@ public class Quest {
return false;
}
System.out.println("Here 2");
if (commands.size() == other.commands.size()) {
for (int i = 0; i < commands.size(); i++) {
@ -569,7 +581,7 @@ public class Quest {
} else {
return false;
}
System.out.println("Here 3");
if (other.description.equals(description) == false) {
return false;
}
@ -587,7 +599,7 @@ public class Quest {
if (other.exp != exp) {
return false;
}
System.out.println("Here 4");
if (other.failRequirements != null && failRequirements != null) {
if (other.failRequirements.equals(failRequirements) == false) {
return false;
@ -609,7 +621,7 @@ public class Quest {
if (other.itemRewards.equals(itemRewards) == false) {
return false;
}
System.out.println("Here 5");
if (other.rpgItemRewardIDs.equals(rpgItemRewardIDs) == false) {
return false;
}
@ -629,7 +641,7 @@ public class Quest {
if (other.heroesClasses.equals(heroesClasses) == false) {
return false;
}
System.out.println("Here 6");
if (other.heroesAmounts.equals(heroesAmounts) == false) {
return false;
}
@ -649,7 +661,7 @@ public class Quest {
if (other.name.equals(name) == false) {
return false;
}
System.out.println("Here 7");
if (other.neededQuests.equals(neededQuests) == false) {
return false;
}
@ -671,7 +683,7 @@ public class Quest {
if (other.permissionReqs.equals(permissionReqs) == false) {
return false;
}
System.out.println("Here 8");
if (other.heroesPrimaryClassReq != null && heroesPrimaryClassReq != null) {
if (other.heroesPrimaryClassReq.equals(heroesPrimaryClassReq) == false) {
return false;
@ -728,12 +740,56 @@ public class Quest {
return false;
}
} else {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 53 * hash + (this.description != null ? this.description.hashCode() : 0);
hash = 53 * hash + (this.finished != null ? this.finished.hashCode() : 0);
hash = 53 * hash + (int) (this.redoDelay ^ (this.redoDelay >>> 32));
hash = 53 * hash + (this.region != null ? this.region.hashCode() : 0);
hash = 53 * hash + (this.guiDisplay != null ? this.guiDisplay.hashCode() : 0);
hash = 53 * hash + (this.orderedStages != null ? this.orderedStages.hashCode() : 0);
hash = 53 * hash + (this.npcStart != null ? this.npcStart.hashCode() : 0);
hash = 53 * hash + (this.blockStart != null ? this.blockStart.hashCode() : 0);
hash = 53 * hash + (this.initialEvent != null ? this.initialEvent.hashCode() : 0);
hash = 53 * hash + this.moneyReq;
hash = 53 * hash + this.questPointsReq;
hash = 53 * hash + (this.items != null ? this.items.hashCode() : 0);
hash = 53 * hash + (this.neededQuests != null ? this.neededQuests.hashCode() : 0);
hash = 53 * hash + (this.blockQuests != null ? this.blockQuests.hashCode() : 0);
hash = 53 * hash + (this.permissionReqs != null ? this.permissionReqs.hashCode() : 0);
hash = 53 * hash + (this.mcMMOSkillReqs != null ? this.mcMMOSkillReqs.hashCode() : 0);
hash = 53 * hash + (this.mcMMOAmountReqs != null ? this.mcMMOAmountReqs.hashCode() : 0);
hash = 53 * hash + (this.heroesPrimaryClassReq != null ? this.heroesPrimaryClassReq.hashCode() : 0);
hash = 53 * hash + (this.heroesSecondaryClassReq != null ? this.heroesSecondaryClassReq.hashCode() : 0);
hash = 53 * hash + (this.customRequirements != null ? this.customRequirements.hashCode() : 0);
hash = 53 * hash + (this.customRewards != null ? this.customRewards.hashCode() : 0);
hash = 53 * hash + (this.failRequirements != null ? this.failRequirements.hashCode() : 0);
hash = 53 * hash + this.moneyReward;
hash = 53 * hash + this.questPoints;
hash = 53 * hash + this.exp;
hash = 53 * hash + (this.commands != null ? this.commands.hashCode() : 0);
hash = 53 * hash + (this.permissions != null ? this.permissions.hashCode() : 0);
hash = 53 * hash + (this.itemRewards != null ? this.itemRewards.hashCode() : 0);
hash = 53 * hash + (this.rpgItemRewardIDs != null ? this.rpgItemRewardIDs.hashCode() : 0);
hash = 53 * hash + (this.rpgItemRewardAmounts != null ? this.rpgItemRewardAmounts.hashCode() : 0);
hash = 53 * hash + (this.mcmmoSkills != null ? this.mcmmoSkills.hashCode() : 0);
hash = 53 * hash + (this.mcmmoAmounts != null ? this.mcmmoAmounts.hashCode() : 0);
hash = 53 * hash + (this.heroesClasses != null ? this.heroesClasses.hashCode() : 0);
hash = 53 * hash + (this.heroesAmounts != null ? this.heroesAmounts.hashCode() : 0);
hash = 53 * hash + (this.phatLootRewards != null ? this.phatLootRewards.hashCode() : 0);
return hash;
}
public boolean isInRegion(Player player) {
if (region == null) {

File diff suppressed because it is too large Load Diff

View File

@ -810,7 +810,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (quest.guiDisplay != null) {
if (ItemUtil.compareItems(stack, quest.guiDisplay, false) != 0) {
if (ItemUtil.compareItems(stack, quest.guiDisplay, false) == 0) {
String error = Lang.get("questGUIError");
error = error.replaceAll("<quest>", PURPLE + quest.name + RED);
@ -1753,6 +1753,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (q.region != null) {
cc.setSessionData(CK.Q_REGION, q.region);
}
if (q.guiDisplay != null) {
cc.setSessionData(CK.Q_GUIDISPLAY, q.guiDisplay);
}
//Requirements
if (q.moneyReq != 0) {

View File

@ -5,9 +5,11 @@ import java.io.IOException;
import java.util.*;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.Bukkit;
@ -40,6 +42,18 @@ public class Quester {
public String questToTake;
public LinkedHashMap<Quest, Integer> currentQuests = new LinkedHashMap<Quest, Integer>() {
public Integer hardRemove(Object key) {
return super.remove((Quest) key);
}
public void hardClear() {
super.clear();
}
public Integer hardPut(Quest key, Integer val) {
return super.put(key, val);
}
@Override
public Integer put(Quest key, Integer val) {
Integer data = super.put(key, val);
@ -126,10 +140,15 @@ public class Quester {
}
};
Map<String, Long> completedTimes = new HashMap<String, Long>();
Map<String, Integer> amountsCompleted = new HashMap<String, Integer>() {
public void hardClear() {
super.clear();
}
@Override
public Integer put(String key, Integer val) {
Integer data = super.put(key, val);
@ -168,6 +187,18 @@ public class Quester {
return data;
}
public QuestData hardRemove(Object key) {
return super.remove((Quest) key);
}
public void hardClear() {
super.clear();
}
public QuestData hardPut(Quest key, QuestData val) {
return super.put(key, val);
}
@Override
public QuestData remove(Object key) {
QuestData data = super.remove(key);
@ -214,7 +245,6 @@ public class Quester {
if(!hasJournal)
return;
System.out.println("Updating journal.");
Inventory inv = getPlayer().getInventory();
ItemStack[] arr = inv.getContents();
int index = -1;
@ -223,9 +253,7 @@ public class Quester {
if(arr[i] != null) {
System.out.println("Checking: " + arr[i]);
if(ItemUtil.isJournal(arr[i])) {
System.out.println("Is journal");
index = i;
break;
}
@ -247,34 +275,58 @@ public class Quester {
if(currentQuests.isEmpty() == false) {
int currentLength = 0;
int currentLines = 0;
String page = "";
for(Quest quest : currentQuests.keySet()) {
System.out.println("ADDING QUEST: " + quest.getName());
String page = ChatColor.DARK_PURPLE + quest.name + "\n";
int currentLength = 19;
int currentLines = 1;
if((currentLength + quest.name.length() > 240) || (currentLines + ((quest.name.length() % 19) == 0 ? (quest.name.length() / 19) : ((quest.name.length() / 19) + 1))) > 13) {
book.addPage(page);
page += ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + quest.name + "\n";
currentLength = quest.name.length();
currentLines = (quest.name.length() % 19) == 0 ? (quest.name.length() / 19) : (quest.name.length() + 1);
} else {
page += ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + quest.name + "\n";
currentLength += quest.name.length();
currentLines += (quest.name.length() / 19);
}
for(String obj : getObjectivesReal(quest)) {
//Length/Line check
if((currentLength + obj.length() > 240) || (currentLines + ((obj.length() % 19) == 0 ? (obj.length() / 19) : ((obj.length() / 19) + 1))) > 13) {
book.addPage(page);
page = "";
currentLines = 0;
currentLength = 0;
page = obj + "\n";
currentLength = obj.length();
currentLines = (obj.length() % 19) == 0 ? (obj.length() / 19) : (obj.length() + 1);
} else {
page += obj + "\n";
a
currentLength += obj.length();
currentLines += (obj.length() / 19);
}
}
if(currentLines < 13)
page += "\n";
book.addPage(page);
page = "";
currentLines = 0;
currentLength = 0;
}
}
stack.setItemMeta(book);
inv.setItem(index, stack);
@ -286,10 +338,6 @@ public class Quester {
return quest.getStage(currentQuests.get(quest));
}
public void setCurrentStage(Quest quest, int stage) {
currentQuests.put(quest, stage);
}
public QuestData getQuestData(Quest quest) {
return questData.get(quest);
}
@ -298,11 +346,17 @@ public class Quester {
Player player = getPlayer();
System.out.println("Hereeeeeee");
if (q.testRequirements(player) == true || override) {
currentQuests.put(q, 0);
Stage stage = q.getStage(0);
System.out.println("What?");
addEmpties(q);
System.out.println("Okay");
currentQuests.put(q, 0);
System.out.println("Done");
Stage stage = q.getStage(0);
System.out.println("Going to add empties for: " + q.name);
if (!override) {
@ -358,6 +412,9 @@ public class Quester {
} else {
System.out.println("Problem");
System.out.println(q.testRequirements(player));
System.out.println(override);
player.sendMessage(q.failRequirements);
}
@ -378,6 +435,9 @@ public class Quester {
public LinkedList<String> getObjectives(Quest quest) {
if(getQuestData(quest) == null)
return new LinkedList<String>();
LinkedList<String> unfinishedObjectives = new LinkedList<String>();
LinkedList<String> finishedObjectives = new LinkedList<String>();
LinkedList<String> objectives = new LinkedList<String>();
@ -494,13 +554,13 @@ public class Quester {
if (getCurrentStage(quest).fishToCatch != null) {
if (getQuestData(quest).fishCaught < getCurrentStage(quest).fishToCatch) {
if (getQuestData(quest).getFishCaught() < getCurrentStage(quest).fishToCatch) {
unfinishedObjectives.add(ChatColor.GREEN + Lang.get("catchFish") + ": " + getQuestData(quest).fishCaught + "/" + getCurrentStage(quest).fishToCatch);
unfinishedObjectives.add(ChatColor.GREEN + Lang.get("catchFish") + ": " + getQuestData(quest).getFishCaught() + "/" + getCurrentStage(quest).fishToCatch);
} else {
finishedObjectives.add(ChatColor.GRAY + Lang.get("catchFish") + ": " + getQuestData(quest).fishCaught + "/" + getCurrentStage(quest).fishToCatch);
finishedObjectives.add(ChatColor.GRAY + Lang.get("catchFish") + ": " + getQuestData(quest).getFishCaught() + "/" + getCurrentStage(quest).fishToCatch);
}
@ -607,13 +667,13 @@ public class Quester {
if (getCurrentStage(quest).playersToKill != null) {
if (getQuestData(quest).playersKilled < getCurrentStage(quest).playersToKill) {
if (getQuestData(quest).getPlayersKilled() < getCurrentStage(quest).playersToKill) {
unfinishedObjectives.add(ChatColor.GREEN + Lang.get("killPlayer") + ": " + getQuestData(quest).playersKilled + "/" + getCurrentStage(quest).playersToKill);
unfinishedObjectives.add(ChatColor.GREEN + Lang.get("killPlayer") + ": " + getQuestData(quest).getPlayersKilled() + "/" + getCurrentStage(quest).playersToKill);
} else {
finishedObjectives.add(ChatColor.GRAY + Lang.get("killPlayer") + ": " + getQuestData(quest).playersKilled + "/" + getCurrentStage(quest).playersToKill);
finishedObjectives.add(ChatColor.GRAY + Lang.get("killPlayer") + ": " + getQuestData(quest).getPlayersKilled() + "/" + getCurrentStage(quest).playersToKill);
}
@ -621,6 +681,18 @@ public class Quester {
for (ItemStack is : getCurrentStage(quest).itemsToDeliver) {
System.out.print("Quest data: ");
System.out.print(getQuestData(quest));
System.out.println();
System.out.print("Items delivered: ");
System.out.print(getQuestData(quest).itemsDelivered);
System.out.println();
System.out.print("IS: ");
System.out.print(is);
System.out.println();
int delivered = getQuestData(quest).itemsDelivered.get(is);
int amt = is.getAmount();
Integer npc = getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(is));
@ -995,10 +1067,10 @@ public class Quester {
public void catchFish(Quest quest) {
if (getQuestData(quest).fishCaught < getCurrentStage(quest).fishToCatch) {
getQuestData(quest).fishCaught++;
if (getQuestData(quest).getFishCaught() < getCurrentStage(quest).fishToCatch) {
getQuestData(quest).setFishCaught(getQuestData(quest).getFishCaught() + 1);
if (((Integer) getQuestData(quest).fishCaught).equals(getCurrentStage(quest).fishToCatch)) {
if (((Integer) getQuestData(quest).getFishCaught()).equals(getCurrentStage(quest).fishToCatch)) {
finishObjective(quest, "catchFish", null, null, null, null, null, null, null, null, null, null);
}
@ -1092,11 +1164,11 @@ public class Quester {
}
public void killPlayer(Quest quest, String player) {
public void killPlayer(Quest quest, Player player) {
if (getQuestData(quest).playerKillTimes.containsKey(player)) {
if (getQuestData(quest).playerKillTimes.containsKey(player.getUniqueId())) {
long killTime = getQuestData(quest).playerKillTimes.get(player);
long killTime = getQuestData(quest).playerKillTimes.get(player.getUniqueId());
long comparator = plugin.killDelay * 1000;
long currentTime = System.currentTimeMillis();
@ -1104,7 +1176,7 @@ public class Quester {
String error = Lang.get("killNotValid");
error = error.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(comparator - (currentTime - killTime)) + ChatColor.RED);
error = error.replaceAll("<player>", ChatColor.DARK_PURPLE + player + ChatColor.RED);
error = error.replaceAll("<player>", ChatColor.DARK_PURPLE + player.getName() + ChatColor.RED);
getPlayer().sendMessage(ChatColor.RED + error);
return;
@ -1112,12 +1184,12 @@ public class Quester {
}
getQuestData(quest).playerKillTimes.put(player, System.currentTimeMillis());
getQuestData(quest).playerKillTimes.put(player.getUniqueId(), System.currentTimeMillis());
if (getQuestData(quest).playersKilled < getCurrentStage(quest).playersToKill) {
getQuestData(quest).playersKilled++;
if (getQuestData(quest).getPlayersKilled() < getCurrentStage(quest).playersToKill) {
getQuestData(quest).setPlayersKilled(getQuestData(quest).getPlayersKilled() + 1);
if (((Integer) getQuestData(quest).playersKilled).equals(getCurrentStage(quest).playersToKill)) {
if (((Integer) getQuestData(quest).getPlayersKilled()).equals(getCurrentStage(quest).playersToKill)) {
finishObjective(quest, "killPlayer", null, null, null, null, null, null, null, null, null, null);
}
@ -1515,179 +1587,309 @@ public class Quester {
public void addEmpties(Quest quest) {
QuestData data = new QuestData();
questData.put(quest, data);
QuestData data = new QuestData(this);
data.setDoJournalUpdate(false);
System.out.println("Put quest data for: " + quest.name);
if (getCurrentStage(quest).blocksToDamage.isEmpty() == false) {
for (Material m : getCurrentStage(quest).blocksToDamage.keySet()) {
if (quest.getStage(0).blocksToDamage.isEmpty() == false) {
for (Material m : quest.getStage(0).blocksToDamage.keySet()) {
getQuestData(quest).blocksDamaged.put(m, 0);
data.blocksDamaged.put(m, 0);
}
}
if (getCurrentStage(quest).blocksToBreak.isEmpty() == false) {
for (Material m : getCurrentStage(quest).blocksToBreak.keySet()) {
if (quest.getStage(0).blocksToBreak.isEmpty() == false) {
for (Material m : quest.getStage(0).blocksToBreak.keySet()) {
getQuestData(quest).blocksBroken.put(m, 0);
data.blocksBroken.put(m, 0);
}
}
if (getCurrentStage(quest).blocksToPlace.isEmpty() == false) {
for (Material m : getCurrentStage(quest).blocksToPlace.keySet()) {
if (quest.getStage(0).blocksToPlace.isEmpty() == false) {
for (Material m : quest.getStage(0).blocksToPlace.keySet()) {
getQuestData(quest).blocksPlaced.put(m, 0);
data.blocksPlaced.put(m, 0);
}
}
if (getCurrentStage(quest).blocksToUse.isEmpty() == false) {
for (Material m : getCurrentStage(quest).blocksToUse.keySet()) {
if (quest.getStage(0).blocksToUse.isEmpty() == false) {
for (Material m : quest.getStage(0).blocksToUse.keySet()) {
getQuestData(quest).blocksUsed.put(m, 0);
data.blocksUsed.put(m, 0);
}
}
if (getCurrentStage(quest).blocksToCut.isEmpty() == false) {
for (Material m : getCurrentStage(quest).blocksToCut.keySet()) {
if (quest.getStage(0).blocksToCut.isEmpty() == false) {
for (Material m : quest.getStage(0).blocksToCut.keySet()) {
getQuestData(quest).blocksCut.put(m, 0);
data.blocksCut.put(m, 0);
}
}
getQuestData(quest).fishCaught = 0;
data.setFishCaught(0);
if (getCurrentStage(quest).itemsToEnchant.isEmpty() == false) {
for (Entry<Map<Enchantment, Material>, Integer> e : getCurrentStage(quest).itemsToEnchant.entrySet()) {
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();
getQuestData(quest).itemsEnchanted.put(map, 0);
data.itemsEnchanted.put(map, 0);
}
}
if (getCurrentStage(quest).mobsToKill.isEmpty() == false) {
for (EntityType e : getCurrentStage(quest).mobsToKill) {
if (quest.getStage(0).mobsToKill.isEmpty() == false) {
for (EntityType e : quest.getStage(0).mobsToKill) {
getQuestData(quest).mobsKilled.add(e);
getQuestData(quest).mobNumKilled.add(0);
if (getCurrentStage(quest).locationsToKillWithin.isEmpty() == false) {
getQuestData(quest).locationsToKillWithin.add(getCurrentStage(quest).locationsToKillWithin.get(getQuestData(quest).mobsKilled.indexOf(e)));
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 (getCurrentStage(quest).radiiToKillWithin.isEmpty() == false) {
getQuestData(quest).radiiToKillWithin.add(getCurrentStage(quest).radiiToKillWithin.get(getQuestData(quest).mobsKilled.indexOf(e)));
if (quest.getStage(0).radiiToKillWithin.isEmpty() == false) {
data.radiiToKillWithin.add(quest.getStage(0).radiiToKillWithin.get(data.mobsKilled.indexOf(e)));
}
}
}
getQuestData(quest).playersKilled = 0;
data.setPlayersKilled(0);
if (getCurrentStage(quest).itemsToDeliver.isEmpty() == false) {
for (ItemStack is : getCurrentStage(quest).itemsToDeliver) {
if (quest.getStage(0).itemsToDeliver.isEmpty() == false) {
for (ItemStack is : quest.getStage(0).itemsToDeliver) {
getQuestData(quest).itemsDelivered.put(is, 0);
data.itemsDelivered.put(is, 0);
}
}
if (getCurrentStage(quest).citizensToInteract.isEmpty() == false) {
for (Integer n : getCurrentStage(quest).citizensToInteract) {
if (quest.getStage(0).citizensToInteract.isEmpty() == false) {
for (Integer n : quest.getStage(0).citizensToInteract) {
getQuestData(quest).citizensInteracted.put(n, false);
data.citizensInteracted.put(n, false);
}
}
if (getCurrentStage(quest).citizensToKill.isEmpty() == false) {
for (Integer n : getCurrentStage(quest).citizensToKill) {
if (quest.getStage(0).citizensToKill.isEmpty() == false) {
for (Integer n : quest.getStage(0).citizensToKill) {
getQuestData(quest).citizensKilled.add(n);
getQuestData(quest).citizenNumKilled.add(0);
data.citizensKilled.add(n);
data.citizenNumKilled.add(0);
}
}
if (getCurrentStage(quest).blocksToCut.isEmpty() == false) {
for (Material m : getCurrentStage(quest).blocksToCut.keySet()) {
if (quest.getStage(0).blocksToCut.isEmpty() == false) {
for (Material m : quest.getStage(0).blocksToCut.keySet()) {
getQuestData(quest).blocksCut.put(m, 0);
data.blocksCut.put(m, 0);
}
}
if (getCurrentStage(quest).locationsToReach.isEmpty() == false) {
for (Location l : getCurrentStage(quest).locationsToReach) {
if (quest.getStage(0).locationsToReach.isEmpty() == false) {
for (Location l : quest.getStage(0).locationsToReach) {
getQuestData(quest).locationsReached.add(l);
getQuestData(quest).hasReached.add(false);
getQuestData(quest).radiiToReachWithin.add(getCurrentStage(quest).radiiToReachWithin.get(getQuestData(quest).locationsReached.indexOf(l)));
data.locationsReached.add(l);
data.hasReached.add(false);
data.radiiToReachWithin.add(quest.getStage(0).radiiToReachWithin.get(data.locationsReached.indexOf(l)));
}
}
if (getCurrentStage(quest).mobsToTame.isEmpty() == false) {
for (EntityType e : getCurrentStage(quest).mobsToTame.keySet()) {
if (quest.getStage(0).mobsToTame.isEmpty() == false) {
for (EntityType e : quest.getStage(0).mobsToTame.keySet()) {
getQuestData(quest).mobsTamed.put(e, 0);
data.mobsTamed.put(e, 0);
}
}
if (getCurrentStage(quest).sheepToShear.isEmpty() == false) {
for (DyeColor d : getCurrentStage(quest).sheepToShear.keySet()) {
if (quest.getStage(0).sheepToShear.isEmpty() == false) {
for (DyeColor d : quest.getStage(0).sheepToShear.keySet()) {
getQuestData(quest).sheepSheared.put(d, 0);
data.sheepSheared.put(d, 0);
}
}
if (getCurrentStage(quest).passwordDisplays.isEmpty() == false) {
for (String display : getCurrentStage(quest).passwordDisplays) {
getQuestData(quest).passwordsSaid.put(display, false);
System.out.println("huehuehue");
if (quest.getStage(0).passwordDisplays.isEmpty() == false) {
System.out.println("jajaja");
for (String display : quest.getStage(0).passwordDisplays) {
System.out.println("display: " + display);
data.passwordsSaid.put(display, false);
}
}
if (getCurrentStage(quest).customObjectives.isEmpty() == false) {
for (CustomObjective co : getCurrentStage(quest).customObjectives) {
getQuestData(quest).customObjectiveCounts.put(co.getName(), 0);
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 resetObjectives(Quest quest) {
QuestData data = new QuestData(this);
data.setDoJournalUpdate(false);
System.out.println("Put quest data for: " + quest.name);
if (getQuestData(quest) == null) {
questData.put(quest, new QuestData());
if (quest.getStage(stage).blocksToDamage.isEmpty() == false) {
for (Material m : quest.getStage(stage).blocksToDamage.keySet()) {
data.blocksDamaged.put(m, 0);
}
}
getQuestData(quest).blocksDamaged.clear();
getQuestData(quest).blocksBroken.clear();
getQuestData(quest).blocksPlaced.clear();
getQuestData(quest).blocksUsed.clear();
getQuestData(quest).blocksCut.clear();
getQuestData(quest).fishCaught = 0;
getQuestData(quest).itemsEnchanted.clear();
getQuestData(quest).mobsKilled.clear();
getQuestData(quest).mobNumKilled.clear();
getQuestData(quest).locationsToKillWithin.clear();
getQuestData(quest).radiiToKillWithin.clear();
getQuestData(quest).playersKilled = 0;
getQuestData(quest).itemsDelivered.clear();
getQuestData(quest).citizensInteracted.clear();
getQuestData(quest).citizensKilled.clear();
getQuestData(quest).citizenNumKilled.clear();
getQuestData(quest).locationsReached.clear();
getQuestData(quest).hasReached.clear();
getQuestData(quest).radiiToReachWithin.clear();
getQuestData(quest).mobsTamed.clear();
getQuestData(quest).sheepSheared.clear();
getQuestData(quest).customObjectiveCounts.clear();
getQuestData(quest).passwordsSaid.clear();
if (quest.getStage(stage).blocksToBreak.isEmpty() == false) {
for (Material m : quest.getStage(stage).blocksToBreak.keySet()) {
data.blocksBroken.put(m, 0);
}
}
if (quest.getStage(stage).blocksToPlace.isEmpty() == false) {
for (Material m : quest.getStage(stage).blocksToPlace.keySet()) {
data.blocksPlaced.put(m, 0);
}
}
if (quest.getStage(stage).blocksToUse.isEmpty() == false) {
for (Material m : quest.getStage(stage).blocksToUse.keySet()) {
data.blocksUsed.put(m, 0);
}
}
if (quest.getStage(stage).blocksToCut.isEmpty() == false) {
for (Material m : quest.getStage(stage).blocksToCut.keySet()) {
data.blocksCut.put(m, 0);
}
}
data.setFishCaught(0);
if (quest.getStage(stage).itemsToEnchant.isEmpty() == false) {
for (Entry<Map<Enchantment, Material>, Integer> e : quest.getStage(stage).itemsToEnchant.entrySet()) {
Map<Enchantment, Material> map = (Map<Enchantment, Material>) e.getKey();
data.itemsEnchanted.put(map, 0);
}
}
if (quest.getStage(stage).mobsToKill.isEmpty() == false) {
for (EntityType e : quest.getStage(stage).mobsToKill) {
data.mobsKilled.add(e);
data.mobNumKilled.add(0);
if (quest.getStage(stage).locationsToKillWithin.isEmpty() == false) {
data.locationsToKillWithin.add(quest.getStage(stage).locationsToKillWithin.get(data.mobsKilled.indexOf(e)));
}
if (quest.getStage(stage).radiiToKillWithin.isEmpty() == false) {
data.radiiToKillWithin.add(quest.getStage(stage).radiiToKillWithin.get(data.mobsKilled.indexOf(e)));
}
}
}
data.setPlayersKilled(0);
if (quest.getStage(stage).itemsToDeliver.isEmpty() == false) {
for (ItemStack is : quest.getStage(stage).itemsToDeliver) {
data.itemsDelivered.put(is, 0);
}
}
if (quest.getStage(stage).citizensToInteract.isEmpty() == false) {
for (Integer n : quest.getStage(stage).citizensToInteract) {
data.citizensInteracted.put(n, false);
}
}
if (quest.getStage(stage).citizensToKill.isEmpty() == false) {
for (Integer n : quest.getStage(stage).citizensToKill) {
data.citizensKilled.add(n);
data.citizenNumKilled.add(0);
}
}
if (quest.getStage(stage).blocksToCut.isEmpty() == false) {
for (Material m : quest.getStage(stage).blocksToCut.keySet()) {
data.blocksCut.put(m, 0);
}
}
if (quest.getStage(stage).locationsToReach.isEmpty() == false) {
for (Location l : quest.getStage(stage).locationsToReach) {
data.locationsReached.add(l);
data.hasReached.add(false);
data.radiiToReachWithin.add(quest.getStage(stage).radiiToReachWithin.get(data.locationsReached.indexOf(l)));
}
}
if (quest.getStage(stage).mobsToTame.isEmpty() == false) {
for (EntityType e : quest.getStage(stage).mobsToTame.keySet()) {
data.mobsTamed.put(e, 0);
}
}
if (quest.getStage(stage).sheepToShear.isEmpty() == false) {
for (DyeColor d : quest.getStage(stage).sheepToShear.keySet()) {
data.sheepSheared.put(d, 0);
}
}
System.out.println("huehuehue");
if (quest.getStage(stage).passwordDisplays.isEmpty() == false) {
System.out.println("jajaja");
for (String display : quest.getStage(stage).passwordDisplays) {
System.out.println("display: " + display);
data.passwordsSaid.put(display, false);
}
}
if (quest.getStage(stage).customObjectives.isEmpty() == false) {
for (CustomObjective co : quest.getStage(stage).customObjectives) {
data.customObjectiveCounts.put(co.getName(), 0);
}
}
data.setDoJournalUpdate(true);
hardDataPut(quest, data);
}
@ -1810,12 +2012,16 @@ public class Quester {
public static String capitalsToSpaces(String s) {
for (int i = 1; i < s.length(); i++) {
int max = s.length();
for (int i = 1; i < max; i++) {
if (Character.isUpperCase(s.charAt(i))) {
s = s.substring(0, i) + " " + s.substring(i);
i++;
max++;
}
}
@ -1913,6 +2119,11 @@ public class Quester {
ConfigurationSection questSec = dataSec.createSection(quest.name);
if(getQuestData(quest) == null)
System.out.println("Quest data is null for " + quest.name);
System.out.println(getQuestData(quest));
System.out.println(getQuestData(quest).blocksDamaged);
if (getQuestData(quest).blocksDamaged.isEmpty() == false) {
LinkedList<Integer> blockIds = new LinkedList<Integer>();
@ -1989,11 +2200,11 @@ public class Quester {
}
if (getCurrentStage(quest).fishToCatch != null) {
questSec.set("fish-caught", getQuestData(quest).fishCaught);
questSec.set("fish-caught", getQuestData(quest).getFishCaught());
}
if (getCurrentStage(quest).playersToKill != null) {
questSec.set("players-killed", getQuestData(quest).playersKilled);
questSec.set("players-killed", getQuestData(quest).getPlayersKilled());
}
if (getQuestData(quest).itemsEnchanted.isEmpty() == false) {
@ -2302,6 +2513,7 @@ public class Quester {
}
data.set("hasJournal", hasJournal);
data.set("lastKnownName", getPlayer().getName());
return data;
@ -2329,6 +2541,8 @@ public class Quester {
} catch (InvalidConfigurationException e) {
return false;
}
hardClear();
if (data.contains("completedRedoableQuests")) {
@ -2351,8 +2565,6 @@ public class Quester {
}
amountsCompleted.clear();
if (data.contains("amountsCompletedQuests")) {
List<String> list1 = data.getStringList("amountsCompletedQuests");
@ -2367,6 +2579,8 @@ public class Quester {
}
questPoints = data.getInt("quest-points");
hasJournal = data.getBoolean("hasJournal");
if (data.isList("completed-Quests")) {
@ -2485,19 +2699,19 @@ public class Quester {
}
if (questSec.contains("fish-caught")) {
getQuestData(quest).fishCaught = questSec.getInt("fish-caught");
getQuestData(quest).setFishCaught(questSec.getInt("fish-caught"));
}
if (questSec.contains("players-killed")) {
getQuestData(quest).playersKilled = questSec.getInt("players-killed");
getQuestData(quest).setPlayersKilled(questSec.getInt("players-killed"));
List<String> playerNames = questSec.getStringList("player-killed-names");
List<Long> killTimes = questSec.getLongList("kill-times");
for (String s : playerNames) {
getQuestData(quest).playerKillTimes.put(s, killTimes.get(playerNames.indexOf(s)));
getQuestData(quest).playerKillTimes.put(UUID.fromString(s), killTimes.get(playerNames.indexOf(s)));
}
@ -2753,7 +2967,7 @@ public class Quester {
}
}
return true;
}
@ -2822,13 +3036,13 @@ public class Quester {
exists = true;
if (q.equals(quest) == false) {
questData.remove(quest);
currentQuests.remove(quest);
hardQuit(quest);
if (plugin.getServer().getPlayer(id) != null) {
String error = Lang.get("questModified");
error = error.replaceAll("<quest>", ChatColor.DARK_PURPLE + quest.name + ChatColor.RED);
plugin.getServer().getPlayer(id).sendMessage(ChatColor.GOLD + "[Quests] " + ChatColor.RED + error);
updateJournal();
}
}
@ -2962,18 +3176,32 @@ public class Quester {
return changed;
}
public void showGUIDisplay(LinkedList<Quest> quests) {
public void showGUIDisplay(NPC npc, LinkedList<Quest> quests) {
Player player = getPlayer();
int size = ((quests.size() / 9) + 1) * 9;
Inventory inv = Bukkit.getServer().createInventory(player, size, "Quests");
Inventory inv = Bukkit.getServer().createInventory(player, size, Lang.get("quests") + " | " + npc.getName());
int inc = 0;
for (int i = 0; i < quests.size(); i++) {
if (quests.get(i).guiDisplay != null) {
inv.setItem(inc, quests.get(i).guiDisplay);
ItemStack display = quests.get(i).guiDisplay;
ItemMeta meta = display.getItemMeta();
meta.setDisplayName(ChatColor.DARK_PURPLE + Quests.parseString(quests.get(i).getName(), npc));
String lore = ChatColor.DARK_GREEN + quests.get(i).description;
LinkedList<String> lines = new LinkedList<String>();
lines = MiscUtil.makeLines(lore, " ", 100);
meta.setLore(lines);
display.setItemMeta(meta);
inv.setItem(inc, display);
inc++;
}
@ -2982,5 +3210,48 @@ public class Quester {
player.openInventory(inv);
}
public void hardQuit(Quest quest) {
try {
currentQuests.getClass().getMethod("hardRemove", Object.class).invoke(currentQuests, quest);
questData.getClass().getMethod("hardRemove", Object.class).invoke(questData, quest);
} catch (Exception ex) {
Logger.getLogger(Quests.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void hardClear() {
try {
currentQuests.getClass().getMethod("hardClear", Object.class).invoke(currentQuests);
questData.getClass().getMethod("hardClear", Object.class).invoke(questData);
amountsCompleted.getClass().getMethod("hardClear", Object.class).invoke(amountsCompleted);
} catch (Exception ex) {
Logger.getLogger(Quests.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void hardStagePut(Quest key, Integer val) {
try {
currentQuests.getClass().getMethod("hardPut", Quest.class, Integer.class).invoke(currentQuests, key, val);
} catch (Exception ex) {
Logger.getLogger(Quests.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void hardDataPut(Quest key, QuestData val) {
try {
questData.getClass().getMethod("hardPut", Quest.class, QuestData.class).invoke(questData, key, val);
} catch (Exception ex) {
Logger.getLogger(Quests.class.getName()).log(Level.SEVERE, null, ex);
}
}
}

View File

@ -139,8 +139,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
public int killDelay = 0;
public int totalQuestPoints = 0;
public Lang lang;
public HashMap<String, Integer> commands = new HashMap<String, Integer>();
public HashMap<String, Integer> adminCommands = new HashMap<String, Integer>();
private static Quests instance = null;
public static final String validVersion = "1.7.9-R0.2";
@SuppressWarnings("serial")
class StageFailedException extends Exception {
@ -195,6 +196,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
defaultQuestsFile();
defaultEventsFile();
defaultDataFile();
loadCommands();
getServer().getPluginManager().registerEvents(pListener, this);
if (npcEffects) {
@ -299,7 +302,87 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}
}
public void loadCommands() {
// [] - required
// {} - optional
commands.put(Lang.get("COMMAND_LIST"), 1); // list {page}
commands.put(Lang.get("COMMAND_TAKE"), 2); // take [quest]
commands.put(Lang.get("COMMAND_QUIT"), 2); // quit [quest]
commands.put(Lang.get("COMMAND_EDITOR"), 1); // editor
commands.put(Lang.get("COMMAND_EVENTS_EDITOR"), 1); // events
commands.put(Lang.get("COMMAND_STATS"), 1); // stats
commands.put(Lang.get("COMMAND_TOP"), 2); // top [number]
commands.put(Lang.get("COMMAND_INFO"), 1); // info
commands.put(Lang.get("COMMAND_JOURNAL"), 1); // journal
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_GIVE"), 3); // give [player] [quest]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_QUIT"), 3); // quit [player] [quest]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_POINTS"), 3); // points [player] [amount]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_TAKEPOINTS"), 3); // takepoints [player] [amount]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_GIVEPOINTS"), 3); // givepoints [player] [amount]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_POINTSALL"), 2); // pointsall [amount]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_FINISH"), 3); // finish [player] [quest]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE"), 3); // nextstage [player] [quest]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_SETSTAGE"), 4); // setstage [player] [quest] [stage]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_TOGGLEGUI"), 2); // togglegui [npc id]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_RELOAD"), 1); // reload
}
public String checkCommand(String cmd, String[] args) {
if(cmd.equalsIgnoreCase("quest") || args.length == 0) {
return null;
}
if(cmd.equalsIgnoreCase("quests")) {
if(commands.containsKey(args[0].toLowerCase())) {
int min = commands.get(args[0].toLowerCase());
if(args.length < min)
return getQuestsCommandUsage(args[0]);
else
return null;
}
return YELLOW + Lang.get("questsUnknownCommand");
} else if(cmd.equalsIgnoreCase("questsadmin") || cmd.equalsIgnoreCase("questadmin")) {
if(adminCommands.containsKey(args[0].toLowerCase())) {
int min = adminCommands.get(args[0].toLowerCase());
if(args.length < min)
return getQuestadminCommandUsage(args[0]);
else
return null;
}
return YELLOW + Lang.get("questsUnknownAdminCommand");
}
return "NULL";
}
public String getQuestsCommandUsage(String cmd) {
return RED + Lang.get("usage") + ":" + YELLOW + "/quests " + Lang.get(Lang.getCommandKey(cmd) + "_HELP");
}
public String getQuestadminCommandUsage(String cmd) {
return RED + Lang.get("usage") + ": " + YELLOW + "/questadmin " + Lang.get(Lang.getCommandKey(cmd) + "_HELP");
}
private void linkOtherPlugins() {
try {
if (getServer().getPluginManager().getPlugin("Citizens") != null) {
citizens = (CitizensPlugin) getServer().getPluginManager().getPlugin("Citizens");
@ -398,7 +481,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
getQuester(player.getUniqueId()).takeQuest(getQuest(getQuester(player.getUniqueId()).questToTake), false);
try{
getQuester(player.getUniqueId()).takeQuest(getQuest(getQuester(player.getUniqueId()).questToTake), false);
}catch(Exception e) {
e.printStackTrace();
}
return Prompt.END_OF_CONVERSATION;
} else if (s.equalsIgnoreCase(Lang.get("noWord"))) {
@ -641,6 +728,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
@Override
public boolean onCommand(final CommandSender cs, Command cmd, String label, String[] args) {
String error = checkCommand(cmd.getName(), args);
if(error != null) {
cs.sendMessage(error);
return true;
}
if (cmd.getName().equalsIgnoreCase("quest")) {
return questCommandHandler(cs, args);
@ -664,74 +758,57 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (args.length == 0) {
adminHelp(cs);
return true;
} else if (args.length == 1) {
}
if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_RELOAD"))) {
if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_RELOAD"))) {
adminReload(cs);
adminReload(cs);
} else {
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_POINTSALL"))) {
cs.sendMessage(YELLOW + Lang.get("questsUnknownAdminCommand"));
adminPointsAll(cs, args);
}
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_GIVE"))) {
} else if (args.length == 2) {
adminGive(cs, args);
if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_POINTSALL"))) {
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_POINTS"))) {
adminPointsAll(cs, args);
adminPoints(cs, args);
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_GIVE"))) {
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_TAKEPOINTS"))) {
adminGive(cs, args);
adminTakePoints(cs, args);
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_POINTS"))) {
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_GIVEPOINTS"))) {
adminPoints(cs, args);
adminGivePoints(cs, args);
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_TAKEPOINTS"))) {
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_TOGGLEGUI"))) {
adminTakePoints(cs, args);
adminToggieGUI(cs, args);
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_GIVEPOINTS"))) {
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_QUIT"))) {
adminGivePoints(cs, args);
adminQuit(cs, args);
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_TOGGLEGUI"))) {
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE"))) {
adminToggieGUI(cs, args);
adminNextStage(cs, args);
} else {
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_SETSTAGE"))) {
cs.sendMessage(YELLOW + Lang.get("questsUnknownAdminCommand"));
adminSetStage(cs, args);
}
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_FINISH"))) {
} else if (args.length >= 3) {
adminFinish(cs, args);
if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_QUIT"))) {
} else {
adminQuit(cs, args);
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE"))) {
adminNextStage(cs, args);
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_SETSTAGE"))) {
adminSetStage(cs, args);
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_FINISH"))) {
adminFinish(cs, args);
} else {
cs.sendMessage(YELLOW + Lang.get("questsUnknownAdminCommand"));
}
cs.sendMessage(YELLOW + Lang.get("questsUnknownAdminCommand"));
}
@ -771,13 +848,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else if (questNPCGUIs.contains(i)) {
questNPCGUIs.remove(questNPCGUIs.indexOf(i));
updateData();
String msg = Lang.get("enableNPCGUI");
String msg = Lang.get("disableNPCGUI");
msg = msg.replaceAll("<npc>", PURPLE + citizens.getNPCRegistry().getById(i).getName() + YELLOW);
cs.sendMessage(YELLOW + msg);
} else {
questNPCGUIs.add(i);
updateData();
String msg = Lang.get("disableNPCGUI");
String msg = Lang.get("enableNPCGUI");
msg = msg.replaceAll("<npc>", PURPLE + citizens.getNPCRegistry().getById(i).getName() + YELLOW);
cs.sendMessage(YELLOW + msg);
}
@ -852,6 +929,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}
private void adminTakePoints(final CommandSender cs, String[] args) {
if (cs.hasPermission("quests.admin.takepoints")) {
Player target = null;
@ -964,6 +1042,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}
private void adminGive(final CommandSender cs, String[] args) {
if (cs.hasPermission("quests.admin.give")) {
Player target = null;
@ -1029,9 +1108,24 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
cs.sendMessage(YELLOW + Lang.get("questNotFound"));
} else {
Quester quester = getQuester(target.getUniqueId());
quester.resetObjectives(questToGive);
for (Quest q : quester.currentQuests.keySet()) {
if(q.getName().equalsIgnoreCase(questToGive.getName())) {
String msg = Lang.get("questsPlayerHasQuestAlready");
msg = msg.replaceAll("<player>", ITALIC + "" + GREEN + target.getName() + RESET + YELLOW);
msg = msg.replaceAll("<quest>", ITALIC + "" + PURPLE + questToGive.getName() + RESET + YELLOW);
cs.sendMessage(YELLOW + msg);
return;
}
}
quester.hardQuit(questToGive);
String msg1 = Lang.get("questForceTake");
msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD);
@ -1389,9 +1483,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
return;
}
quester.resetObjectives(found);
quester.currentQuests.remove(found);
quester.questData.remove(found);
quester.hardQuit(found);
String msg1 = Lang.get("questForceQuit");
msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD);
msg1 = msg1.replaceAll("<quest>", PURPLE + found.name + GOLD);
@ -1402,6 +1495,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
target.sendMessage(GREEN + msg2);
quester.saveData();
quester.updateJournal();
}
@ -1421,6 +1515,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (args.length == 0) {
questsHelp(cs);
return true;
} else {
@ -1455,6 +1550,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_EVENTS_EDITOR"))) {
questsEvents(cs);
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_INFO"))) {
questsInfo(cs);
@ -1721,14 +1817,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
return true;
}
quester.resetObjectives(found);
quester.currentQuests.remove(found);
quester.questData.remove(found);
quester.hardQuit(found);
String msg = Lang.get("questQuit");
msg = msg.replaceAll("<quest>", PURPLE + found.name + YELLOW);
player.sendMessage(YELLOW + msg);
quester.saveData();
quester.loadData();
quester.updateJournal();
return true;
} else {
@ -1811,6 +1907,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
String msg = Lang.get("questMaxAllowed");
msg = msg.replaceAll("<number>", String.valueOf(maxQuests));
player.sendMessage(YELLOW + msg);
} else if (quester.currentQuests.containsKey(q)) {
String msg = Lang.get("questAlreadyOn");
player.sendMessage(YELLOW + msg);
} else if (quester.completedQuests.contains(q.name) && q.redoDelay < 0) {
String msg = Lang.get("questAlreadyCompleted");
msg = msg.replaceAll("<quest>", PURPLE + q.name + YELLOW);
@ -1962,6 +2061,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}
private boolean questCommandHandler(final CommandSender cs, String[] args) {
if (cs instanceof Player) {
if (((Player) cs).hasPermission("quests.quest")) {
@ -4140,6 +4240,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
parsed = parsed.replaceAll("<underline>", UNDERLINE.toString());
parsed = parsed.replaceAll("<strike>", STRIKETHROUGH.toString());
parsed = parsed.replaceAll("<reset>", RESET.toString());
parsed = parsed.replaceAll("<br>", "\n");
parsed = ChatColor.translateAlternateColorCodes('&', parsed);
return parsed;
@ -4178,6 +4281,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
parsed = parsed.replaceAll("<underline>", UNDERLINE.toString());
parsed = parsed.replaceAll("<strike>", STRIKETHROUGH.toString());
parsed = parsed.replaceAll("<reset>", RESET.toString());
parsed = parsed.replaceAll("<br>", "\n");
parsed = ChatColor.translateAlternateColorCodes('&', parsed);
return parsed;
@ -5022,12 +5128,15 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
public boolean hasQuest(NPC npc, Quester quester) {
for (Quest quest : quests) {
for (Quest q : quests) {
if (quest.npcStart != null && quester.completedQuests.contains(quest.name) == false) {
if (q.npcStart != null && quester.completedQuests.contains(q.name) == false) {
if (quest.npcStart.getId() == npc.getId()) {
return true;
if (q.npcStart.getId() == npc.getId()) {
if(ignoreLockedQuests == false || ignoreLockedQuests == true && q.testRequirements(quester) == true) {
return true;
}
}
}
@ -5179,6 +5288,19 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
final FileConfiguration config = new YamlConfiguration();
config.load(found);
if(config.contains("currentQuest")) {
LinkedList<String> currentQuests = new LinkedList<String>();
currentQuests.add(config.getString("currentQuest"));
LinkedList<Integer> currentStages = new LinkedList<Integer>();
currentStages.add(config.getInt("currentStage"));
config.set("currentQuests", currentQuests);
config.set("currentStages", currentStages);
}
config.save(copy);
found.delete();

View File

@ -38,17 +38,19 @@ public class StageTimer implements Runnable {
} else {
quester.resetObjectives(quest);
Stage currentStage = quester.getCurrentStage(quest);
int stageNum = quester.currentQuests.get(quest) + 1;
quester.hardQuit(quest);
if (quester.getCurrentStage(quest).script != null) {
plugin.trigger.parseQuestTaskTrigger(quester.getCurrentStage(quest).script, player);
if (currentStage.script != null) {
plugin.trigger.parseQuestTaskTrigger(currentStage.script, player);
}
if (quester.getCurrentStage(quest).finishEvent != null) {
quester.getCurrentStage(quest).finishEvent.fire(quester, quest);
if (currentStage.finishEvent != null) {
currentStage.finishEvent.fire(quester, quest);
}
quester.setCurrentStage(quest, quester.currentQuests.get(quest) + 1);
quester.hardStagePut(quest, stageNum);
quester.addEmpties(quest);
quester.getQuestData(quest).delayStartTime = 0;
quester.getQuestData(quest).delayTimeLeft = -1;
@ -71,6 +73,7 @@ public class StageTimer implements Runnable {
}
quester.getQuestData(quest).delayOver = true;
quester.updateJournal();
}

View File

@ -7,6 +7,8 @@ COMMAND_QUESTADMIN_SETSTAGE_HELP
COMMAND_QUESTADMIN_SETSTAGE_USAGE
COMMAND_QUESTADMIN_QUIT_HELP
questsUnknownAdminCommand
currentQuest
noCurrentQuest
noActiveQuest
@ -23,8 +25,11 @@ COMMAND_JOURNAL
COMMAND_JOURNAL_HELP
questMaxAllowed
questAlreadyOn
questsPlayerHasQuestAlready
journalTitle
journalTaken
journalPutAway
journalAlreadyHave
journalNoRoom
journalNoRoom
usage

View File

@ -377,7 +377,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil {
if (input.equalsIgnoreCase(Lang.get("cmdClear")) == false && input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
Enchantment e = Quests.getEnchantment(input);
Enchantment e = Quests.getEnchantmentPretty(input);
if (e != null) {
cc.setSessionData("tempEnchant", e);
@ -441,7 +441,6 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil {
} catch (NumberFormatException e) {
cc.getForWhom().sendRawMessage(RED + Lang.get("itemCreateNotNumber"));
e.printStackTrace();
return new LevelPrompt(enchantment);
}

View File

@ -5,6 +5,7 @@ import java.util.Map.Entry;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -211,6 +212,18 @@ public class ItemUtil implements ColorUtil {
}
public static boolean isItem(ItemStack is) {
if(is == null)
return false;
if(is.getType().equals(Material.AIR))
return false;
return true;
}
public static boolean isJournal(ItemStack is) {
if(is == null)

View File

@ -42,9 +42,23 @@ public class Lang {
}
return null;
return "NULL";
}
public static String getCommandKey(String val) {
for (Entry<String, String> entry : langMap.entrySet()) {
if (entry.getValue().equalsIgnoreCase(val) && entry.getKey().toUpperCase().startsWith("COMMAND_")) {
return entry.getKey();
}
}
return "NULL";
}
public static void clearPhrases() {
langMap.clear();
@ -72,6 +86,7 @@ public class Lang {
//Quests
langMap.put("questFailed", "*QUEST FAILED*");
langMap.put("questMaxAllowed", "You may only have up to <number> Quests.");
langMap.put("questAlreadyOn", "You are already on that Quest!");
langMap.put("questTooEarly", "You may not take <quest> again for another <time>.");
langMap.put("questAlreadyCompleted", "You have already completed <quest>.");
langMap.put("questInvalidLocation", "You may not take <quest> at this location.");
@ -921,7 +936,8 @@ public class Lang {
langMap.put("errorReading", "Error reading <file>, skipping..");
langMap.put("errorReadingSuppress", "Error reading <file>, suppressing further errors.");
langMap.put("errorDataFolder", "Error: Unable to read Quests data folder!");
langMap.put("questsUnknownAdminCommand", "Unknown Quests command. Type /quests for help.");
langMap.put("questsPlayerHasQuestAlready", "<player> is already on the Quest <quest>!");
langMap.put("questsUnknownAdminCommand", "Unknown Questsadmin command. Type /questsadmin for help.");
langMap.put("unknownError", "An unknown error occurred. See console output.");
langMap.put("journalTaken", "You take out your Quest Journal.");
@ -1024,6 +1040,7 @@ public class Lang {
langMap.put("questPoints", "Quest Points");
langMap.put("complete", "Complete");
langMap.put("redoable", "Redoable");
langMap.put("usage", "Usage");
langMap.put("redoableEvery", "Redoable every <time>.");
langMap.put("requirements", "Requirements");
langMap.put("money", "Money");

View File

@ -1,9 +1,7 @@
package me.blackvein.quests.util;
import me.blackvein.quests.Quester;
import org.bukkit.Bukkit;
import java.util.LinkedList;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
public class MiscUtil {
@ -137,5 +135,32 @@ public class MiscUtil {
return s.trim().equals("") ? null : s.trim();
}
public static LinkedList<String> makeLines(String s, String wordDelimiter, int lineLength) {
LinkedList<String> toReturn = new LinkedList<String>();
String[] split = s.split(wordDelimiter);
String line = "";
int currentLength = 0;
for (String piece : split) {
if ((currentLength + piece.length()) > (lineLength + 1)) {
toReturn.add(line.replaceAll("^" + wordDelimiter, ""));
line = piece + wordDelimiter;
currentLength = piece.length() + 1;
} else {
line += piece + wordDelimiter;
currentLength += piece.length() + 1;
}
}
if(line.equals("") == false)
toReturn.add(line);
return toReturn;
}
}

View File

@ -1,11 +1,11 @@
name: Quests
main: me.blackvein.quests.Quests
version: 1.9.0
version: 2.0.0
description: Player questing system
website: http://dev.bukkit.org/server-mods/quests/
dev-url: https://github.com/Blackvein/Quests/
authors: [Blackvein]
soft-depend: [Citizens, Vault]
softdepend: [Citizens, Vault]
permissions:
quests.quest:
description: View current Quest objectives