mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-18 15:18:34 +01:00
Fix stages not working after delay, fixes #289
This commit is contained in:
parent
1842396473
commit
0919a84dac
@ -1061,6 +1061,8 @@ public class Quester {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (questData.mobsKilled.contains(e) == false) {
|
if (questData.mobsKilled.contains(e) == false) {
|
||||||
|
for (EntityType ee : questData.mobsKilled) {
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Stage currentStage = getCurrentStage(quest);
|
Stage currentStage = getCurrentStage(quest);
|
||||||
@ -2444,6 +2446,10 @@ public class Quester {
|
|||||||
getQuestData(quest).delayStartTime = System.currentTimeMillis();
|
getQuestData(quest).delayStartTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pause the stage timer. Useful when a player quits
|
||||||
|
* @param quest The quest of which the timer is for
|
||||||
|
*/
|
||||||
public void stopStageTimer(Quest quest) {
|
public void stopStageTimer(Quest quest) {
|
||||||
if (getQuestData(quest).delayTimeLeft > -1) {
|
if (getQuestData(quest).delayTimeLeft > -1) {
|
||||||
getQuestData(quest).delayTimeLeft = getQuestData(quest).delayTimeLeft - (System.currentTimeMillis() - getQuestData(quest).delayStartTime);
|
getQuestData(quest).delayTimeLeft = getQuestData(quest).delayTimeLeft - (System.currentTimeMillis() - getQuestData(quest).delayStartTime);
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
package me.blackvein.quests;
|
package me.blackvein.quests;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import me.blackvein.quests.util.Lang;
|
import me.blackvein.quests.util.Lang;
|
||||||
@ -29,6 +32,7 @@ public class StageTimer implements Runnable {
|
|||||||
plugin = quests;
|
plugin = quests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (quester.getQuestData(quest).delayOver) {
|
if (quester.getQuestData(quest).delayOver) {
|
||||||
@ -52,7 +56,7 @@ public class StageTimer implements Runnable {
|
|||||||
currentStage.finishEvent.fire(quester, quest);
|
currentStage.finishEvent.fire(quester, quest);
|
||||||
}
|
}
|
||||||
quester.hardStagePut(quest, stageNum);
|
quester.hardStagePut(quest, stageNum);
|
||||||
quester.addEmptiesFor(quest, 0);
|
quester.addEmptiesFor(quest, stageNum);
|
||||||
quester.getCurrentStage(quest).delay = -1; // Line added to fix Github issue #505
|
quester.getCurrentStage(quest).delay = -1; // Line added to fix Github issue #505
|
||||||
quester.getQuestData(quest).delayStartTime = 0;
|
quester.getQuestData(quest).delayStartTime = 0;
|
||||||
quester.getQuestData(quest).delayTimeLeft = -1;
|
quester.getQuestData(quest).delayTimeLeft = -1;
|
||||||
@ -60,8 +64,39 @@ public class StageTimer implements Runnable {
|
|||||||
msg = msg.replace("<quest>", quest.name);
|
msg = msg.replace("<quest>", quest.name);
|
||||||
player.sendMessage(ChatColor.GOLD + msg);
|
player.sendMessage(ChatColor.GOLD + msg);
|
||||||
for (String s : quester.getObjectivesReal(quest)) {
|
for (String s : quester.getObjectivesReal(quest)) {
|
||||||
|
try {
|
||||||
|
// TODO ensure all applicable strings are translated
|
||||||
|
String sbegin = s.substring(s.indexOf(ChatColor.AQUA.toString()) + 2);
|
||||||
|
String serial = sbegin.substring(0, sbegin.indexOf(ChatColor.GREEN.toString()));
|
||||||
|
|
||||||
|
String enchant = "";
|
||||||
|
if (s.contains(ChatColor.LIGHT_PURPLE.toString())) {
|
||||||
|
String ebegin = s.substring(s.indexOf(ChatColor.LIGHT_PURPLE.toString()) + 2);
|
||||||
|
enchant = ebegin.substring(0, ebegin.indexOf(ChatColor.GREEN.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Order is important
|
||||||
|
if (Enchantment.getByName(Lang.getKey(enchant).replace("ENCHANTMENT_", "")) != null) {
|
||||||
|
Material m = Material.matchMaterial(serial);
|
||||||
|
Enchantment e = Enchantment.getByName(Lang.getKey(enchant).replace("ENCHANTMENT_", ""));
|
||||||
|
plugin.query.sendMessage(player, s.replace(serial, "<item>").replace(enchant, "<enchantment>"), m, e);
|
||||||
|
continue;
|
||||||
|
} else if (Material.matchMaterial(serial) != null) {
|
||||||
|
Material m = Material.matchMaterial(serial);
|
||||||
|
plugin.query.sendMessage(player, s.replace(serial, "<item>"), m);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
EntityType type = EntityType.valueOf(serial.toUpperCase().replace(" ", "_"));
|
||||||
|
plugin.query.sendMessage(player, s.replace(serial, "<mob>"), type);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
player.sendMessage(s);
|
player.sendMessage(s);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
player.sendMessage(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
String stageStartMessage = quester.getCurrentStage(quest).startMessage;
|
String stageStartMessage = quester.getCurrentStage(quest).startMessage;
|
||||||
if (stageStartMessage != null) {
|
if (stageStartMessage != null) {
|
||||||
quester.getPlayer().sendMessage(Quests.parseString(stageStartMessage, quest));
|
quester.getPlayer().sendMessage(Quests.parseString(stageStartMessage, quest));
|
||||||
|
Loading…
Reference in New Issue
Block a user