mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-18 07:07:40 +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;
|
||||
}
|
||||
if (questData.mobsKilled.contains(e) == false) {
|
||||
for (EntityType ee : questData.mobsKilled) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
Stage currentStage = getCurrentStage(quest);
|
||||
@ -2443,7 +2445,11 @@ public class Quester {
|
||||
}
|
||||
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) {
|
||||
if (getQuestData(quest).delayTimeLeft > -1) {
|
||||
getQuestData(quest).delayTimeLeft = getQuestData(quest).delayTimeLeft - (System.currentTimeMillis() - getQuestData(quest).delayStartTime);
|
||||
|
@ -13,6 +13,9 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.blackvein.quests.util.Lang;
|
||||
@ -29,6 +32,7 @@ public class StageTimer implements Runnable {
|
||||
plugin = quests;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void run() {
|
||||
if (quester.getQuestData(quest).delayOver) {
|
||||
@ -52,7 +56,7 @@ public class StageTimer implements Runnable {
|
||||
currentStage.finishEvent.fire(quester, quest);
|
||||
}
|
||||
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.getQuestData(quest).delayStartTime = 0;
|
||||
quester.getQuestData(quest).delayTimeLeft = -1;
|
||||
@ -60,7 +64,38 @@ public class StageTimer implements Runnable {
|
||||
msg = msg.replace("<quest>", quest.name);
|
||||
player.sendMessage(ChatColor.GOLD + msg);
|
||||
for (String s : quester.getObjectivesReal(quest)) {
|
||||
player.sendMessage(s);
|
||||
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);
|
||||
}
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
player.sendMessage(s);
|
||||
}
|
||||
}
|
||||
String stageStartMessage = quester.getCurrentStage(quest).startMessage;
|
||||
if (stageStartMessage != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user