Prevent sending of most empty quester strings, fixes #1545

This commit is contained in:
PikaMug 2021-01-09 01:55:31 -05:00
parent ebe13ea162
commit f315916124
5 changed files with 188 additions and 202 deletions

View File

@ -263,9 +263,8 @@ public class Quest implements Comparable<Quest> {
updateCompass(quester, nextStage); updateCompass(quester, nextStage);
if (player.isOnline()) { if (player.isOnline()) {
final Player p = quester.getPlayer(); final Player p = quester.getPlayer();
String msg = Lang.get(p, "questObjectivesTitle"); final String msg = Lang.get(p, "objectives").replace("<quest>", name);
msg = msg.replace("<quest>", name); quester.sendMessage(ChatColor.GOLD + msg);
p.sendMessage(ChatColor.GOLD + msg);
plugin.showObjectives(this, quester, false); plugin.showObjectives(this, quester, false);
final String stageStartMessage = quester.getCurrentStage(this).startMessage; final String stageStartMessage = quester.getCurrentStage(this).startMessage;
if (stageStartMessage != null) { if (stageStartMessage != null) {
@ -546,14 +545,13 @@ public class Quest implements Comparable<Quest> {
} }
} }
if (player.isOnline()) { if (player.isOnline()) {
final Player p = (Player)player;
for (final ItemStack i : rews.getItems()) { for (final ItemStack i : rews.getItems()) {
try { try {
InventoryUtil.addItem(p, i); InventoryUtil.addItem(player.getPlayer(), i);
} catch (final Exception e) { } catch (final Exception e) {
plugin.getLogger().severe("Unable to add null reward item to inventory of " plugin.getLogger().severe("Unable to add null reward item to inventory of "
+ player.getName() + " upon completion of quest " + name); + player.getName() + " upon completion of quest " + name);
p.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. " q.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. "
+ "Please contact an administrator."); + "Please contact an administrator.");
} }
issuedReward = true; issuedReward = true;
@ -643,14 +641,13 @@ public class Quest implements Comparable<Quest> {
if (lb.getItemList().isEmpty() == false) { if (lb.getItemList().isEmpty() == false) {
phatLootItems.addAll(lb.getItemList()); phatLootItems.addAll(lb.getItemList());
if (player.isOnline()) { if (player.isOnline()) {
final Player p = (Player)player;
for (final ItemStack is : lb.getItemList()) { for (final ItemStack is : lb.getItemList()) {
try { try {
InventoryUtil.addItem(p, is); InventoryUtil.addItem(player.getPlayer(), is);
} catch (final Exception e) { } catch (final Exception e) {
plugin.getLogger().severe("Unable to add PhatLoots item to inventory of " + p.getName() plugin.getLogger().severe("Unable to add PhatLoots item to inventory of " + player.getName()
+ " upon completion of quest " + name); + " upon completion of quest " + name);
p.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. " q.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. "
+ "Please contact an administrator."); + "Please contact an administrator.");
} }
} }
@ -696,13 +693,13 @@ public class Quest implements Comparable<Quest> {
// Inform player // Inform player
if (player.isOnline()) { if (player.isOnline()) {
final Player p = (Player)player; final Player p = (Player)player;
p.sendMessage(ChatColor.GOLD + Lang.get(p, "questCompleteTitle").replace("<quest>", ChatColor.YELLOW + name q.sendMessage(ChatColor.GOLD + Lang.get(p, "questCompleteTitle").replace("<quest>", ChatColor.YELLOW + name
+ ChatColor.GOLD)); + ChatColor.GOLD));
if (plugin.getSettings().canShowQuestTitles()) { if (plugin.getSettings().canShowQuestTitles()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + p.getName() Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + player.getName()
+ " title " + "{\"text\":\"" + Lang.get(p, "quest") + " " + Lang.get(p, "complete") + " title " + "{\"text\":\"" + Lang.get(p, "quest") + " " + Lang.get(p, "complete")
+ "\",\"color\":\"gold\"}"); + "\",\"color\":\"gold\"}");
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + p.getName() Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + player.getName()
+ " subtitle " + "{\"text\":\"" + name + "\",\"color\":\"yellow\"}"); + " subtitle " + "{\"text\":\"" + name + "\",\"color\":\"yellow\"}");
} }
p.sendMessage(ChatColor.GREEN + Lang.get(p, "questRewardsTitle")); p.sendMessage(ChatColor.GREEN + Lang.get(p, "questRewardsTitle"));
@ -715,11 +712,11 @@ public class Quest implements Comparable<Quest> {
if (plugin.getDependencies().getPlaceholderApi() != null) { if (plugin.getDependencies().getPlaceholderApi() != null) {
message = PlaceholderAPI.setPlaceholders(p, message); message = PlaceholderAPI.setPlaceholders(p, message);
} }
p.sendMessage("- " + message); q.sendMessage("- " + message);
} }
} else { } else {
if (rews.getQuestPoints() > 0) { if (rews.getQuestPoints() > 0) {
p.sendMessage("- " + ChatColor.DARK_GREEN + rews.getQuestPoints() + " " q.sendMessage("- " + ChatColor.DARK_GREEN + rews.getQuestPoints() + " "
+ Lang.get(p, "questPoints")); + Lang.get(p, "questPoints"));
} }
for (final ItemStack i : rews.getItems()) { for (final ItemStack i : rews.getItems()) {
@ -780,48 +777,48 @@ public class Quest implements Comparable<Quest> {
text = text.replaceFirst("<enchantment>", ItemUtil.getPrettyEnchantmentName(e.getKey())); text = text.replaceFirst("<enchantment>", ItemUtil.getPrettyEnchantmentName(e.getKey()));
text = text.replaceFirst("<level>", RomanNumeral.getNumeral(e.getValue())); text = text.replaceFirst("<level>", RomanNumeral.getNumeral(e.getValue()));
} }
p.sendMessage(text.replace("<item>", ItemUtil.getName(i))); q.sendMessage(text.replace("<item>", ItemUtil.getName(i)));
} }
} }
for (final ItemStack i : phatLootItems) { for (final ItemStack i : phatLootItems) {
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) { if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
if (i.getEnchantments().isEmpty()) { if (i.getEnchantments().isEmpty()) {
p.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() q.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount()); + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount());
} else { } else {
p.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() q.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName()
+ ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE
+ " " + Lang.get(p, "enchantedItem")); + " " + Lang.get(p, "enchantedItem"));
} }
} else if (i.getDurability() != 0) { } else if (i.getDurability() != 0) {
if (i.getEnchantments().isEmpty()) { if (i.getEnchantments().isEmpty()) {
p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() q.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability()
+ ChatColor.GRAY + " x " + i.getAmount()); + ChatColor.GRAY + " x " + i.getAmount());
} else { } else {
p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() q.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability()
+ ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " "
+ Lang.get(p, "enchantedItem")); + Lang.get(p, "enchantedItem"));
} }
} else { } else {
if (i.getEnchantments().isEmpty()) { if (i.getEnchantments().isEmpty()) {
p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " q.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x "
+ i.getAmount()); + i.getAmount());
} else { } else {
p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " q.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x "
+ i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get(p, "enchantedItem")); + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get(p, "enchantedItem"));
} }
} }
} }
if (rews.getMoney() > 1) { if (rews.getMoney() > 1) {
p.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE q.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE
+ plugin.getDependencies().getCurrency(true)); + plugin.getDependencies().getCurrency(true));
} else if (rews.getMoney() == 1) { } else if (rews.getMoney() == 1) {
p.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE q.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE
+ plugin.getDependencies().getCurrency(false)); + plugin.getDependencies().getCurrency(false));
} }
if (rews.getExp() > 0 || phatLootExp > 0) { if (rews.getExp() > 0 || phatLootExp > 0) {
final int tot = rews.getExp() + phatLootExp; final int tot = rews.getExp() + phatLootExp;
p.sendMessage("- " + ChatColor.DARK_GREEN + tot + ChatColor.DARK_PURPLE + " " q.sendMessage("- " + ChatColor.DARK_GREEN + tot + ChatColor.DARK_PURPLE + " "
+ Lang.get(p, "experience")); + Lang.get(p, "experience"));
} }
if (rews.getCommands().isEmpty() == false) { if (rews.getCommands().isEmpty() == false) {
@ -830,11 +827,11 @@ public class Quest implements Comparable<Quest> {
if (rews.getCommandsOverrideDisplay().isEmpty() == false if (rews.getCommandsOverrideDisplay().isEmpty() == false
&& rews.getCommandsOverrideDisplay().size() > index) { && rews.getCommandsOverrideDisplay().size() > index) {
if (!rews.getCommandsOverrideDisplay().get(index).trim().equals("")) { if (!rews.getCommandsOverrideDisplay().get(index).trim().equals("")) {
p.sendMessage("- " + ChatColor.DARK_GREEN q.sendMessage("- " + ChatColor.DARK_GREEN
+ rews.getCommandsOverrideDisplay().get(index)); + rews.getCommandsOverrideDisplay().get(index));
} }
} else { } else {
p.sendMessage("- " + ChatColor.DARK_GREEN + s); q.sendMessage("- " + ChatColor.DARK_GREEN + s);
} }
index++; index++;
} }
@ -843,10 +840,10 @@ public class Quest implements Comparable<Quest> {
int index = 0; int index = 0;
for (final String s : rews.getPermissions()) { for (final String s : rews.getPermissions()) {
if (rews.getPermissionWorlds() != null && rews.getPermissionWorlds().size() > index) { if (rews.getPermissionWorlds() != null && rews.getPermissionWorlds().size() > index) {
p.sendMessage("- " + ChatColor.DARK_GREEN + s + " (" + rews.getPermissionWorlds().get(index) q.sendMessage("- " + ChatColor.DARK_GREEN + s + " (" + rews.getPermissionWorlds().get(index)
+ ")"); + ")");
} else { } else {
p.sendMessage("- " + ChatColor.DARK_GREEN + s); q.sendMessage("- " + ChatColor.DARK_GREEN + s);
} }
index++; index++;
@ -854,21 +851,21 @@ public class Quest implements Comparable<Quest> {
} }
if (rews.getMcmmoSkills().isEmpty() == false) { if (rews.getMcmmoSkills().isEmpty() == false) {
for (final String s : rews.getMcmmoSkills()) { for (final String s : rews.getMcmmoSkills()) {
p.sendMessage("- " + ChatColor.DARK_GREEN q.sendMessage("- " + ChatColor.DARK_GREEN
+ rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)) + " " + rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)) + " "
+ ChatColor.DARK_PURPLE + s + " " + Lang.get(p, "experience")); + ChatColor.DARK_PURPLE + s + " " + Lang.get(p, "experience"));
} }
} }
if (rews.getHeroesClasses().isEmpty() == false) { if (rews.getHeroesClasses().isEmpty() == false) {
for (final String s : rews.getHeroesClasses()) { for (final String s : rews.getHeroesClasses()) {
p.sendMessage("- " + ChatColor.AQUA q.sendMessage("- " + ChatColor.AQUA
+ rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)) + " " + ChatColor.BLUE + rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)) + " " + ChatColor.BLUE
+ s + " " + Lang.get(p, "experience")); + s + " " + Lang.get(p, "experience"));
} }
} }
if (phatLootMessages.isEmpty() == false) { if (phatLootMessages.isEmpty() == false) {
for (final String s : phatLootMessages) { for (final String s : phatLootMessages) {
p.sendMessage("- " + s); q.sendMessage("- " + s);
} }
} }
for (final String s : rews.getCustomRewards().keySet()) { for (final String s : rews.getCustomRewards().keySet()) {
@ -886,7 +883,7 @@ public class Quest implements Comparable<Quest> {
for (final String key : datamap.keySet()) { for (final String key : datamap.keySet()) {
message = message.replace("%" + key + "%", datamap.get(key).toString()); message = message.replace("%" + key + "%", datamap.get(key).toString());
} }
p.sendMessage("- " + ChatColor.GOLD + message); q.sendMessage("- " + ChatColor.GOLD + message);
} else { } else {
plugin.getLogger().warning("Failed to notify player: " plugin.getLogger().warning("Failed to notify player: "
+ "Custom Reward does not have an assigned name"); + "Custom Reward does not have an assigned name");
@ -901,7 +898,7 @@ public class Quest implements Comparable<Quest> {
} }
q.saveData(); q.saveData();
if (player.isOnline()) { if (player.isOnline()) {
((Player)player).updateInventory(); player.getPlayer().updateInventory();
} }
q.updateJournal(); q.updateJournal();
q.findCompassTarget(); q.findCompassTarget();
@ -951,7 +948,7 @@ public class Quest implements Comparable<Quest> {
} }
} }
final String[] messages = { final String[] messages = {
ChatColor.GOLD + Lang.get(player, "questObjectivesTitle").replace("<quest>", name), ChatColor.GOLD + Lang.get(player, "questCommandTitle").replace("<quest>", name),
ChatColor.RED + Lang.get(player, "questFailed") ChatColor.RED + Lang.get(player, "questFailed")
}; };
quester.quitQuest(this, messages); quester.quitQuest(this, messages);

