mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-15 07:05:51 +01:00
Supply external conversation hooks, part 10. Fixes #570
This commit is contained in:
parent
b584a4b0f8
commit
f8fa9dc57c
@ -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<String> 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<Enchantment, Material> 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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user