Fix delays breaking reach-location objectives, fixes #505

This commit is contained in:
HappyPikachu 2018-11-07 02:22:56 -05:00
parent 441cd7ef28
commit 81a6c7a772
2 changed files with 28 additions and 24 deletions

View File

@ -414,28 +414,32 @@ public class Quester {
msg = msg.replace("<quest>", q.name);
getPlayer().sendMessage(ChatColor.GOLD + msg);
for (String s : getObjectivesReal(q)) {
// 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);
} else if (Material.matchMaterial(serial) != null) {
Material m = Material.matchMaterial(serial);
plugin.query.sendMessage(player, s.replace(serial, "<item>"), m);
} else if (EntityType.valueOf(serial.toUpperCase().replace(" ", "_")) != null) {
EntityType type = EntityType.valueOf(serial.toUpperCase().replace(" ", "_"));
plugin.query.sendMessage(player, s.replace(serial, "<mob>"), type);
} else {
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);
} else if (Material.matchMaterial(serial) != null) {
Material m = Material.matchMaterial(serial);
plugin.query.sendMessage(player, s.replace(serial, "<item>"), m);
} else if (EntityType.valueOf(serial.toUpperCase().replace(" ", "_")) != null) {
EntityType type = EntityType.valueOf(serial.toUpperCase().replace(" ", "_"));
plugin.query.sendMessage(player, s.replace(serial, "<mob>"), type);
} else {
player.sendMessage(s);
}
} catch (IndexOutOfBoundsException e) {
player.sendMessage(s);
}
}

View File

@ -53,12 +53,12 @@ public class StageTimer implements Runnable {
}
quester.hardStagePut(quest, stageNum);
quester.addEmptiesFor(quest, 0);
quester.getCurrentStage(quest).delay = -1; // Line added to fix Github issue #505
quester.getQuestData(quest).delayStartTime = 0;
quester.getQuestData(quest).delayTimeLeft = -1;
String msg = Lang.get(player, "questObjectivesTitle");
msg = msg.replaceAll("<quest>", quest.name);
msg = msg.replace("<quest>", quest.name);
player.sendMessage(ChatColor.GOLD + msg);
player.sendMessage(ChatColor.GOLD + Lang.get(player, "questObjectivesTitle"));
for (String s : quester.getObjectivesReal(quest)) {
player.sendMessage(s);
}