View File

@ -373,6 +373,13 @@ public class Quester implements Comparable<Quester> {
return plugin.getServer().getOfflinePlayer(id); return plugin.getServer().getOfflinePlayer(id);
} }
public void sendMessage(final String message) {
if (getPlayer() == null || !getPlayer().isOnline() || message.trim().isEmpty()) {
return;
}
getPlayer().sendMessage(message);
}
public Stage getCurrentStage(final Quest quest) { public Stage getCurrentStage(final Quest quest) {
if (currentQuests.containsKey(quest)) { if (currentQuests.containsKey(quest)) {
return quest.getStage(currentQuests.get(quest)); return quest.getStage(currentQuests.get(quest));
@ -454,9 +461,8 @@ public class Quester implements Comparable<Quester> {
if (preEvent.isCancelled()) { if (preEvent.isCancelled()) {
return; return;
} }
final OfflinePlayer player = getOfflinePlayer(); final OfflinePlayer offlinePlayer = getOfflinePlayer();
if (player.isOnline()) { if (offlinePlayer.isOnline()) {
final Player p = getPlayer();
final Planner pln = q.getPlanner(); final Planner pln = q.getPlanner();
final long currentTime = System.currentTimeMillis(); final long currentTime = System.currentTimeMillis();
final long start = pln.getStartInMillis(); // Start time in milliseconds since UTC epoch final long start = pln.getStartInMillis(); // Start time in milliseconds since UTC epoch
@ -469,7 +475,7 @@ public class Quester implements Comparable<Quester> {
early = early.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW); early = early.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW);
early = early.replace("<time>", ChatColor.RED early = early.replace("<time>", ChatColor.RED
+ MiscUtil.getTime(start - currentTime) + ChatColor.YELLOW); + MiscUtil.getTime(start - currentTime) + ChatColor.YELLOW);
p.sendMessage(ChatColor.YELLOW + early); sendMessage(ChatColor.YELLOW + early);
return; return;
} }
} }
@ -479,7 +485,7 @@ public class Quester implements Comparable<Quester> {
late = late.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.RED); late = late.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.RED);
late = late.replace("<time>", ChatColor.DARK_PURPLE late = late.replace("<time>", ChatColor.DARK_PURPLE
+ MiscUtil.getTime(currentTime - end) + ChatColor.RED); + MiscUtil.getTime(currentTime - end) + ChatColor.RED);
p.sendMessage(ChatColor.RED + late); sendMessage(ChatColor.RED + late);
return; return;
} }
} }
@ -526,19 +532,19 @@ public class Quester implements Comparable<Quester> {
// If quest is not active, or new period of activity should override player cooldown, inform user // If quest is not active, or new period of activity should override player cooldown, inform user
if (!active | (q.getPlanner().getOverride() && completedEnd > 0L if (!active | (q.getPlanner().getOverride() && completedEnd > 0L
&& currentTime < (completedEnd /*+ repeat*/))) { && currentTime < (completedEnd /*+ repeat*/))) {
if (p.isOnline()) { if (getPlayer().isOnline()) {
final String early = Lang.get("plnTooEarly") final String early = Lang.get("plnTooEarly")
.replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW) .replace("<quest>", ChatColor.AQUA + q.getName() + ChatColor.YELLOW)
.replace("<time>", ChatColor.DARK_PURPLE .replace("<time>", ChatColor.DARK_PURPLE
+ MiscUtil.getTime((completedEnd /*+ repeat*/) - currentTime) + ChatColor.YELLOW); + MiscUtil.getTime((completedEnd /*+ repeat*/) - currentTime) + ChatColor.YELLOW);
p.sendMessage(ChatColor.YELLOW + early); sendMessage(ChatColor.YELLOW + early);
} }
return; return;
} }
} }
} }
} }
if (q.testRequirements(player) == true || ignoreReqs) { if (q.testRequirements(offlinePlayer) == true || ignoreReqs) {
addEmptiesFor(q, 0); addEmptiesFor(q, 0);
try { try {
currentQuests.put(q, 0); currentQuests.put(q, 0);
@ -546,7 +552,7 @@ public class Quester implements Comparable<Quester> {
plugin.getLogger().info(getPlayer().getUniqueId() + " started quest " + q.getName()); plugin.getLogger().info(getPlayer().getUniqueId() + " started quest " + q.getName());
} }
} catch (final NullPointerException npe) { } catch (final NullPointerException npe) {
plugin.getLogger().severe("Unable to add quest" + q.getName() + " for player " + player.getName() plugin.getLogger().severe("Unable to add quest" + q.getName() + " for player " + offlinePlayer.getName()
+ ". Consider resetting player data or report on Github"); + ". Consider resetting player data or report on Github");
} }
final Stage stage = q.getStage(0); final Stage stage = q.getStage(0);
@ -557,7 +563,7 @@ public class Quester implements Comparable<Quester> {
plugin.getDependencies().getVaultEconomy().withdrawPlayer(getOfflinePlayer(), reqs.getMoney()); plugin.getDependencies().getVaultEconomy().withdrawPlayer(getOfflinePlayer(), reqs.getMoney());
} }
} }
if (player.isOnline()) { if (offlinePlayer.isOnline()) {
final Player p = getPlayer(); final Player p = getPlayer();
final ItemStack[] original = p.getInventory().getContents().clone(); final ItemStack[] original = p.getInventory().getContents().clone();
for (final ItemStack is : reqs.getItems()) { for (final ItemStack is : reqs.getItems()) {
@ -566,7 +572,7 @@ public class Quester implements Comparable<Quester> {
if (InventoryUtil.stripItem(p.getEquipment(), is) == false) { if (InventoryUtil.stripItem(p.getEquipment(), is) == false) {
p.getInventory().setContents(original); p.getInventory().setContents(original);
p.updateInventory(); p.updateInventory();
p.sendMessage(Lang.get(p, "requirementsItemFail")); sendMessage(Lang.get(p, "requirementsItemFail"));
hardQuit(q); hardQuit(q);
return; return;
} }
@ -575,68 +581,66 @@ public class Quester implements Comparable<Quester> {
} }
String accepted = Lang.get(getPlayer(), "questAccepted"); String accepted = Lang.get(getPlayer(), "questAccepted");
accepted = accepted.replace("<quest>", q.getName()); accepted = accepted.replace("<quest>", q.getName());
p.sendMessage(ChatColor.GREEN + accepted); sendMessage(ChatColor.GREEN + accepted);
p.sendMessage(""); p.sendMessage("");
if (plugin.getSettings().canShowQuestTitles()) { if (plugin.getSettings().canShowQuestTitles()) {
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "title " plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "title "
+ player.getName() + " title " + "{\"text\":\"" + Lang.get(getPlayer(), "quest") + " " + offlinePlayer.getName() + " title " + "{\"text\":\"" + Lang.get(getPlayer(), "quest")
+ Lang.get(getPlayer(), "accepted") + "\",\"color\":\"gold\"}"); + " " + Lang.get(getPlayer(), "accepted") + "\",\"color\":\"gold\"}");
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "title " plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "title "
+ player.getName() + " subtitle " + "{\"text\":\"" + q.getName() + offlinePlayer.getName() + " subtitle " + "{\"text\":\"" + q.getName()
+ "\",\"color\":\"yellow\"}"); + "\",\"color\":\"yellow\"}");
} }
} }
} }
if (player.isOnline()) { if (offlinePlayer.isOnline()) {
final Player p = getPlayer(); final Player p = getPlayer();
String title = Lang.get(p, "questObjectivesTitle"); final String title = Lang.get(p, "objectives").replace("<quest>", q.getName());
title = title.replace("<quest>", q.getName()); sendMessage(ChatColor.GOLD + title);
p.sendMessage(ChatColor.GOLD + title);
plugin.showObjectives(q, this, false); plugin.showObjectives(q, this, false);
final String stageStartMessage = stage.startMessage; final String stageStartMessage = stage.startMessage;
if (stageStartMessage != null) { if (stageStartMessage != null) {
p.sendMessage(ConfigUtil p.sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(stageStartMessage, q, getPlayer()));
.parseStringWithPossibleLineBreaks(stageStartMessage, q, getPlayer()));
} }
final Condition c = stage.getCondition(); final Condition c = stage.getCondition();
if (c != null) { if (c != null) {
p.sendMessage(ChatColor.LIGHT_PURPLE + Lang.get("stageEditorConditions") + ":"); sendMessage(ChatColor.LIGHT_PURPLE + Lang.get("stageEditorConditions"));
if (!c.getEntitiesWhileRiding().isEmpty()) { if (!c.getEntitiesWhileRiding().isEmpty()) {
String msg = "- " + Lang.get("conditionEditorRideEntity"); String msg = "- " + Lang.get("conditionEditorRideEntity");
for (final String e : c.getEntitiesWhileRiding()) { for (final String e : c.getEntitiesWhileRiding()) {
msg += ChatColor.AQUA + "\n \u2515 " + e; msg += ChatColor.AQUA + "\n \u2515 " + e;
} }
p.sendMessage(ChatColor.YELLOW + msg); sendMessage(ChatColor.YELLOW + msg);
} else if (!c.getPermissions().isEmpty()) { } else if (!c.getPermissions().isEmpty()) {
String msg = "- " + Lang.get("conditionEditorPermissions"); String msg = "- " + Lang.get("conditionEditorPermissions");
for (final String e : c.getPermissions()) { for (final String e : c.getPermissions()) {
msg += ChatColor.AQUA + "\n \u2515 " + e; msg += ChatColor.AQUA + "\n \u2515 " + e;
} }
p.sendMessage(ChatColor.YELLOW + msg); sendMessage(ChatColor.YELLOW + msg);
} else if (!c.getItemsWhileHoldingMainHand().isEmpty()) { } else if (!c.getItemsWhileHoldingMainHand().isEmpty()) {
String msg = "- " + Lang.get("conditionEditorItemsInMainHand"); String msg = "- " + Lang.get("conditionEditorItemsInMainHand");
for (final ItemStack is : c.getItemsWhileHoldingMainHand()) { for (final ItemStack is : c.getItemsWhileHoldingMainHand()) {
msg += ChatColor.AQUA + "\n \u2515 " + ItemUtil.getPrettyItemName(is.getType().name()); msg += ChatColor.AQUA + "\n \u2515 " + ItemUtil.getPrettyItemName(is.getType().name());
} }
p.sendMessage(ChatColor.YELLOW + msg); sendMessage(ChatColor.YELLOW + msg);
} else if (!c.getWorldsWhileStayingWithin().isEmpty()) { } else if (!c.getWorldsWhileStayingWithin().isEmpty()) {
String msg = "- " + Lang.get("conditionEditorStayWithinWorld"); String msg = "- " + Lang.get("conditionEditorStayWithinWorld");
for (final String w : c.getWorldsWhileStayingWithin()) { for (final String w : c.getWorldsWhileStayingWithin()) {
msg += ChatColor.AQUA + "\n \u2515 " + w; msg += ChatColor.AQUA + "\n \u2515 " + w;
} }
p.sendMessage(ChatColor.YELLOW + msg); sendMessage(ChatColor.YELLOW + msg);
} else if (!c.getBiomesWhileStayingWithin().isEmpty()) { } else if (!c.getBiomesWhileStayingWithin().isEmpty()) {
String msg = "- " + Lang.get("conditionEditorStayWithinBiome"); String msg = "- " + Lang.get("conditionEditorStayWithinBiome");
for (final String b : c.getBiomesWhileStayingWithin()) { for (final String b : c.getBiomesWhileStayingWithin()) {
msg += ChatColor.AQUA + "\n \u2515 " + MiscUtil.snakeCaseToUpperCamelCase(b); msg += ChatColor.AQUA + "\n \u2515 " + MiscUtil.snakeCaseToUpperCamelCase(b);
} }
p.sendMessage(ChatColor.YELLOW + msg); sendMessage(ChatColor.YELLOW + msg);
} else if (!c.getRegionsWhileStayingWithin().isEmpty()) { } else if (!c.getRegionsWhileStayingWithin().isEmpty()) {
String msg = "- " + Lang.get("conditionEditorStayWithinRegion"); String msg = "- " + Lang.get("conditionEditorStayWithinRegion");
for (final String r : c.getRegionsWhileStayingWithin()) { for (final String r : c.getRegionsWhileStayingWithin()) {
msg += ChatColor.AQUA + "\n \u2515 " + r; msg += ChatColor.AQUA + "\n \u2515 " + r;
} }
p.sendMessage(ChatColor.YELLOW + msg); sendMessage(ChatColor.YELLOW + msg);
} else if (!c.getPlaceholdersCheckIdentifier().isEmpty()) { } else if (!c.getPlaceholdersCheckIdentifier().isEmpty()) {
String msg = "- " + Lang.get("conditionEditorCheckPlaceholder"); String msg = "- " + Lang.get("conditionEditorCheckPlaceholder");
int index = 0; int index = 0;
@ -647,7 +651,7 @@ public class Quester implements Comparable<Quester> {
} }
index++; index++;
} }
p.sendMessage(ChatColor.YELLOW + msg); sendMessage(ChatColor.YELLOW + msg);
} }
} }
} }
@ -670,14 +674,14 @@ public class Quester implements Comparable<Quester> {
q.updateCompass(this, stage); q.updateCompass(this, stage);
saveData(); saveData();
} else { } else {
if (player.isOnline()) { if (offlinePlayer.isOnline()) {
((Player)player).sendMessage(ChatColor.DARK_AQUA + Lang.get("requirements")); sendMessage(ChatColor.DARK_AQUA + Lang.get("requirements"));
for (final String s : getCurrentRequirements(q, false)) { for (final String s : getCurrentRequirements(q, false)) {
((Player)player).sendMessage(ChatColor.GRAY + "- " + s); sendMessage(ChatColor.GRAY + "- " + s);
} }
} }
} }
if (player.isOnline()) { if (offlinePlayer.isOnline()) {
final QuesterPostStartQuestEvent postEvent = new QuesterPostStartQuestEvent(this, q); final QuesterPostStartQuestEvent postEvent = new QuesterPostStartQuestEvent(this, q);
plugin.getServer().getPluginManager().callEvent(postEvent); plugin.getServer().getPluginManager().callEvent(postEvent);
} }
@ -711,7 +715,7 @@ public class Quester implements Comparable<Quester> {
} }
for (final String message : messages) { for (final String message : messages) {
if (message != null && !message.equals("") && getPlayer().isOnline()) { if (message != null && !message.equals("") && getPlayer().isOnline()) {
getPlayer().sendMessage(message); sendMessage(message);
} }
} }
saveData(); saveData();
@ -1786,7 +1790,6 @@ public class Quester implements Comparable<Quester> {
* @param i The item being crafted * @param i The item being crafted
*/ */
public void craftItem(final Quest quest, final ItemStack i) { public void craftItem(final Quest quest, final ItemStack i) {
final Player player = getPlayer();
ItemStack found = null; ItemStack found = null;
for (final ItemStack is : getQuestData(quest).itemsCrafted.keySet()) { for (final ItemStack is : getQuestData(quest).itemsCrafted.keySet()) {
if (ItemUtil.compareItems(i, is, true) == 0) { if (ItemUtil.compareItems(i, is, true) == 0) {
@ -1804,8 +1807,7 @@ public class Quester implements Comparable<Quester> {
+ quest.getName() + " with " + i.getType() + " x " + i.getAmount() + quest.getName() + " with " + i.getType() + " x " + i.getAmount()
+ " already crafted. List amount reports value of " + amount + " already crafted. List amount reports value of " + amount
+ ". Please report this error on Github!"); + ". Please report this error on Github!");
player.sendMessage(ChatColor.RED sendMessage(ChatColor.RED + "Quests had a problem crafting your item, please contact an administrator!");
+ "Quests had a problem crafting your item, please contact an administrator!");
return; return;
} }
final int req = getCurrentStage(quest).itemsToCraft.get(getCurrentStage(quest).itemsToCraft.indexOf(found)) final int req = getCurrentStage(quest).itemsToCraft.get(getCurrentStage(quest).itemsToCraft.indexOf(found))
@ -1849,7 +1851,6 @@ public class Quester implements Comparable<Quester> {
* @param i The item being smelted * @param i The item being smelted
*/ */
public void smeltItem(final Quest quest, final ItemStack i) { public void smeltItem(final Quest quest, final ItemStack i) {
final Player player = getPlayer();
ItemStack found = null; ItemStack found = null;
for (final ItemStack is : getQuestData(quest).itemsSmelted.keySet()) { for (final ItemStack is : getQuestData(quest).itemsSmelted.keySet()) {
if (ItemUtil.compareItems(i, is, true) == 0) { if (ItemUtil.compareItems(i, is, true) == 0) {
@ -1866,8 +1867,7 @@ public class Quester implements Comparable<Quester> {
+ found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x " + found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x "
+ i.getAmount() + " already smelted. List amount reports value of " + amount + i.getAmount() + " already smelted. List amount reports value of " + amount
+ ". Please report this error on Github!"); + ". Please report this error on Github!");
player.sendMessage(ChatColor.RED sendMessage(ChatColor.RED + "Quests had a problem smelting your item, please contact an administrator!");
+ "Quests had a problem smelting your item, please contact an administrator!");
return; return;
} }
final int req = getCurrentStage(quest).itemsToSmelt.get(getCurrentStage(quest).itemsToSmelt.indexOf(found)) final int req = getCurrentStage(quest).itemsToSmelt.get(getCurrentStage(quest).itemsToSmelt.indexOf(found))
@ -1911,7 +1911,6 @@ public class Quester implements Comparable<Quester> {
* @param i The item being enchanted * @param i The item being enchanted
*/ */
public void enchantItem(final Quest quest, final ItemStack i) { public void enchantItem(final Quest quest, final ItemStack i) {
final Player player = getPlayer();
ItemStack found = null; ItemStack found = null;
for (final ItemStack is : getQuestData(quest).itemsEnchanted.keySet()) { for (final ItemStack is : getQuestData(quest).itemsEnchanted.keySet()) {
if (!is.getEnchantments().isEmpty()) { if (!is.getEnchantments().isEmpty()) {
@ -1935,8 +1934,7 @@ public class Quester implements Comparable<Quester> {
+ found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x " + found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x "
+ i.getAmount() + " already enchanted. List amount reports value of " + amount + i.getAmount() + " already enchanted. List amount reports value of " + amount
+ ". Please report this error on Github!"); + ". Please report this error on Github!");
player.sendMessage(ChatColor.RED sendMessage(ChatColor.RED + "Quests had a problem enchanting your item, please contact an administrator!");
+ "Quests had a problem enchanting your item, please contact an administrator!");
return; return;
} }
final int req = getCurrentStage(quest).itemsToEnchant.get(getCurrentStage(quest).itemsToEnchant final int req = getCurrentStage(quest).itemsToEnchant.get(getCurrentStage(quest).itemsToEnchant
@ -1980,7 +1978,6 @@ public class Quester implements Comparable<Quester> {
* @param i The item being brewed * @param i The item being brewed
*/ */
public void brewItem(final Quest quest, final ItemStack i) { public void brewItem(final Quest quest, final ItemStack i) {
final Player player = getPlayer();
ItemStack found = null; ItemStack found = null;
for (final ItemStack is : getQuestData(quest).itemsBrewed.keySet()) { for (final ItemStack is : getQuestData(quest).itemsBrewed.keySet()) {
if (ItemUtil.compareItems(i, is, true) == 0) { if (ItemUtil.compareItems(i, is, true) == 0) {
@ -1997,8 +1994,7 @@ public class Quester implements Comparable<Quester> {
+ found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x " + found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x "
+ i.getAmount() + " already smelted. List amount reports value of " + amount + i.getAmount() + " already smelted. List amount reports value of " + amount
+ ". Please report this error on Github!"); + ". Please report this error on Github!");
player.sendMessage(ChatColor.RED sendMessage(ChatColor.RED + "Quests had a problem brewing your item, please contact an administrator!");
+ "Quests had a problem brewing your item, please contact an administrator!");
return; return;
} }
final int req = getCurrentStage(quest).itemsToBrew.get(getCurrentStage(quest).itemsToBrew.indexOf(found)) final int req = getCurrentStage(quest).itemsToBrew.get(getCurrentStage(quest).itemsToBrew.indexOf(found))
@ -2042,7 +2038,6 @@ public class Quester implements Comparable<Quester> {
* @param i The item being consumed * @param i The item being consumed
*/ */
public void consumeItem(final Quest quest, final ItemStack i) { public void consumeItem(final Quest quest, final ItemStack i) {
final Player player = getPlayer();
ItemStack found = null; ItemStack found = null;
for (final ItemStack is : getQuestData(quest).itemsConsumed.keySet()) { for (final ItemStack is : getQuestData(quest).itemsConsumed.keySet()) {
if (ItemUtil.compareItems(i, is, true) == 0) { if (ItemUtil.compareItems(i, is, true) == 0) {
@ -2059,8 +2054,7 @@ public class Quester implements Comparable<Quester> {
+ found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x " + found.getAmount() + " for quest " + quest.getName() + " with " + i.getType() + " x "
+ i.getAmount() + " already consumed. List amount reports value of " + amount + i.getAmount() + " already consumed. List amount reports value of " + amount
+ ". Please report this error on Github!"); + ". Please report this error on Github!");
player.sendMessage(ChatColor.RED sendMessage(ChatColor.RED + "Quests had a problem consuming your item, please contact an administrator!");
+ "Quests had a problem consuming your item, please contact an administrator!");
return; return;
} }
final int req = getCurrentStage(quest).itemsToConsume.get(getCurrentStage(quest).itemsToConsume.indexOf(found)) final int req = getCurrentStage(quest).itemsToConsume.get(getCurrentStage(quest).itemsToConsume.indexOf(found))
@ -2487,7 +2481,6 @@ public class Quester implements Comparable<Quester> {
new Objective(type, locationsReached, locationsToReach)); new Objective(type, locationsReached, locationsToReach));
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
// TODO - Find proper cause of Github issues #646 and #825 and #1191
if (locationsReached <= index) { if (locationsReached <= index) {
getQuestData(quest).hasReached.add(true); getQuestData(quest).hasReached.add(true);
finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1), finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
@ -2706,11 +2699,10 @@ public class Quester implements Comparable<Quester> {
if (plugin.getDependencies().getPlaceholderApi() != null) { if (plugin.getDependencies().getPlaceholderApi() != null) {
message = PlaceholderAPI.setPlaceholders(p, message); message = PlaceholderAPI.setPlaceholders(p, message);
} }
p.sendMessage(message); sendMessage(message);
} }
} else if (type.equals(ObjectiveType.PASSWORD)) { } else if (type.equals(ObjectiveType.PASSWORD)) {
final String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + pass; sendMessage(ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + pass);
p.sendMessage(message);
} else if (type.equals(ObjectiveType.BREAK_BLOCK)) { } else if (type.equals(ObjectiveType.BREAK_BLOCK)) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "break"); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "break");
if (message.contains("<count>")) { if (message.contains("<count>")) {
@ -2723,7 +2715,7 @@ public class Quester implements Comparable<Quester> {
&& !goal.getItemMeta().hasDisplayName()) { && !goal.getItemMeta().hasDisplayName()) {
plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null); plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null);
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(increment))); sendMessage(message.replace("<item>", ItemUtil.getName(increment)));
} }
} else if (type.equals(ObjectiveType.DAMAGE_BLOCK)) { } else if (type.equals(ObjectiveType.DAMAGE_BLOCK)) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "damage"); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "damage");
@ -2737,7 +2729,7 @@ public class Quester implements Comparable<Quester> {
&& !goal.getItemMeta().hasDisplayName()) { && !goal.getItemMeta().hasDisplayName()) {
plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null); plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null);
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(increment))); sendMessage(message.replace("<item>", ItemUtil.getName(increment)));
} }
} else if (type.equals(ObjectiveType.PLACE_BLOCK)) { } else if (type.equals(ObjectiveType.PLACE_BLOCK)) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "place"); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "place");
@ -2751,7 +2743,7 @@ public class Quester implements Comparable<Quester> {
&& !goal.getItemMeta().hasDisplayName()) { && !goal.getItemMeta().hasDisplayName()) {
plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null); plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null);
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(increment))); sendMessage(message.replace("<item>", ItemUtil.getName(increment)));
} }
} else if (type.equals(ObjectiveType.USE_BLOCK)) { } else if (type.equals(ObjectiveType.USE_BLOCK)) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "use"); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "use");
@ -2765,7 +2757,7 @@ public class Quester implements Comparable<Quester> {
&& !goal.getItemMeta().hasDisplayName()) { && !goal.getItemMeta().hasDisplayName()) {
plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null); plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null);
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(increment))); sendMessage(message.replace("<item>", ItemUtil.getName(increment)));
} }
} else if (type.equals(ObjectiveType.CUT_BLOCK)) { } else if (type.equals(ObjectiveType.CUT_BLOCK)) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "cut"); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "cut");
@ -2779,7 +2771,7 @@ public class Quester implements Comparable<Quester> {
&& !goal.getItemMeta().hasDisplayName()) { && !goal.getItemMeta().hasDisplayName()) {
plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null); plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), null);
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(increment))); sendMessage(message.replace("<item>", ItemUtil.getName(increment)));
} }
} else if (type.equals(ObjectiveType.CRAFT_ITEM)) { } else if (type.equals(ObjectiveType.CRAFT_ITEM)) {
final ItemStack is = getCurrentStage(quest).itemsToCraft.get(getCurrentStage(quest).itemsToCraft.indexOf(goal)); final ItemStack is = getCurrentStage(quest).itemsToCraft.get(getCurrentStage(quest).itemsToCraft.indexOf(goal));
@ -2794,7 +2786,7 @@ public class Quester implements Comparable<Quester> {
&& !goal.getItemMeta().hasDisplayName()) { && !goal.getItemMeta().hasDisplayName()) {
plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(), null); plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(), null);
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(is))); sendMessage(message.replace("<item>", ItemUtil.getName(is)));
} }
} else if (type.equals(ObjectiveType.SMELT_ITEM)) { } else if (type.equals(ObjectiveType.SMELT_ITEM)) {
final ItemStack is = getCurrentStage(quest).itemsToSmelt.get(getCurrentStage(quest).itemsToSmelt.indexOf(goal)); final ItemStack is = getCurrentStage(quest).itemsToSmelt.get(getCurrentStage(quest).itemsToSmelt.indexOf(goal));
@ -2809,7 +2801,7 @@ public class Quester implements Comparable<Quester> {
&& !goal.getItemMeta().hasDisplayName()) { && !goal.getItemMeta().hasDisplayName()) {
plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(), null); plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(), null);
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(is))); sendMessage(message.replace("<item>", ItemUtil.getName(is)));
} }
} else if (type.equals(ObjectiveType.ENCHANT_ITEM)) { } else if (type.equals(ObjectiveType.ENCHANT_ITEM)) {
final ItemStack is = getCurrentStage(quest).itemsToEnchant.get(getCurrentStage(quest).itemsToEnchant.indexOf(goal)); final ItemStack is = getCurrentStage(quest).itemsToEnchant.get(getCurrentStage(quest).itemsToEnchant.indexOf(goal));
@ -2831,7 +2823,7 @@ public class Quester implements Comparable<Quester> {
goal.getEnchantments()); goal.getEnchantments());
} else { } else {
for (final Entry<Enchantment, Integer> e : is.getEnchantments().entrySet()) { for (final Entry<Enchantment, Integer> e : is.getEnchantments().entrySet()) {
p.sendMessage(message.replace("<item>", ItemUtil.getName(is)) sendMessage(message.replace("<item>", ItemUtil.getName(is))
.replace("<enchantment>", ItemUtil.getPrettyEnchantmentName(e.getKey())) .replace("<enchantment>", ItemUtil.getPrettyEnchantmentName(e.getKey()))
.replace("<level>", RomanNumeral.getNumeral(e.getValue()))); .replace("<level>", RomanNumeral.getNumeral(e.getValue())));
} }
@ -2855,7 +2847,7 @@ public class Quester implements Comparable<Quester> {
plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(), plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(),
goal.getEnchantments()); goal.getEnchantments());
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(is))); sendMessage(message.replace("<item>", ItemUtil.getName(is)));
} }
} else if (type.equals(ObjectiveType.CONSUME_ITEM)) { } else if (type.equals(ObjectiveType.CONSUME_ITEM)) {
final ItemStack is = getCurrentStage(quest).itemsToConsume.get(getCurrentStage(quest).itemsToConsume final ItemStack is = getCurrentStage(quest).itemsToConsume.get(getCurrentStage(quest).itemsToConsume
@ -2871,7 +2863,7 @@ public class Quester implements Comparable<Quester> {
&& !goal.getItemMeta().hasDisplayName()) { && !goal.getItemMeta().hasDisplayName()) {
plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(), null); plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability(), null);
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(is))); sendMessage(message.replace("<item>", ItemUtil.getName(is)));
} }
} else if (type.equals(ObjectiveType.DELIVER_ITEM)) { } else if (type.equals(ObjectiveType.DELIVER_ITEM)) {
final ItemStack is = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver final ItemStack is = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver
@ -2889,7 +2881,7 @@ public class Quester implements Comparable<Quester> {
&& !goal.getItemMeta().hasDisplayName()) { && !goal.getItemMeta().hasDisplayName()) {
plugin.getLocaleQuery().sendMessage(p, message, is.getType(), is.getDurability(), null); plugin.getLocaleQuery().sendMessage(p, message, is.getType(), is.getDurability(), null);
} else { } else {
p.sendMessage(message.replace("<item>", ItemUtil.getName(is))); sendMessage(message.replace("<item>", ItemUtil.getName(is)));
} }
} else if (type.equals(ObjectiveType.MILK_COW)) { } else if (type.equals(ObjectiveType.MILK_COW)) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "milkCow"); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "milkCow");
@ -2899,7 +2891,7 @@ public class Quester implements Comparable<Quester> {
// Legacy // Legacy
message += ChatColor.GREEN + ": " + goal.getAmount() + "/" + goal.getAmount(); message += ChatColor.GREEN + ": " + goal.getAmount() + "/" + goal.getAmount();
} }
p.sendMessage(message); sendMessage(message);
} else if (type.equals(ObjectiveType.CATCH_FISH)) { } else if (type.equals(ObjectiveType.CATCH_FISH)) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "catchFish"); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "catchFish");
if (message.contains("<count>")) { if (message.contains("<count>")) {
@ -2908,7 +2900,7 @@ public class Quester implements Comparable<Quester> {
// Legacy // Legacy
message += ChatColor.GREEN + ": " + goal.getAmount() + "/" + goal.getAmount(); message += ChatColor.GREEN + ": " + goal.getAmount() + "/" + goal.getAmount();
} }
p.sendMessage(message); sendMessage(message);
} else if (type.equals(ObjectiveType.KILL_MOB)) { } else if (type.equals(ObjectiveType.KILL_MOB)) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill"); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill");
if (message.contains("<count>")) { if (message.contains("<count>")) {
@ -2921,7 +2913,7 @@ public class Quester implements Comparable<Quester> {
if (plugin.getSettings().canTranslateNames()) { if (plugin.getSettings().canTranslateNames()) {
plugin.getLocaleQuery().sendMessage(p, message, mob, extra); plugin.getLocaleQuery().sendMessage(p, message, mob, extra);
} else { } else {
p.sendMessage(message.replace("<mob>", MiscUtil.snakeCaseToUpperCamelCase(mob.name()))); sendMessage(message.replace("<mob>", MiscUtil.snakeCaseToUpperCamelCase(mob.name())));
} }
} else if (type.equals(ObjectiveType.KILL_PLAYER)) { } else if (type.equals(ObjectiveType.KILL_PLAYER)) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "killPlayer"); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "killPlayer");
@ -2931,11 +2923,11 @@ public class Quester implements Comparable<Quester> {
// Legacy // Legacy
message += ChatColor.GREEN + ": " + goal.getAmount() + "/" + goal.getAmount(); message += ChatColor.GREEN + ": " + goal.getAmount() + "/" + goal.getAmount();
} }
p.sendMessage(message); sendMessage(message);
} else if (type.equals(ObjectiveType.TALK_TO_NPC)) { } else if (type.equals(ObjectiveType.TALK_TO_NPC)) {
final String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "talkTo") final String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "talkTo")
.replace("<npc>", plugin.getDependencies().getNPCName(npc.getId())); .replace("<npc>", plugin.getDependencies().getNPCName(npc.getId()));
p.sendMessage(message); sendMessage(message);
} else if (type.equals(ObjectiveType.KILL_NPC)) { } else if (type.equals(ObjectiveType.KILL_NPC)) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill"); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill");
if (message.contains("<count>")) { if (message.contains("<count>")) {
@ -2945,7 +2937,7 @@ public class Quester implements Comparable<Quester> {
message += ChatColor.AQUA + " <mob>" + ChatColor.GREEN + ": " + goal.getAmount() + "/" message += ChatColor.AQUA + " <mob>" + ChatColor.GREEN + ": " + goal.getAmount() + "/"
+ goal.getAmount(); + goal.getAmount();
} }
p.sendMessage(message.replace("<mob>", plugin.getDependencies().getNPCName(npc.getId()))); sendMessage(message.replace("<mob>", plugin.getDependencies().getNPCName(npc.getId())));
} else if (type.equals(ObjectiveType.TAME_MOB)) { } else if (type.equals(ObjectiveType.TAME_MOB)) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "tame"); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "tame");
if (!message.contains("<mob>")) { if (!message.contains("<mob>")) {
@ -2960,7 +2952,7 @@ public class Quester implements Comparable<Quester> {
if (plugin.getSettings().canTranslateNames()) { if (plugin.getSettings().canTranslateNames()) {
plugin.getLocaleQuery().sendMessage(p, message, mob, extra); plugin.getLocaleQuery().sendMessage(p, message, mob, extra);
} else { } else {
p.sendMessage(message.replace("<mob>", MiscUtil.snakeCaseToUpperCamelCase(mob.name()))); sendMessage(message.replace("<mob>", MiscUtil.snakeCaseToUpperCamelCase(mob.name())));
} }
} else if (type.equals(ObjectiveType.SHEAR_SHEEP)) { } else if (type.equals(ObjectiveType.SHEAR_SHEEP)) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "shearSheep"); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "shearSheep");
@ -2971,7 +2963,7 @@ public class Quester implements Comparable<Quester> {
// Legacy // Legacy
message += ChatColor.GREEN + ": " + goal.getAmount() + "/" + goal.getAmount(); message += ChatColor.GREEN + ": " + goal.getAmount() + "/" + goal.getAmount();
} }
p.sendMessage(message); sendMessage(message);
} else if (type.equals(ObjectiveType.REACH_LOCATION)) { } else if (type.equals(ObjectiveType.REACH_LOCATION)) {
String obj = Lang.get(p, "goTo"); String obj = Lang.get(p, "goTo");
try { try {
@ -2983,7 +2975,7 @@ public class Quester implements Comparable<Quester> {
obj = obj.replace("<location>", "ERROR"); obj = obj.replace("<location>", "ERROR");
} }
final String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj; final String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj;
p.sendMessage(message); sendMessage(message);
} else if (co != null) { } else if (co != null) {
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + co.getDisplay(); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + co.getDisplay();
int index = -1; int index = -1;
@ -3006,7 +2998,7 @@ public class Quester implements Comparable<Quester> {
if (co.canShowCount()) { if (co.canShowCount()) {
message = message.replace("%count%", goal.getAmount() + "/" + goal.getAmount()); message = message.replace("%count%", goal.getAmount() + "/" + goal.getAmount());
} }
p.sendMessage(message); sendMessage(message);
} }
if (testComplete(quest)) { if (testComplete(quest)) {
quest.nextStage(this, true); quest.nextStage(this, true);
@ -3693,10 +3685,8 @@ public class Quester implements Comparable<Quester> {
} }
} }
if (!exists) { if (!exists) {
if (getPlayer() != null && getPlayer().isOnline()) { sendMessage(ChatColor.RED + Lang.get("questNotExist").replace("<quest>", ChatColor.DARK_PURPLE
getPlayer().sendMessage(ChatColor.RED + Lang.get("questNotExist") + quest.getName() + ChatColor.RED));
.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.RED));
}
} }
} }
} }
@ -3924,13 +3914,13 @@ public class Quester implements Comparable<Quester> {
final Stage stage = getCurrentStage(quest); final Stage stage = getCurrentStage(quest);
if (stage != null) { if (stage != null) {
quest.updateCompass(Quester.this, stage); quest.updateCompass(Quester.this, stage);
if (notify && getPlayer().isOnline()) { if (notify) {
getPlayer().sendMessage(ChatColor.YELLOW + Lang.get(getPlayer(), "compassSet") sendMessage(ChatColor.YELLOW + Lang.get(getPlayer(), "compassSet")
.replace("<quest>", ChatColor.GOLD + quest.getName() + ChatColor.YELLOW)); .replace("<quest>", ChatColor.GOLD + quest.getName() + ChatColor.YELLOW));
} }
} }
} else { } else {
getPlayer().sendMessage(ChatColor.RED + Lang.get(getPlayer(), "journalNoQuests") sendMessage(ChatColor.RED + Lang.get(getPlayer(), "journalNoQuests")
.replace("<journal>", Lang.get(getPlayer(), "journalTitle"))); .replace("<journal>", Lang.get(getPlayer(), "journalTitle")));
} }
} }
@ -4106,7 +4096,7 @@ public class Quester implements Comparable<Quester> {
final String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD final String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE + quest.getName() + ChatColor.GOLD
+ " -\n" + "\n" + ChatColor.RESET + quest.getDescription() + "\n"; + " -\n" + "\n" + ChatColor.RESET + quest.getDescription() + "\n";
for (final String msg : s.split("<br>")) { for (final String msg : s.split("<br>")) {
getPlayer().sendMessage(msg); sendMessage(msg);
} }
if (!plugin.getSettings().canAskConfirmation()) { if (!plugin.getSettings().canAskConfirmation()) {
takeQuest(quest, false); takeQuest(quest, false);
@ -4115,7 +4105,7 @@ public class Quester implements Comparable<Quester> {
} }
return true; return true;
} else { } else {
getPlayer().sendMessage(ChatColor.YELLOW + Lang.get(getPlayer(), "alreadyConversing")); sendMessage(ChatColor.YELLOW + Lang.get(getPlayer(), "alreadyConversing"));
} }
} }
} }
@ -4136,22 +4126,22 @@ public class Quester implements Comparable<Quester> {
if (getCurrentQuests().size() >= plugin.getSettings().getMaxQuests() && plugin.getSettings().getMaxQuests() if (getCurrentQuests().size() >= plugin.getSettings().getMaxQuests() && plugin.getSettings().getMaxQuests()
> 0) { > 0) {
if (giveReason) { if (giveReason) {
String msg = Lang.get(getPlayer(), "questMaxAllowed"); final String msg = Lang.get(getPlayer(), "questMaxAllowed").replace("<number>",
msg = msg.replace("<number>", String.valueOf(plugin.getSettings().getMaxQuests())); String.valueOf(plugin.getSettings().getMaxQuests()));
getPlayer().sendMessage(ChatColor.YELLOW + msg); sendMessage(ChatColor.YELLOW + msg);
} }
return false; return false;
} else if (getCurrentQuests().containsKey(quest)) { } else if (getCurrentQuests().containsKey(quest)) {
if (giveReason) { if (giveReason) {
final String msg = Lang.get(getPlayer(), "questAlreadyOn"); final String msg = Lang.get(getPlayer(), "questAlreadyOn");
getPlayer().sendMessage(ChatColor.YELLOW + msg); sendMessage(ChatColor.YELLOW + msg);
} }
return false; return false;
} else if (getCompletedQuests().contains(quest) && quest.getPlanner().getCooldown() < 0) { } else if (getCompletedQuests().contains(quest) && quest.getPlanner().getCooldown() < 0) {
if (giveReason) { if (giveReason) {
String msg = Lang.get(getPlayer(), "questAlreadyCompleted"); final String msg = Lang.get(getPlayer(), "questAlreadyCompleted")
msg = msg.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW); .replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW);
getPlayer().sendMessage(ChatColor.YELLOW + msg); sendMessage(ChatColor.YELLOW + msg);
} }
return false; return false;
} else if (plugin.getDependencies().getCitizens() != null } else if (plugin.getDependencies().getCitizens() != null
@ -4161,33 +4151,32 @@ public class Quester implements Comparable<Quester> {
getPlayer().getLocation().getWorld().getName()) getPlayer().getLocation().getWorld().getName())
&& quest.getNpcStart().getEntity().getLocation().distance(getPlayer().getLocation()) > 6.0) { && quest.getNpcStart().getEntity().getLocation().distance(getPlayer().getLocation()) > 6.0) {
if (giveReason) { if (giveReason) {
String msg = Lang.get(getPlayer(), "mustSpeakTo"); final String msg = Lang.get(getPlayer(), "mustSpeakTo").replace("<npc>", ChatColor.DARK_PURPLE
msg = msg.replace("<npc>", ChatColor.DARK_PURPLE + quest.getNpcStart().getName() + ChatColor.YELLOW); + quest.getNpcStart().getName() + ChatColor.YELLOW);
getPlayer().sendMessage(ChatColor.YELLOW + msg); sendMessage(ChatColor.YELLOW + msg);
} }
return false; return false;
} else if (quest.getBlockStart() != null) { } else if (quest.getBlockStart() != null) {
if (giveReason) { if (giveReason) {
String msg = Lang.get(getPlayer(), "noCommandStart"); final String msg = Lang.get(getPlayer(), "noCommandStart").replace("<quest>", ChatColor.DARK_PURPLE
msg = msg.replace("<quest>", ChatColor.DARK_PURPLE + quest.getName() + ChatColor.YELLOW); + quest.getName() + ChatColor.YELLOW);
getPlayer().sendMessage(ChatColor.YELLOW + msg); sendMessage(ChatColor.YELLOW + msg);
} }
return false; return false;
} else if (getCompletedQuests().contains(quest) && getRemainingCooldown(quest) > 0 } else if (getCompletedQuests().contains(quest) && getRemainingCooldown(quest) > 0
&& !quest.getPlanner().getOverride()) { && !quest.getPlanner().getOverride()) {
if (giveReason) { if (giveReason) {
String msg = Lang.get(getPlayer(), "questTooEarly"); final String msg = Lang.get(getPlayer(), "questTooEarly").replace("<quest>", ChatColor.AQUA
msg = msg.replace("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW); + quest.getName()+ ChatColor.YELLOW).replace("<time>", ChatColor.DARK_PURPLE
msg = msg.replace("<time>", ChatColor.DARK_PURPLE + MiscUtil.getTime(getRemainingCooldown(quest)) + MiscUtil.getTime(getRemainingCooldown(quest)) + ChatColor.YELLOW);
+ ChatColor.YELLOW);
getPlayer().sendMessage(ChatColor.YELLOW + msg); getPlayer().sendMessage(ChatColor.YELLOW + msg);
} }
return false; return false;
} else if (quest.getRegionStart() != null) { } else if (quest.getRegionStart() != null) {
if (!quest.isInRegionStart(this)) { if (!quest.isInRegionStart(this)) {
if (giveReason) { if (giveReason) {
String msg = Lang.get(getPlayer(), "questInvalidLocation"); final String msg = Lang.get(getPlayer(), "questInvalidLocation").replace("<quest>", ChatColor.AQUA
msg = msg.replace("<quest>", ChatColor.AQUA + quest.getName() + ChatColor.YELLOW); + quest.getName() + ChatColor.YELLOW);
getPlayer().sendMessage(ChatColor.YELLOW + msg); getPlayer().sendMessage(ChatColor.YELLOW + msg);
} }
return false; return false;
@ -4236,8 +4225,8 @@ public class Quester implements Comparable<Quester> {
if (getPlayer() == null) { if (getPlayer() == null) {
return false; return false;
} }
if (plugin.getDependencies().getWorldGuardApi() if (plugin.getDependencies().getWorldGuardApi().getApplicableRegionsIDs(getPlayer().getWorld(),
.getApplicableRegionsIDs(getPlayer().getWorld(), getPlayer().getLocation()).contains(regionID)) { getPlayer().getLocation()).contains(regionID)) {
return true; return true;
} }
return false; return false;

View File

@ -887,12 +887,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
if (!ignoreOverrides && !quester.getCurrentStage(quest).objectiveOverrides.isEmpty()) { if (!ignoreOverrides && !quester.getCurrentStage(quest).objectiveOverrides.isEmpty()) {
for (final String s: quester.getCurrentStage(quest).objectiveOverrides) { for (final String s: quester.getCurrentStage(quest).objectiveOverrides) {
String message = ChatColor.GREEN + ConfigUtil.parseString( String message = ChatColor.GREEN + (s.trim().length() > 0 ? "- " : "") + ConfigUtil
ChatColor.translateAlternateColorCodes('&', s), quest, quester.getPlayer()); .parseString(ChatColor.translateAlternateColorCodes('&', s), quest, quester.getPlayer());
if (depends.getPlaceholderApi() != null) { if (depends.getPlaceholderApi() != null) {
message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message);
} }
quester.getPlayer().sendMessage(message); quester.sendMessage(message);
} }
return; return;
} }
@ -902,7 +902,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
for (final ItemStack e2 : data.blocksBroken) { for (final ItemStack e2 : data.blocksBroken) {
if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) {
final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "break"); String message = color + "- " + Lang.get(quester.getPlayer(), "break");
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + e2.getAmount() + "/" + e.getAmount()); message = message.replace("<count>", "" + color + e2.getAmount() + "/" + e.getAmount());
} else { } else {
@ -915,7 +915,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (getSettings().canTranslateNames() && !e.hasItemMeta() && !e.getItemMeta().hasDisplayName()) { if (getSettings().canTranslateNames() && !e.hasItemMeta() && !e.getItemMeta().hasDisplayName()) {
localeQuery.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null); localeQuery.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null);
} else { } else {
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(e))); quester.sendMessage(message.replace("<item>", ItemUtil.getName(e)));
} }
} }
} }
@ -924,7 +924,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
for (final ItemStack e2 : data.blocksDamaged) { for (final ItemStack e2 : data.blocksDamaged) {
if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) {
final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "damage"); String message = color + "- " + Lang.get(quester.getPlayer(), "damage");
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + e2.getAmount() + "/" + e.getAmount()); message = message.replace("<count>", "" + color + e2.getAmount() + "/" + e.getAmount());
} else { } else {
@ -937,7 +937,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (getSettings().canTranslateNames() && !e.hasItemMeta() && !e.getItemMeta().hasDisplayName()) { if (getSettings().canTranslateNames() && !e.hasItemMeta() && !e.getItemMeta().hasDisplayName()) {
localeQuery.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null); localeQuery.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null);
} else { } else {
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(e))); quester.sendMessage(message.replace("<item>", ItemUtil.getName(e)));
} }
} }
} }
@ -946,7 +946,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
for (final ItemStack e2 : data.blocksPlaced) { for (final ItemStack e2 : data.blocksPlaced) {
if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) {
final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "place"); String message = color + "- " + Lang.get(quester.getPlayer(), "place");
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + e2.getAmount() + "/" + e.getAmount()); message = message.replace("<count>", "" + color + e2.getAmount() + "/" + e.getAmount());
} else { } else {
@ -959,7 +959,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (getSettings().canTranslateNames() && !e.hasItemMeta() && !e.getItemMeta().hasDisplayName()) { if (getSettings().canTranslateNames() && !e.hasItemMeta() && !e.getItemMeta().hasDisplayName()) {
localeQuery.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null); localeQuery.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null);
} else { } else {
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(e))); quester.sendMessage(message.replace("<item>", ItemUtil.getName(e)));
} }
} }
} }
@ -968,7 +968,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
for (final ItemStack e2 : data.blocksUsed) { for (final ItemStack e2 : data.blocksUsed) {
if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) {
final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "use"); String message = color + "- " + Lang.get(quester.getPlayer(), "use");
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + e2.getAmount() + "/" + e.getAmount()); message = message.replace("<count>", "" + color + e2.getAmount() + "/" + e.getAmount());
} else { } else {
@ -981,7 +981,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (getSettings().canTranslateNames() && !e.hasItemMeta() && !e.getItemMeta().hasDisplayName()) { if (getSettings().canTranslateNames() && !e.hasItemMeta() && !e.getItemMeta().hasDisplayName()) {
localeQuery.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null); localeQuery.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null);
} else { } else {
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(e))); quester.sendMessage(message.replace("<item>", ItemUtil.getName(e)));
} }
} }
} }
@ -990,7 +990,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
for (final ItemStack e2 : data.blocksCut) { for (final ItemStack e2 : data.blocksCut) {
if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) {
final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "cut"); String message = color + "- " + Lang.get(quester.getPlayer(), "cut");
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + e2.getAmount() + "/" + e.getAmount()); message = message.replace("<count>", "" + color + e2.getAmount() + "/" + e.getAmount());
} else { } else {
@ -1003,7 +1003,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (getSettings().canTranslateNames() && !e.hasItemMeta() && !e.getItemMeta().hasDisplayName()) { if (getSettings().canTranslateNames() && !e.hasItemMeta() && !e.getItemMeta().hasDisplayName()) {
localeQuery.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null); localeQuery.sendMessage(quester.getPlayer(), message, e.getType(), e.getDurability(), null);
} else { } else {
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(e))); quester.sendMessage(message.replace("<item>", ItemUtil.getName(e)));
} }
} }
} }
@ -1015,7 +1015,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
final int amt = is.getAmount(); final int amt = is.getAmount();
final ChatColor color = crafted < amt ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = crafted < amt ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "craftItem"); String message = color + "- " + Lang.get(quester.getPlayer(), "craftItem");
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + crafted + "/" + is.getAmount()); message = message.replace("<count>", "" + color + crafted + "/" + is.getAmount());
} else { } else {
@ -1029,7 +1029,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(), localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(),
is.getEnchantments()); is.getEnchantments());
} else { } else {
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(is))); quester.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
} }
} }
for (final ItemStack is : stage.itemsToSmelt) { for (final ItemStack is : stage.itemsToSmelt) {
@ -1039,7 +1039,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
final int amt = is.getAmount(); final int amt = is.getAmount();
final ChatColor color = smelted < amt ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = smelted < amt ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "smeltItem"); String message = color + "- " + Lang.get(quester.getPlayer(), "smeltItem");
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + smelted + "/" + is.getAmount()); message = message.replace("<count>", "" + color + smelted + "/" + is.getAmount());
} else { } else {
@ -1053,7 +1053,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(), localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(),
is.getEnchantments()); is.getEnchantments());
} else { } else {
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(is))); quester.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
} }
} }
for (final ItemStack is : stage.itemsToEnchant) { for (final ItemStack is : stage.itemsToEnchant) {
@ -1063,7 +1063,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
final int amt = is.getAmount(); final int amt = is.getAmount();
final ChatColor color = enchanted < amt ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = enchanted < amt ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "enchItem"); String message = color + "- " + Lang.get(quester.getPlayer(), "enchItem");
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + enchanted + "/" + is.getAmount()); message = message.replace("<count>", "" + color + enchanted + "/" + is.getAmount());
} else { } else {
@ -1084,13 +1084,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
is.getEnchantments()); is.getEnchantments());
} else { } else {
if (is.getEnchantments().isEmpty()) { if (is.getEnchantments().isEmpty()) {
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(is)) quester.sendMessage(message.replace("<item>", ItemUtil.getName(is))
.replace("<enchantment>", "") .replace("<enchantment>", "")
.replace("<level>", "") .replace("<level>", "")
.replaceAll("\\s+", " ")); .replaceAll("\\s+", " "));
} else { } else {
for (final Entry<Enchantment, Integer> e : is.getEnchantments().entrySet()) { for (final Entry<Enchantment, Integer> e : is.getEnchantments().entrySet()) {
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(is)) quester.sendMessage(message.replace("<item>", ItemUtil.getName(is))
.replace("<enchantment>", ItemUtil.getPrettyEnchantmentName(e.getKey())) .replace("<enchantment>", ItemUtil.getPrettyEnchantmentName(e.getKey()))
.replace("<level>", RomanNumeral.getNumeral(e.getValue()))); .replace("<level>", RomanNumeral.getNumeral(e.getValue())));
} }
@ -1104,7 +1104,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
final int amt = is.getAmount(); final int amt = is.getAmount();
final ChatColor color = brewed < amt ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = brewed < amt ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "brewItem"); String message = color + "- " + Lang.get(quester.getPlayer(), "brewItem");
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + brewed + "/" + is.getAmount()); message = message.replace("<count>", "" + color + brewed + "/" + is.getAmount());
} else { } else {
@ -1124,7 +1124,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(), localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(),
is.getEnchantments()); is.getEnchantments());
} else { } else {
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(is))); quester.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
} }
} }
for (final ItemStack is : stage.itemsToConsume) { for (final ItemStack is : stage.itemsToConsume) {
@ -1134,7 +1134,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
final int amt = is.getAmount(); final int amt = is.getAmount();
final ChatColor color = consumed < amt ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = consumed < amt ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "consumeItem"); String message = color + "- " + Lang.get(quester.getPlayer(), "consumeItem");
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + consumed + "/" + is.getAmount()); message = message.replace("<count>", "" + color + consumed + "/" + is.getAmount());
} else { } else {
@ -1148,12 +1148,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(), localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(),
is.getEnchantments()); is.getEnchantments());
} else { } else {
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(is))); quester.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
} }
} }
if (stage.cowsToMilk != null) { if (stage.cowsToMilk != null) {
final ChatColor color = data.getCowsMilked() < stage.cowsToMilk ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = data.getCowsMilked() < stage.cowsToMilk ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "milkCow"); String message = color + "- " + Lang.get(quester.getPlayer(), "milkCow");
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + data.getCowsMilked() + "/" + stage.cowsToMilk); message = message.replace("<count>", "" + color + data.getCowsMilked() + "/" + stage.cowsToMilk);
} else { } else {
@ -1163,11 +1163,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (depends.getPlaceholderApi() != null) { if (depends.getPlaceholderApi() != null) {
message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message);
} }
quester.getPlayer().sendMessage(message); quester.sendMessage(message);
} }
if (stage.fishToCatch != null) { if (stage.fishToCatch != null) {
final ChatColor color = data.getFishCaught() < stage.fishToCatch ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = data.getFishCaught() < stage.fishToCatch ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "catchFish"); String message = color + "- " + Lang.get(quester.getPlayer(), "catchFish");
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + data.getFishCaught() + "/" + stage.fishToCatch); message = message.replace("<count>", "" + color + data.getFishCaught() + "/" + stage.fishToCatch);
} else { } else {
@ -1177,7 +1177,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (depends.getPlaceholderApi() != null) { if (depends.getPlaceholderApi() != null) {
message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message);
} }
quester.getPlayer().sendMessage(message); quester.sendMessage(message);
} }
for (final EntityType e : stage.mobsToKill) { for (final EntityType e : stage.mobsToKill) {
for (final EntityType e2 : data.mobsKilled) { for (final EntityType e2 : data.mobsKilled) {
@ -1219,7 +1219,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (getSettings().canTranslateNames()) { if (getSettings().canTranslateNames()) {
localeQuery.sendMessage(quester.getPlayer(), message, e, null); localeQuery.sendMessage(quester.getPlayer(), message, e, null);
} else { } else {
quester.getPlayer().sendMessage(message.replace("<mob>", MiscUtil.getProperMobName(e))); quester.sendMessage(message.replace("<mob>", MiscUtil.getProperMobName(e)));
} }
} }
} }
@ -1227,7 +1227,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
if (stage.playersToKill != null) { if (stage.playersToKill != null) {
final ChatColor color = data.getPlayersKilled() < stage.playersToKill ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = data.getPlayersKilled() < stage.playersToKill ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "killPlayer"); String message = color + "- " + Lang.get(quester.getPlayer(), "killPlayer");
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + data.getPlayersKilled() + "/" + stage.playersToKill); message = message.replace("<count>", "" + color + data.getPlayersKilled() + "/" + stage.playersToKill);
} else { } else {
@ -1237,7 +1237,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (depends.getPlaceholderApi() != null) { if (depends.getPlaceholderApi() != null) {
message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message);
} }
quester.getPlayer().sendMessage(message); quester.sendMessage(message);
} }
int index = 0; int index = 0;
for (final ItemStack is : stage.itemsToDeliver) { for (final ItemStack is : stage.itemsToDeliver) {
@ -1249,7 +1249,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
final Integer npc = stage.itemDeliveryTargets.get(index); final Integer npc = stage.itemDeliveryTargets.get(index);
index++; index++;
final ChatColor color = delivered < toDeliver ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = delivered < toDeliver ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "deliver").replace("<npc>", depends.getNPCName(npc)); String message = color + "- " + Lang.get(quester.getPlayer(), "deliver").replace("<npc>", depends.getNPCName(npc));
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + delivered + "/" + toDeliver); message = message.replace("<count>", "" + color + delivered + "/" + toDeliver);
} else { } else {
@ -1263,19 +1263,19 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(), localeQuery.sendMessage(quester.getPlayer(), message, is.getType(), is.getDurability(),
is.getEnchantments()); is.getEnchantments());
} else { } else {
quester.getPlayer().sendMessage(message.replace("<item>", ItemUtil.getName(is))); quester.sendMessage(message.replace("<item>", ItemUtil.getName(is)));
} }
} }
for (final Integer n : stage.citizensToInteract) { for (final Integer n : stage.citizensToInteract) {
for (final Entry<Integer, Boolean> e : data.citizensInteracted.entrySet()) { for (final Entry<Integer, Boolean> e : data.citizensInteracted.entrySet()) {
if (e.getKey().equals(n)) { if (e.getKey().equals(n)) {
final ChatColor color = e.getValue() == false ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = e.getValue() == false ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "talkTo") String message = color + "- " + Lang.get(quester.getPlayer(), "talkTo")
.replace("<npc>", depends.getNPCName(n)); .replace("<npc>", depends.getNPCName(n));
if (depends.getPlaceholderApi() != null) { if (depends.getPlaceholderApi() != null) {
message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message);
} }
quester.getPlayer().sendMessage(message); quester.sendMessage(message);
} }
} }
} }
@ -1287,7 +1287,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
final ChatColor color = data.citizenNumKilled.get(data.citizensKilled.indexOf(n2)) final ChatColor color = data.citizenNumKilled.get(data.citizensKilled.indexOf(n2))
< stage.citizenNumToKill.get(stage.citizensToKill.indexOf(n)) == false < stage.citizenNumToKill.get(stage.citizensToKill.indexOf(n)) == false
? ChatColor.GREEN : ChatColor.GRAY; ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "kill"); String message = color + "- " + Lang.get(quester.getPlayer(), "kill");
if (message.contains("<mob>")) { if (message.contains("<mob>")) {
message = message.replace("<mob>", depends.getNPCName(n)); message = message.replace("<mob>", depends.getNPCName(n));
} else { } else {
@ -1305,7 +1305,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (depends.getPlaceholderApi() != null) { if (depends.getPlaceholderApi() != null) {
message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message);
} }
quester.getPlayer().sendMessage(message); quester.sendMessage(message);
} }
} }
} }
@ -1314,7 +1314,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
for (final Entry<EntityType, Integer> e2 : data.mobsTamed.entrySet()) { for (final Entry<EntityType, Integer> e2 : data.mobsTamed.entrySet()) {
if (e.getKey().equals(e2.getKey())) { if (e.getKey().equals(e2.getKey())) {
final ChatColor color = e2.getValue() < e.getValue() ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = e2.getValue() < e.getValue() ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "tame"); String message = color + "- " + Lang.get(quester.getPlayer(), "tame");
if (!message.contains("<mob>")) { if (!message.contains("<mob>")) {
message += " <mob>"; message += " <mob>";
} }
@ -1327,7 +1327,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (getSettings().canTranslateNames()) { if (getSettings().canTranslateNames()) {
localeQuery.sendMessage(quester.getPlayer(), message, e.getKey(), null); localeQuery.sendMessage(quester.getPlayer(), message, e.getKey(), null);
} else { } else {
quester.getPlayer().sendMessage(message.replace("<mob>", quester.sendMessage(message.replace("<mob>",
MiscUtil.getProperMobName(e.getKey()))); MiscUtil.getProperMobName(e.getKey())));
} }
} }
@ -1337,7 +1337,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
for (final Entry<DyeColor, Integer> e2 : data.sheepSheared.entrySet()) { for (final Entry<DyeColor, Integer> e2 : data.sheepSheared.entrySet()) {
if (e.getKey().equals(e2.getKey())) { if (e.getKey().equals(e2.getKey())) {
final ChatColor color = e2.getValue() < e.getValue() ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = e2.getValue() < e.getValue() ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "shearSheep"); String message = color + "- " + Lang.get(quester.getPlayer(), "shearSheep");
message = message.replace("<color>", MiscUtil.getPrettyDyeColorName(e.getKey())); message = message.replace("<color>", MiscUtil.getPrettyDyeColorName(e.getKey()));
if (message.contains("<count>")) { if (message.contains("<count>")) {
message = message.replace("<count>", "" + color + e2.getValue() + "/" + e.getValue()); message = message.replace("<count>", "" + color + e2.getValue() + "/" + e.getValue());
@ -1345,7 +1345,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
// Legacy // Legacy
message += color + ": " + e2.getValue() + "/" + e.getValue(); message += color + ": " + e2.getValue() + "/" + e.getValue();
} }
quester.getPlayer().sendMessage(message); quester.sendMessage(message);
} }
} }
} }
@ -1355,10 +1355,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (!data.hasReached.isEmpty()) { if (!data.hasReached.isEmpty()) {
final ChatColor color = data.hasReached.get(data.locationsReached.indexOf(l2)) == false final ChatColor color = data.hasReached.get(data.locationsReached.indexOf(l2)) == false
? ChatColor.GREEN : ChatColor.GRAY; ? ChatColor.GREEN : ChatColor.GRAY;
String message = color + Lang.get(quester.getPlayer(), "goTo"); String message = color + "- " + Lang.get(quester.getPlayer(), "goTo");
message = message.replace("<location>", message = message.replace("<location>",
stage.locationNames.get(stage.locationsToReach.indexOf(l))); stage.locationNames.get(stage.locationsToReach.indexOf(l)));
quester.getPlayer().sendMessage(message); quester.sendMessage(message);
} }
} }
} }
@ -1367,8 +1367,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (data.passwordsSaid.containsKey(s)) { if (data.passwordsSaid.containsKey(s)) {
final Boolean b = data.passwordsSaid.get(s); final Boolean b = data.passwordsSaid.get(s);
final ChatColor color = b != null && !b == false ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = b != null && !b == false ? ChatColor.GREEN : ChatColor.GRAY;
final String message = color + s; final String message = color + "- " + s;
quester.getPlayer().sendMessage(message); quester.sendMessage(message);
} }
} }
for (final CustomObjective co : stage.customObjectives) { for (final CustomObjective co : stage.customObjectives) {
@ -1411,10 +1411,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
countsIndex++; countsIndex++;
} }
for (final String s : unfinished) { for (final String s : unfinished) {
quester.getPlayer().sendMessage(ChatColor.GREEN + s); quester.sendMessage(ChatColor.GREEN + "- " + s);
} }
for (final String s : finished) { for (final String s : finished) {
quester.getPlayer().sendMessage(ChatColor.GRAY + s); quester.sendMessage(ChatColor.GRAY + "- " + s);
} }
} }
} }
@ -1444,9 +1444,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
} }
if ((available.size() + rows) <= (page * rows) || available.size() == 0) { if ((available.size() + rows) <= (page * rows) || available.size() == 0) {
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "pageNotExist")); quester.sendMessage(ChatColor.YELLOW + Lang.get(player, "pageNotExist"));
} else { } else {
player.sendMessage(ChatColor.GOLD + Lang.get(player, "questListTitle")); quester.sendMessage(ChatColor.GOLD + Lang.get(player, "questListTitle"));
int fromOrder = (page - 1) * rows; int fromOrder = (page - 1) * rows;
List<Quest> subQuests; List<Quest> subQuests;
if (available.size() >= (fromOrder + rows)) { if (available.size() >= (fromOrder + rows)) {
@ -1457,9 +1457,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
fromOrder++; fromOrder++;
for (final Quest q : subQuests) { for (final Quest q : subQuests) {
if (quester.canAcceptOffer(q, false)) { if (quester.canAcceptOffer(q, false)) {
player.sendMessage(ChatColor.YELLOW + Integer.toString(fromOrder) + ". " + q.getName()); quester.sendMessage(ChatColor.YELLOW + Integer.toString(fromOrder) + ". " + q.getName());
} else { } else {
player.sendMessage(ChatColor.GRAY + Integer.toString(fromOrder) + ". " + q.getName()); quester.sendMessage(ChatColor.GRAY + Integer.toString(fromOrder) + ". " + q.getName());
} }
fromOrder++; fromOrder++;
} }
@ -1467,13 +1467,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
String msg = Lang.get(player, "pageFooter"); String msg = Lang.get(player, "pageFooter");
msg = msg.replace("<current>", String.valueOf(page)); msg = msg.replace("<current>", String.valueOf(page));
msg = msg.replace("<all>", String.valueOf(numPages)); msg = msg.replace("<all>", String.valueOf(numPages));
player.sendMessage(ChatColor.GOLD + msg); quester.sendMessage(ChatColor.GOLD + msg);
} }
} else { } else {
if ((quests.size() + rows) <= (page * rows) || quests.size() == 0) { if ((quests.size() + rows) <= (page * rows) || quests.size() == 0) {
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "pageNotExist")); quester.sendMessage(ChatColor.YELLOW + Lang.get(player, "pageNotExist"));
} else { } else {
player.sendMessage(ChatColor.GOLD + Lang.get(player, "questListTitle")); quester.sendMessage(ChatColor.GOLD + Lang.get(player, "questListTitle"));
int fromOrder = (page - 1) * rows; int fromOrder = (page - 1) * rows;
List<Quest> subQuests; List<Quest> subQuests;
if (quests.size() >= (fromOrder + rows)) { if (quests.size() >= (fromOrder + rows)) {
@ -1484,9 +1484,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
fromOrder++; fromOrder++;
for (final Quest q : subQuests) { for (final Quest q : subQuests) {
if (quester.canAcceptOffer(q, false)) { if (quester.canAcceptOffer(q, false)) {
player.sendMessage(ChatColor.YELLOW + Integer.toString(fromOrder) + ". " + q.getName()); quester.sendMessage(ChatColor.YELLOW + Integer.toString(fromOrder) + ". " + q.getName());
} else { } else {
player.sendMessage(ChatColor.GRAY + Integer.toString(fromOrder) + ". " + q.getName()); quester.sendMessage(ChatColor.GRAY + Integer.toString(fromOrder) + ". " + q.getName());
} }
fromOrder++; fromOrder++;
} }
@ -1494,7 +1494,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
String msg = Lang.get(player, "pageFooter"); String msg = Lang.get(player, "pageFooter");
msg = msg.replace("<current>", String.valueOf(page)); msg = msg.replace("<current>", String.valueOf(page));
msg = msg.replace("<all>", String.valueOf(numPages)); msg = msg.replace("<all>", String.valueOf(numPages));
player.sendMessage(ChatColor.GOLD + msg); quester.sendMessage(ChatColor.GOLD + msg);
} }
} }
} }

