mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-23 00:31:36 +01:00
Merge pull request #248 from elBukkit/master
Quests Compass, Several Bug Fixes
This commit is contained in:
commit
f6fecf529d
2
pom.xml
2
pom.xml
@ -127,7 +127,7 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>Quests-${project.version}-b${env.BUILD_NUMBER}</finalName>
|
||||
<finalName>Quests-${project.version}</finalName>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
|
@ -85,11 +85,14 @@ public abstract class CustomObjective implements Listener {
|
||||
|
||||
Quester quester = Quests.getInstance().getQuester(player.getUniqueId());
|
||||
if (quester != null) {
|
||||
Stage currentStage = quester.getCurrentStage(quest);
|
||||
if (currentStage == null) return null;
|
||||
|
||||
int index = -1;
|
||||
int tempIndex = 0;
|
||||
|
||||
for (me.blackvein.quests.CustomObjective co : quester.getCurrentStage(quest).customObjectives) {
|
||||
|
||||
for (me.blackvein.quests.CustomObjective co : currentStage.customObjectives) {
|
||||
|
||||
if (co.getName().equals(obj.getName())) {
|
||||
index = tempIndex;
|
||||
@ -102,7 +105,7 @@ public abstract class CustomObjective implements Listener {
|
||||
|
||||
if (index > -1) {
|
||||
|
||||
return quester.getCurrentStage(quest).customObjectiveData.get(index);
|
||||
return currentStage.customObjectiveData.get(index);
|
||||
|
||||
}
|
||||
|
||||
|
@ -812,7 +812,8 @@ public class PlayerListener implements Listener, ColorUtil {
|
||||
|
||||
for (Quest quest : quester.currentQuests.keySet()) {
|
||||
|
||||
if (quester.getCurrentStage(quest).deathEvent != null) {
|
||||
Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && stage.deathEvent != null) {
|
||||
quester.getCurrentStage(quest).deathEvent.fire(quester, quest);
|
||||
}
|
||||
|
||||
|
@ -89,6 +89,7 @@ public class Quest {
|
||||
if (stageCompleteMessage != null) {
|
||||
q.getPlayer().sendMessage(Quests.parseString(stageCompleteMessage, this));
|
||||
}
|
||||
resetCompass(q);
|
||||
|
||||
if (q.getCurrentStage(this).delay < 0) {
|
||||
|
||||
@ -128,7 +129,6 @@ public class Quest {
|
||||
}
|
||||
|
||||
public void setStage(Quester quester, int stage) throws InvalidStageException {
|
||||
|
||||
if (orderedStages.size() - 1 < stage) {
|
||||
throw new InvalidStageException(this, stage);
|
||||
}
|
||||
@ -147,9 +147,11 @@ public class Quest {
|
||||
/*if (quester.getCurrentStage(this).finishEvent != null) {
|
||||
quester.getCurrentStage(this).finishEvent.fire(quester);
|
||||
}*/
|
||||
if (quester.getCurrentStage(this).startEvent != null) {
|
||||
quester.getCurrentStage(this).startEvent.fire(quester, this);
|
||||
Stage nextStage = quester.getCurrentStage(this);
|
||||
if (nextStage.startEvent != null) {
|
||||
nextStage.startEvent.fire(quester, this);
|
||||
}
|
||||
updateCompass(quester, nextStage);
|
||||
|
||||
String msg = Lang.get("questObjectivesTitle");
|
||||
msg = msg.replaceAll("<quest>", name);
|
||||
@ -169,6 +171,46 @@ public class Quest {
|
||||
|
||||
}
|
||||
|
||||
public void updateCompass(Quester quester, Stage nextStage)
|
||||
{
|
||||
if (!Quests.getInstance().useCompass) return;
|
||||
|
||||
Location targetLocation = null;
|
||||
if (nextStage == null) {
|
||||
resetCompass(quester);
|
||||
return;
|
||||
}
|
||||
if (nextStage.citizensToInteract != null && nextStage.citizensToInteract.size() > 0)
|
||||
{
|
||||
targetLocation = plugin.getNPCLocation(nextStage.citizensToInteract.getFirst());
|
||||
}
|
||||
else if (nextStage.citizensToKill != null && nextStage.citizensToKill.size() > 0)
|
||||
{
|
||||
targetLocation = plugin.getNPCLocation(nextStage.citizensToKill.getFirst());
|
||||
}
|
||||
else if (nextStage.locationsToReach != null && nextStage.locationsToReach.size() > 0)
|
||||
{
|
||||
targetLocation = nextStage.locationsToReach.getFirst();
|
||||
}
|
||||
if (targetLocation != null) {
|
||||
quester.getPlayer().setCompassTarget(targetLocation);
|
||||
} else {
|
||||
resetCompass(quester);
|
||||
}
|
||||
}
|
||||
|
||||
protected void resetCompass(Quester q) {
|
||||
if (!Quests.getInstance().useCompass) return;
|
||||
Player player = q.getPlayer();
|
||||
if (player == null) return;
|
||||
|
||||
Location defaultLocation = player.getBedSpawnLocation();
|
||||
if (defaultLocation == null) {
|
||||
defaultLocation = player.getWorld().getSpawnLocation();
|
||||
}
|
||||
player.setCompassTarget(defaultLocation);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -287,16 +329,21 @@ public class Quest {
|
||||
@SuppressWarnings("deprecation")
|
||||
public void completeQuest(Quester q) {
|
||||
|
||||
Player player = plugin.getServer().getPlayer(q.id);
|
||||
final Player player = plugin.getServer().getPlayer(q.id);
|
||||
q.hardQuit(this);
|
||||
q.completedQuests.add(name);
|
||||
String none = ChatColor.GRAY + "- (" + Lang.get("none") + ")";
|
||||
|
||||
String ps = Quests.parseString(finished, this);
|
||||
final String ps = Quests.parseString(finished, this);
|
||||
|
||||
for (String msg : ps.split("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
org.bukkit.Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (String msg : ps.split("<br>")) {
|
||||
player.sendMessage(ChatColor.AQUA + msg);
|
||||
}
|
||||
}
|
||||
}, 40);
|
||||
|
||||
if (moneyReward > 0 && Quests.economy != null) {
|
||||
Quests.economy.depositPlayer(q.getOfflinePlayer(), moneyReward);
|
||||
|
@ -1230,6 +1230,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
|
||||
if (cc.getSessionData(CK.Q_GUIDISPLAY) != null) {
|
||||
guiDisplay = (ItemStack) cc.getSessionData(CK.Q_GUIDISPLAY);
|
||||
guiDisplay = new ItemStack(guiDisplay.getType());
|
||||
}
|
||||
|
||||
if (cc.getSessionData(CK.REW_MONEY) != null) {
|
||||
|
@ -394,6 +394,7 @@ public class Quester {
|
||||
if (stage.startEvent != null) {
|
||||
stage.startEvent.fire(this, q);
|
||||
}
|
||||
q.updateCompass(this, stage);
|
||||
|
||||
saveData();
|
||||
|
||||
@ -2086,15 +2087,17 @@ public class Quester {
|
||||
for (Quest quest : currentQuests.keySet()) {
|
||||
|
||||
ConfigurationSection questSec = dataSec.createSection(quest.name);
|
||||
QuestData questData = getQuestData(quest);
|
||||
if (questData == null) continue;
|
||||
|
||||
if (getQuestData(quest).blocksDamaged.isEmpty() == false) {
|
||||
if (questData.blocksDamaged.isEmpty() == false) {
|
||||
|
||||
LinkedList<String> blockNames = new LinkedList<String>();
|
||||
LinkedList<Integer> blockAmounts = new LinkedList<Integer>();
|
||||
|
||||
for (Material m : getQuestData(quest).blocksDamaged.keySet()) {
|
||||
for (Material m : questData.blocksDamaged.keySet()) {
|
||||
blockNames.add(m.name());
|
||||
blockAmounts.add(getQuestData(quest).blocksDamaged.get(m));
|
||||
blockAmounts.add(questData.blocksDamaged.get(m));
|
||||
}
|
||||
|
||||
questSec.set("blocks-damaged-names", blockNames);
|
||||
@ -2102,14 +2105,14 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).blocksBroken.isEmpty() == false) {
|
||||
if (questData.blocksBroken.isEmpty() == false) {
|
||||
|
||||
LinkedList<String> blockNames = new LinkedList<String>();
|
||||
LinkedList<Integer> blockAmounts = new LinkedList<Integer>();
|
||||
|
||||
for (Material m : getQuestData(quest).blocksBroken.keySet()) {
|
||||
for (Material m : questData.blocksBroken.keySet()) {
|
||||
blockNames.add(m.name());
|
||||
blockAmounts.add(getQuestData(quest).blocksBroken.get(m));
|
||||
blockAmounts.add(questData.blocksBroken.get(m));
|
||||
}
|
||||
|
||||
questSec.set("blocks-broken-names", blockNames);
|
||||
@ -2117,14 +2120,14 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).blocksPlaced.isEmpty() == false) {
|
||||
if (questData.blocksPlaced.isEmpty() == false) {
|
||||
|
||||
LinkedList<String> blockNames = new LinkedList<String>();
|
||||
LinkedList<Integer> blockAmounts = new LinkedList<Integer>();
|
||||
|
||||
for (Material m : getQuestData(quest).blocksPlaced.keySet()) {
|
||||
for (Material m : questData.blocksPlaced.keySet()) {
|
||||
blockNames.add(m.name());
|
||||
blockAmounts.add(getQuestData(quest).blocksPlaced.get(m));
|
||||
blockAmounts.add(questData.blocksPlaced.get(m));
|
||||
}
|
||||
|
||||
questSec.set("blocks-placed-names", blockNames);
|
||||
@ -2132,14 +2135,14 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).blocksUsed.isEmpty() == false) {
|
||||
if (questData.blocksUsed.isEmpty() == false) {
|
||||
|
||||
LinkedList<String> blockNames = new LinkedList<String>();
|
||||
LinkedList<Integer> blockAmounts = new LinkedList<Integer>();
|
||||
|
||||
for (Material m : getQuestData(quest).blocksUsed.keySet()) {
|
||||
for (Material m : questData.blocksUsed.keySet()) {
|
||||
blockNames.add(m.name());
|
||||
blockAmounts.add(getQuestData(quest).blocksUsed.get(m));
|
||||
blockAmounts.add(questData.blocksUsed.get(m));
|
||||
}
|
||||
|
||||
questSec.set("blocks-used-names", blockNames);
|
||||
@ -2147,14 +2150,14 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).blocksCut.isEmpty() == false) {
|
||||
if (questData.blocksCut.isEmpty() == false) {
|
||||
|
||||
LinkedList<String> blockNames = new LinkedList<String>();
|
||||
LinkedList<Integer> blockAmounts = new LinkedList<Integer>();
|
||||
|
||||
for (Material m : getQuestData(quest).blocksCut.keySet()) {
|
||||
for (Material m : questData.blocksCut.keySet()) {
|
||||
blockNames.add(m.name());
|
||||
blockAmounts.add(getQuestData(quest).blocksCut.get(m));
|
||||
blockAmounts.add(questData.blocksCut.get(m));
|
||||
}
|
||||
|
||||
questSec.set("blocks-cut-names", blockNames);
|
||||
@ -2163,23 +2166,23 @@ public class Quester {
|
||||
}
|
||||
|
||||
if (getCurrentStage(quest).fishToCatch != null) {
|
||||
questSec.set("fish-caught", getQuestData(quest).getFishCaught());
|
||||
questSec.set("fish-caught", questData.getFishCaught());
|
||||
}
|
||||
|
||||
if (getCurrentStage(quest).playersToKill != null) {
|
||||
questSec.set("players-killed", getQuestData(quest).getPlayersKilled());
|
||||
questSec.set("players-killed", questData.getPlayersKilled());
|
||||
}
|
||||
|
||||
if (getQuestData(quest).itemsEnchanted.isEmpty() == false) {
|
||||
if (questData.itemsEnchanted.isEmpty() == false) {
|
||||
|
||||
LinkedList<String> enchantments = new LinkedList<String>();
|
||||
LinkedList<String> itemNames = new LinkedList<String>();
|
||||
LinkedList<Integer> enchAmounts = new LinkedList<Integer>();
|
||||
|
||||
for (Entry<Map<Enchantment, Material>, Integer> e : getQuestData(quest).itemsEnchanted.entrySet()) {
|
||||
for (Entry<Map<Enchantment, Material>, Integer> e : questData.itemsEnchanted.entrySet()) {
|
||||
|
||||
Map<Enchantment, Material> enchMap = (Map<Enchantment, Material>) e.getKey();
|
||||
enchAmounts.add(getQuestData(quest).itemsEnchanted.get(enchMap));
|
||||
enchAmounts.add(questData.itemsEnchanted.get(enchMap));
|
||||
for (Entry<Enchantment, Material> e2 : enchMap.entrySet()) {
|
||||
|
||||
enchantments.add(Quester.prettyEnchantmentString((Enchantment) e2.getKey()));
|
||||
@ -2195,20 +2198,20 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).mobsKilled.isEmpty() == false) {
|
||||
if (questData.mobsKilled.isEmpty() == false) {
|
||||
|
||||
LinkedList<String> mobNames = new LinkedList<String>();
|
||||
LinkedList<Integer> mobAmounts = new LinkedList<Integer>();
|
||||
LinkedList<String> locations = new LinkedList<String>();
|
||||
LinkedList<Integer> radii = new LinkedList<Integer>();
|
||||
|
||||
for (EntityType e : getQuestData(quest).mobsKilled) {
|
||||
for (EntityType e : questData.mobsKilled) {
|
||||
|
||||
mobNames.add(Quester.prettyMobString(e));
|
||||
|
||||
}
|
||||
|
||||
for (int i : getQuestData(quest).mobNumKilled) {
|
||||
for (int i : questData.mobNumKilled) {
|
||||
|
||||
mobAmounts.add(i);
|
||||
|
||||
@ -2217,15 +2220,15 @@ public class Quester {
|
||||
questSec.set("mobs-killed", mobNames);
|
||||
questSec.set("mobs-killed-amounts", mobAmounts);
|
||||
|
||||
if (getQuestData(quest).locationsToKillWithin.isEmpty() == false) {
|
||||
if (questData.locationsToKillWithin.isEmpty() == false) {
|
||||
|
||||
for (Location l : getQuestData(quest).locationsToKillWithin) {
|
||||
for (Location l : questData.locationsToKillWithin) {
|
||||
|
||||
locations.add(l.getWorld().getName() + " " + l.getX() + " " + l.getY() + " " + l.getZ());
|
||||
|
||||
}
|
||||
|
||||
for (int i : getQuestData(quest).radiiToKillWithin) {
|
||||
for (int i : questData.radiiToKillWithin) {
|
||||
|
||||
radii.add(i);
|
||||
|
||||
@ -2238,11 +2241,11 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).itemsDelivered.isEmpty() == false) {
|
||||
if (questData.itemsDelivered.isEmpty() == false) {
|
||||
|
||||
LinkedList<Integer> deliveryAmounts = new LinkedList<Integer>();
|
||||
|
||||
for (Entry<ItemStack, Integer> e : getQuestData(quest).itemsDelivered.entrySet()) {
|
||||
for (Entry<ItemStack, Integer> e : questData.itemsDelivered.entrySet()) {
|
||||
|
||||
deliveryAmounts.add(e.getValue());
|
||||
|
||||
@ -2252,15 +2255,15 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).citizensInteracted.isEmpty() == false) {
|
||||
if (questData.citizensInteracted.isEmpty() == false) {
|
||||
|
||||
LinkedList<Integer> npcIds = new LinkedList<Integer>();
|
||||
LinkedList<Boolean> hasTalked = new LinkedList<Boolean>();
|
||||
|
||||
for (Integer n : getQuestData(quest).citizensInteracted.keySet()) {
|
||||
for (Integer n : questData.citizensInteracted.keySet()) {
|
||||
|
||||
npcIds.add(n);
|
||||
hasTalked.add(getQuestData(quest).citizensInteracted.get(n));
|
||||
hasTalked.add(questData.citizensInteracted.get(n));
|
||||
|
||||
}
|
||||
|
||||
@ -2269,38 +2272,38 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).citizensKilled.isEmpty() == false) {
|
||||
if (questData.citizensKilled.isEmpty() == false) {
|
||||
|
||||
LinkedList<Integer> npcIds = new LinkedList<Integer>();
|
||||
|
||||
for (Integer n : getQuestData(quest).citizensKilled) {
|
||||
for (Integer n : questData.citizensKilled) {
|
||||
|
||||
npcIds.add(n);
|
||||
|
||||
}
|
||||
|
||||
questSec.set("citizen-ids-killed", npcIds);
|
||||
questSec.set("citizen-amounts-killed", getQuestData(quest).citizenNumKilled);
|
||||
questSec.set("citizen-amounts-killed", questData.citizenNumKilled);
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).locationsReached.isEmpty() == false) {
|
||||
if (questData.locationsReached.isEmpty() == false) {
|
||||
|
||||
LinkedList<String> locations = new LinkedList<String>();
|
||||
LinkedList<Boolean> has = new LinkedList<Boolean>();
|
||||
LinkedList<Integer> radii = new LinkedList<Integer>();
|
||||
|
||||
for (Location l : getQuestData(quest).locationsReached) {
|
||||
for (Location l : questData.locationsReached) {
|
||||
|
||||
locations.add(l.getWorld().getName() + " " + l.getX() + " " + l.getY() + " " + l.getZ());
|
||||
|
||||
}
|
||||
|
||||
for (boolean b : getQuestData(quest).hasReached) {
|
||||
for (boolean b : questData.hasReached) {
|
||||
has.add(b);
|
||||
}
|
||||
|
||||
for (int i : getQuestData(quest).radiiToReachWithin) {
|
||||
for (int i : questData.radiiToReachWithin) {
|
||||
radii.add(i);
|
||||
}
|
||||
|
||||
@ -2310,12 +2313,12 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).potionsBrewed.isEmpty() == false) {
|
||||
if (questData.potionsBrewed.isEmpty() == false) {
|
||||
|
||||
LinkedList<String> potionNames = new LinkedList<String>();
|
||||
LinkedList<Integer> potionAmounts = new LinkedList<Integer>();
|
||||
|
||||
for (Entry<String, Integer> entry : getQuestData(quest).potionsBrewed.entrySet()) {
|
||||
for (Entry<String, Integer> entry : questData.potionsBrewed.entrySet()) {
|
||||
|
||||
potionNames.add(entry.getKey());
|
||||
potionAmounts.add(entry.getValue());
|
||||
@ -2327,15 +2330,15 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).mobsTamed.isEmpty() == false) {
|
||||
if (questData.mobsTamed.isEmpty() == false) {
|
||||
|
||||
LinkedList<String> mobNames = new LinkedList<String>();
|
||||
LinkedList<Integer> mobAmounts = new LinkedList<Integer>();
|
||||
|
||||
for (EntityType e : getQuestData(quest).mobsTamed.keySet()) {
|
||||
for (EntityType e : questData.mobsTamed.keySet()) {
|
||||
|
||||
mobNames.add(Quester.prettyMobString(e));
|
||||
mobAmounts.add(getQuestData(quest).mobsTamed.get(e));
|
||||
mobAmounts.add(questData.mobsTamed.get(e));
|
||||
|
||||
}
|
||||
|
||||
@ -2344,15 +2347,15 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).sheepSheared.isEmpty() == false) {
|
||||
if (questData.sheepSheared.isEmpty() == false) {
|
||||
|
||||
LinkedList<String> colors = new LinkedList<String>();
|
||||
LinkedList<Integer> shearAmounts = new LinkedList<Integer>();
|
||||
|
||||
for (DyeColor d : getQuestData(quest).sheepSheared.keySet()) {
|
||||
for (DyeColor d : questData.sheepSheared.keySet()) {
|
||||
|
||||
colors.add(Quester.prettyColorString(d));
|
||||
shearAmounts.add(getQuestData(quest).sheepSheared.get(d));
|
||||
shearAmounts.add(questData.sheepSheared.get(d));
|
||||
|
||||
}
|
||||
|
||||
@ -2361,12 +2364,12 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).passwordsSaid.isEmpty() == false) {
|
||||
if (questData.passwordsSaid.isEmpty() == false) {
|
||||
|
||||
LinkedList<String> passwords = new LinkedList<String>();
|
||||
LinkedList<Boolean> said = new LinkedList<Boolean>();
|
||||
|
||||
for (Entry<String, Boolean> entry : getQuestData(quest).passwordsSaid.entrySet()) {
|
||||
for (Entry<String, Boolean> entry : questData.passwordsSaid.entrySet()) {
|
||||
|
||||
passwords.add(entry.getKey());
|
||||
said.add(entry.getValue());
|
||||
@ -2378,12 +2381,12 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).customObjectiveCounts.isEmpty() == false) {
|
||||
if (questData.customObjectiveCounts.isEmpty() == false) {
|
||||
|
||||
LinkedList<String> customObj = new LinkedList<String>();
|
||||
LinkedList<Integer> customObjCounts = new LinkedList<Integer>();
|
||||
|
||||
for (Entry<String, Integer> entry : getQuestData(quest).customObjectiveCounts.entrySet()) {
|
||||
for (Entry<String, Integer> entry : questData.customObjectiveCounts.entrySet()) {
|
||||
|
||||
customObj.add(entry.getKey());
|
||||
customObjCounts.add(entry.getValue());
|
||||
@ -2395,16 +2398,16 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
if (getQuestData(quest).delayTimeLeft > 0) {
|
||||
questSec.set("stage-delay", getQuestData(quest).delayTimeLeft);
|
||||
if (questData.delayTimeLeft > 0) {
|
||||
questSec.set("stage-delay", questData.delayTimeLeft);
|
||||
}
|
||||
|
||||
if (getQuestData(quest).eventFired.isEmpty() == false) {
|
||||
if (questData.eventFired.isEmpty() == false) {
|
||||
|
||||
LinkedList<String> triggers = new LinkedList<String>();
|
||||
for (String trigger : getQuestData(quest).eventFired.keySet()) {
|
||||
for (String trigger : questData.eventFired.keySet()) {
|
||||
|
||||
if (getQuestData(quest).eventFired.get(trigger) == true) {
|
||||
if (questData.eventFired.get(trigger) == true) {
|
||||
triggers.add(trigger);
|
||||
}
|
||||
|
||||
@ -2575,7 +2578,10 @@ public class Quester {
|
||||
List<String> questNames = data.getStringList("currentQuests");
|
||||
List<Integer> questStages = data.getIntegerList("currentStages");
|
||||
|
||||
for (int i = 0; i < questNames.size(); i++) {
|
||||
// These appear to differ sometimes? That seems bad.
|
||||
int maxSize = Math.min(questNames.size(), questStages.size());
|
||||
|
||||
for (int i = 0; i < maxSize; i++) {
|
||||
if (plugin.getQuest(questNames.get(i)) != null) {
|
||||
currentQuests.put(plugin.getQuest(questNames.get(i)), questStages.get(i));
|
||||
}
|
||||
@ -3219,10 +3225,13 @@ if (quest != null) {
|
||||
boolean exists = false;
|
||||
|
||||
for (Quest q : plugin.quests) {
|
||||
|
||||
if (q.name.equalsIgnoreCase(quest.name)) {
|
||||
|
||||
Stage stage = getCurrentStage(quest);
|
||||
quest.updateCompass(this, stage);
|
||||
exists = true;
|
||||
|
||||
// Meh, let's not.
|
||||
/*
|
||||
if (q.equals(quest) == false) {
|
||||
|
||||
hardQuit(quest);
|
||||
@ -3235,6 +3244,7 @@ if (quest != null) {
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
break;
|
||||
|
||||
|
@ -98,6 +98,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
public static Heroes heroes = null;
|
||||
public static PhatLoots phatLoots = null;
|
||||
public static boolean npcEffects = true;
|
||||
public static boolean useCompass = true;
|
||||
public static boolean ignoreLockedQuests = false;
|
||||
public static boolean genFilesOnJoin = true;
|
||||
public static int acceptTimeout = 20;
|
||||
@ -336,6 +337,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
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_PURGE"), 2); // purge [player]
|
||||
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_RESET"), 2); // purge [player]
|
||||
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_TOGGLEGUI"), 2); // togglegui [npc id]
|
||||
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_RELOAD"), 1); // reload
|
||||
|
||||
@ -532,6 +534,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
allowCommandsForNpcQuests = config.getBoolean("allow-command-quests-with-npcs", false);
|
||||
showQuestReqs = config.getBoolean("show-requirements", true);
|
||||
allowQuitting = config.getBoolean("allow-quitting", true);
|
||||
useCompass = config.getBoolean("use-compass", true);
|
||||
genFilesOnJoin = config.getBoolean("generate-files-on-join", true);
|
||||
npcEffects = config.getBoolean("show-npc-effects", true);
|
||||
effect = config.getString("npc-effect", "note");
|
||||
@ -847,6 +850,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
adminPurge(cs, args);
|
||||
|
||||
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_RESET"))) {
|
||||
|
||||
adminReset(cs, args);
|
||||
|
||||
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_STATS"))) {
|
||||
|
||||
adminStats(cs, args);
|
||||
@ -1582,6 +1589,53 @@ try{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void adminReset(final CommandSender cs, String[] args) {
|
||||
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reset")) {
|
||||
|
||||
Quester quester = getQuester(args[1]);
|
||||
|
||||
if (quester == null) {
|
||||
cs.sendMessage(YELLOW + Lang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
UUID id = quester.id;
|
||||
questers.remove(id);
|
||||
|
||||
try {
|
||||
quester.hardClear();
|
||||
quester.saveData();
|
||||
quester.updateJournal();
|
||||
final File dataFolder = new File(this.getDataFolder(), "data/");
|
||||
final File found = new File(dataFolder, id + ".yml");
|
||||
found.delete();
|
||||
|
||||
String msg = Lang.get("questReset");
|
||||
if (Bukkit.getOfflinePlayer(id).getName() != null) {
|
||||
msg = msg.replaceAll("<player>", GREEN + Bukkit.getOfflinePlayer(id).getName() + GOLD);
|
||||
} else {
|
||||
msg = msg.replaceAll("<player>", GREEN + args[1] + GOLD);
|
||||
}
|
||||
cs.sendMessage(GOLD + msg);
|
||||
cs.sendMessage(PURPLE + " UUID: " + DARKAQUA + id);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
getLogger().info("Data file does not exist for " + id.toString());
|
||||
}
|
||||
|
||||
quester = new Quester(this);
|
||||
quester.id = id;
|
||||
quester.saveData();
|
||||
questers.put(id, quester);
|
||||
|
||||
} else {
|
||||
|
||||
cs.sendMessage(RED + Lang.get("questCmdNoPerms"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void adminStats(final CommandSender cs, String[] args) {
|
||||
|
||||
@ -2492,6 +2546,7 @@ try{
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE_HELP"));
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_HELP"));
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_PURGE_HELP"));
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_RESET_HELP"));
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_REMOVE_HELP"));
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_TOGGLEGUI_HELP"));
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_RELOAD_HELP"));
|
||||
@ -2529,6 +2584,9 @@ try{
|
||||
if (cs.hasPermission("quests.admin.purge")) {
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_PURGE_HELP"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.reset")) {
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_RESET_HELP"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.remove")) {
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_REMOVE_HELP"));
|
||||
}
|
||||
@ -2560,7 +2618,7 @@ try{
|
||||
|
||||
if (numOrder > 1) {
|
||||
if (quests.size() >= (numOrder + 7)) {
|
||||
subQuests = quests.subList((numOrder), (numOrder + 8));
|
||||
subQuests = quests.subList((numOrder), (numOrder + 7));
|
||||
} else {
|
||||
subQuests = quests.subList((numOrder), quests.size());
|
||||
}
|
||||
@ -4979,6 +5037,12 @@ try{
|
||||
|
||||
}
|
||||
|
||||
public Location getNPCLocation(int id) {
|
||||
|
||||
return citizens.getNPCRegistry().getById(id).getStoredLocation();
|
||||
|
||||
}
|
||||
|
||||
public String getNPCName(int id) {
|
||||
|
||||
return citizens.getNPCRegistry().getById(id).getName();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.blackvein.quests.prompts;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
@ -95,7 +96,8 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil {
|
||||
|
||||
ItemMeta meta = is.getItemMeta();
|
||||
if (meta.hasDisplayName()) {
|
||||
cc.setSessionData("tempDisplay", ChatColor.stripColor(meta.getDisplayName()));
|
||||
String display = meta.getDisplayName().replace(ChatColor.COLOR_CHAR, '&');
|
||||
cc.setSessionData("tempDisplay", display);
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
@ -176,7 +178,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil {
|
||||
short data = -1;
|
||||
Map<Enchantment, Integer> enchs = null;
|
||||
String display = null;
|
||||
LinkedList<String> lore = null;
|
||||
List<String> lore = null;
|
||||
|
||||
if (cc.getSessionData("tempData") != null) {
|
||||
data = (Short) cc.getSessionData("tempData");
|
||||
@ -185,10 +187,15 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil {
|
||||
enchs = (Map<Enchantment, Integer>) cc.getSessionData("tempEnchantments");
|
||||
}
|
||||
if (cc.getSessionData("tempDisplay") != null) {
|
||||
display = (String) cc.getSessionData("tempDisplay");
|
||||
display = ChatColor.translateAlternateColorCodes('&', (String) cc.getSessionData("tempDisplay"));
|
||||
}
|
||||
if (cc.getSessionData("tempLore") != null) {
|
||||
lore = (LinkedList<String>) cc.getSessionData("tempLore");
|
||||
lore = new ArrayList<String>();
|
||||
LinkedList<String> loadedLore = (LinkedList<String>) cc.getSessionData("tempLore");
|
||||
for (String line : loadedLore)
|
||||
{
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack stack = new ItemStack(Material.matchMaterial(name), amount);
|
||||
|
@ -104,9 +104,9 @@ public class ItemUtil implements ColorUtil {
|
||||
Enchantment e = Quests.getEnchantment(enchs[0]);
|
||||
meta.addEnchant(e, Integer.parseInt(enchs[1]), true);
|
||||
} else if (arg.startsWith("displayname-")) {
|
||||
meta.setDisplayName(arg.substring(12));
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', arg.substring(12)));
|
||||
} else if (arg.startsWith("lore-")) {
|
||||
lore.add(arg.substring(5));
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', arg.substring(5)));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -162,7 +162,10 @@ public class Lang {
|
||||
langMap.put("COMMAND_QUESTADMIN_SETSTAGE_USAGE", "Usage: /questadmin setstage [player] [quest] [stage]");
|
||||
|
||||
langMap.put("COMMAND_QUESTADMIN_PURGE", "purge");
|
||||
langMap.put("COMMAND_QUESTADMIN_PURGE_HELP", "purge [player] - Clear all Quests data of a player");
|
||||
langMap.put("COMMAND_QUESTADMIN_PURGE_HELP", "purge [player] - Clear all Quests data of a player AND BLACKLISTS THEM");
|
||||
|
||||
langMap.put("COMMAND_QUESTADMIN_RESET", "reset");
|
||||
langMap.put("COMMAND_QUESTADMIN_RESET_HELP", "reset [player] - Clear all Quests data of a player");
|
||||
|
||||
langMap.put("COMMAND_QUESTADMIN_REMOVE", "remove");
|
||||
langMap.put("COMMAND_QUESTADMIN_REMOVE_HELP", "remove [player] [quest] - Remove a completed Quest from a player");
|
||||
@ -927,6 +930,7 @@ public class Lang {
|
||||
langMap.put("questForceNextStage", "<player> has advanced to the next Stage in the Quest <quest>.");
|
||||
langMap.put("questForcedNextStage", "<player> has advanced you to the next Stage in your Quest <quest>.");
|
||||
langMap.put("questPurged", "<player> has been purged and blacklisted.");
|
||||
langMap.put("questReset", "<player> has been reset.");
|
||||
langMap.put("questRemoved", "Quest <quest> has been removed from player <player>'s completed Quests.");
|
||||
langMap.put("settingAllQuestPoints", "Setting all players' Quest Points...");
|
||||
langMap.put("allQuestPointsSet", "All players' Quest Points have been set to <number>!");
|
||||
|
@ -3,6 +3,7 @@ allow-command-questing: true
|
||||
allow-command-quests-with-npcs: false
|
||||
show-requirements: true
|
||||
allow-quitting: true
|
||||
use-compass: true
|
||||
ignore-locked-quests: false
|
||||
debug-mode: false
|
||||
generate-files-on-join: true
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: Quests
|
||||
main: me.blackvein.quests.Quests
|
||||
version: ${project.version}-b${env.BUILD_NUMBER}
|
||||
version: ${project.version}
|
||||
description: Player questing system
|
||||
website: http://dev.bukkit.org/server-mods/quests/
|
||||
dev-url: https://github.com/Blackvein/Quests/
|
||||
@ -68,6 +68,9 @@ permissions:
|
||||
description: Immediately force Stage completion for a player
|
||||
default: op
|
||||
quests.admin.purge:
|
||||
description: Clear all Quests data of a player AND BLACKLISTS THEM
|
||||
default: op
|
||||
quests.admin.reset:
|
||||
description: Clear all Quests data of a player
|
||||
default: op
|
||||
quests.admin.remove:
|
||||
|
Loading…
Reference in New Issue
Block a user