diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java index 0738c2ce2..0e2276f91 100644 --- a/src/main/java/me/blackvein/quests/Quester.java +++ b/src/main/java/me/blackvein/quests/Quester.java @@ -414,28 +414,32 @@ public class Quester { msg = msg.replace("", 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, "").replace(enchant, ""), m, e); - } else if (Material.matchMaterial(serial) != null) { - Material m = Material.matchMaterial(serial); - plugin.query.sendMessage(player, s.replace(serial, ""), m); - } else if (EntityType.valueOf(serial.toUpperCase().replace(" ", "_")) != null) { - EntityType type = EntityType.valueOf(serial.toUpperCase().replace(" ", "_")); - plugin.query.sendMessage(player, s.replace(serial, ""), 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, "").replace(enchant, ""), m, e); + } else if (Material.matchMaterial(serial) != null) { + Material m = Material.matchMaterial(serial); + plugin.query.sendMessage(player, s.replace(serial, ""), m); + } else if (EntityType.valueOf(serial.toUpperCase().replace(" ", "_")) != null) { + EntityType type = EntityType.valueOf(serial.toUpperCase().replace(" ", "_")); + plugin.query.sendMessage(player, s.replace(serial, ""), type); + } else { + player.sendMessage(s); + } + } catch (IndexOutOfBoundsException e) { player.sendMessage(s); } } diff --git a/src/main/java/me/blackvein/quests/StageTimer.java b/src/main/java/me/blackvein/quests/StageTimer.java index 81c98c815..5f3143c08 100644 --- a/src/main/java/me/blackvein/quests/StageTimer.java +++ b/src/main/java/me/blackvein/quests/StageTimer.java @@ -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.name); + msg = msg.replace("", quest.name); player.sendMessage(ChatColor.GOLD + msg); - player.sendMessage(ChatColor.GOLD + Lang.get(player, "questObjectivesTitle")); for (String s : quester.getObjectivesReal(quest)) { player.sendMessage(s); }