View File

@ -204,9 +204,9 @@ public class CmdExecutor implements CommandExecutor {
final Stage stage = quester.getCurrentStage(q); final Stage stage = quester.getCurrentStage(q);
q.updateCompass(quester, stage); q.updateCompass(quester, stage);
if (plugin.getQuester(player.getUniqueId()).getQuestData(q).getDelayStartTime() == 0) { if (plugin.getQuester(player.getUniqueId()).getQuestData(q).getDelayStartTime() == 0) {
String msg = Lang.get(player, "questObjectivesTitle"); final String msg = Lang.get(player, "questCommandTitle")
msg = msg.replace("<quest>", q.getName()); .replace("<quest>", q.getName());
player.sendMessage(ChatColor.GOLD + msg); quester.sendMessage(ChatColor.GOLD + msg);
plugin.showObjectives(q, quester, false); plugin.showObjectives(q, quester, false);
} else { } else {
final long time = plugin.getQuester(player.getUniqueId()).getStageTime(q); final long time = plugin.getQuester(player.getUniqueId()).getStageTime(q);
@ -214,11 +214,11 @@ public class CmdExecutor implements CommandExecutor {
+ Lang.get(player, "plnTooEarly"); + Lang.get(player, "plnTooEarly");
msg = msg.replace("<quest>", q.getName()); msg = msg.replace("<quest>", q.getName());
msg = msg.replace("<time>", MiscUtil.getTime(time)); msg = msg.replace("<time>", MiscUtil.getTime(time));
player.sendMessage(msg); quester.sendMessage(msg);
} }
} }
} else { } else {
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "noActiveQuest")); quester.sendMessage(ChatColor.YELLOW + Lang.get(player, "noActiveQuest"));
} }
} else { } else {
showQuestDetails(cs, args); showQuestDetails(cs, args);

View File

@ -569,7 +569,7 @@ overrideCreateSet: "Set details list override"
overrideCreateEnter: "Enter replacement text, <clear>, <cancel>" overrideCreateEnter: "Enter replacement text, <clear>, <cancel>"
questObjectivesTitle: "---(<quest>)---" questObjectivesTitle: "---(<quest>)---"
questCompleteTitle: '**QUEST COMPLETE: <quest>**' questCompleteTitle: '**QUEST COMPLETE: <quest>**'
questRewardsTitle: "Rewards:" questRewardsTitle: "Rewards"
questFailed: "*QUEST FAILED*" questFailed: "*QUEST FAILED*"
questMaxAllowed: "You may only have up to <number> quests." questMaxAllowed: "You may only have up to <number> quests."
questAlreadyOn: "You are already on that quest!" questAlreadyOn: "You are already on that quest!"