diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java index 57e995c6d..64c28dcab 100644 --- a/main/src/main/java/me/blackvein/quests/Quester.java +++ b/main/src/main/java/me/blackvein/quests/Quester.java @@ -543,7 +543,7 @@ public class Quester { * * @param quest The quest to get objectives of * @param ignoreOverrides Whether to ignore objective-overrides - * @return + * @return List of detailed objectives */ @SuppressWarnings("deprecation") public LinkedList getObjectives(Quest quest, boolean ignoreOverrides) { @@ -635,10 +635,10 @@ public class Quester { int amt = is.getAmount(); if (crafted < amt) { String obj = Lang.get(getPlayer(), "craft") + " " + ItemUtil.getName(is); - unfinishedObjectives.add(ChatColor.GREEN + obj + ": " + crafted + "/" + amt); + unfinishedObjectives.add(ChatColor.GREEN + obj + ChatColor.GREEN + ": " + crafted + "/" + amt); } else { String obj = Lang.get(getPlayer(), "craft") + " " + ItemUtil.getName(is); - finishedObjectives.add(ChatColor.GRAY + obj + ": " + crafted + "/" + amt); + finishedObjectives.add(ChatColor.GRAY + obj + ChatColor.GRAY + ": " + crafted + "/" + amt); } } for (ItemStack is : getCurrentStage(quest).itemsToSmelt) { @@ -649,10 +649,10 @@ public class Quester { int amt = is.getAmount(); if (smelted < amt) { String obj = Lang.get(getPlayer(), "smelt") + " " + ItemUtil.getName(is); - unfinishedObjectives.add(ChatColor.GREEN + obj + ": " + smelted + "/" + amt); + unfinishedObjectives.add(ChatColor.GREEN + obj + ChatColor.GREEN + ": " + smelted + "/" + amt); } else { String obj = Lang.get(getPlayer(), "smelt") + " " + ItemUtil.getName(is); - finishedObjectives.add(ChatColor.GRAY + obj + ": " + smelted + "/" + amt); + finishedObjectives.add(ChatColor.GRAY + obj + ChatColor.GRAY + ": " + smelted + "/" + amt); } } Map set; @@ -706,10 +706,10 @@ public class Quester { int amt = is.getAmount(); if (brewed < amt) { String obj = Lang.get(getPlayer(), "brew") + " " + ItemUtil.getName(is); - unfinishedObjectives.add(ChatColor.GREEN + obj + ": " + brewed + "/" + amt); + unfinishedObjectives.add(ChatColor.GREEN + obj + ChatColor.GREEN + ": " + brewed + "/" + amt); } else { String obj = Lang.get(getPlayer(), "brew") + " " + ItemUtil.getName(is); - finishedObjectives.add(ChatColor.GRAY + obj + ": " + brewed + "/" + amt); + finishedObjectives.add(ChatColor.GRAY + obj + ChatColor.GRAY + ": " + brewed + "/" + amt); } } if (getCurrentStage(quest).fishToCatch != null) { @@ -2501,12 +2501,12 @@ public class Quester { data.set("amountsCompleted", list2); } // #getPlayer is faster - OfflinePlayer represented_player = getPlayer(); - if (represented_player == null) { - represented_player = getOfflinePlayer(); + OfflinePlayer representedPlayer = getPlayer(); + if (representedPlayer == null) { + representedPlayer = getOfflinePlayer(); } data.set("hasJournal", hasJournal); - data.set("lastKnownName", represented_player.getName()); + data.set("lastKnownName", representedPlayer.getName()); return data; } diff --git a/main/src/main/java/me/blackvein/quests/events/command/QuestsCommandEvent.java b/main/src/main/java/me/blackvein/quests/events/command/QuestsCommandEvent.java new file mode 100644 index 000000000..b2f12de70 --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/events/command/QuestsCommandEvent.java @@ -0,0 +1,29 @@ +package me.blackvein.quests.events.command; + +import me.blackvein.quests.Quester; +import me.blackvein.quests.events.QuestsEvent; + +/** + * Represents a Quests command-related event + */ +public abstract class QuestsCommandEvent extends QuestsEvent { + protected Quester quester; + + public QuestsCommandEvent(final Quester quester) { + this.quester = quester; + } + + public QuestsCommandEvent(final Quester quester, boolean async) { + super(async); + this.quester = quester; + } + + /** + * Returns the quester involved in this event + * + * @return Quester which is involved in this event + */ + public final Quester getQuester() { + return quester; + } +} \ No newline at end of file diff --git a/main/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsJournalEvent.java b/main/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsJournalEvent.java new file mode 100644 index 000000000..7e411b156 --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/events/command/QuestsCommandPreQuestsJournalEvent.java @@ -0,0 +1,34 @@ +package me.blackvein.quests.events.command; + +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +import me.blackvein.quests.Quester; + +public class QuestsCommandPreQuestsJournalEvent extends QuestsCommandEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancel = false; + + public QuestsCommandPreQuestsJournalEvent(Quester quester) { + super(quester); + } + + @Override + public boolean isCancelled() { + return cancel; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java b/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java index f65b45f9c..d415e4bfe 100644 --- a/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java +++ b/main/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java @@ -30,6 +30,7 @@ import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; import me.blackvein.quests.Requirements; import me.blackvein.quests.Stage; +import me.blackvein.quests.events.command.QuestsCommandPreQuestsJournalEvent; import me.blackvein.quests.events.editor.quests.QuestsEditorPreOpenMainPromptEvent; import me.blackvein.quests.events.quest.QuestQuitEvent; import me.blackvein.quests.exceptions.InvalidStageException; @@ -582,6 +583,12 @@ public class CmdExecutor implements CommandExecutor { @SuppressWarnings("deprecation") private void questsJournal(final Player player) { Quester quester = plugin.getQuester(player.getUniqueId()); + QuestsCommandPreQuestsJournalEvent preEvent = new QuestsCommandPreQuestsJournalEvent(quester); + plugin.getServer().getPluginManager().callEvent(preEvent); + if (preEvent.isCancelled()) { + return; + } + Inventory inv = player.getInventory(); if (quester.hasJournal) { ItemStack[] arr = inv.getContents();