Pass plugin to abandon prompt, fixes #2085

This commit is contained in:
PikaMug 2023-04-02 13:33:32 -04:00
parent e5322074b8
commit 8b9385c0de
5 changed files with 15 additions and 2 deletions

View File

@ -70,6 +70,7 @@ public abstract class CustomRequirement {
/**
* @deprecated Use {@link #setItem(String, short)}
*/
@Deprecated
public void addItem(final String type, final short durability) {
setItem(type, durability);
}

View File

@ -70,6 +70,7 @@ public abstract class CustomReward {
/**
* @deprecated Use {@link #setItem(String, short)}
*/
@Deprecated
public void addItem(final String type, final short durability) {
setItem(type, durability);
}

View File

@ -168,6 +168,7 @@ public class CustomObjective implements ICustomObjective, Listener {
/**
* @deprecated Do not use
*/
@Deprecated
public Map<String, Object> getDataForPlayerTemp(final Player player, final ICustomObjective customObj,
final IQuest quest) {
final IQuester quester = plugin.getQuester(player.getUniqueId());
@ -208,6 +209,7 @@ public class CustomObjective implements ICustomObjective, Listener {
/**
* @deprecated Do not use
*/
@Deprecated
public void incrementObjectiveTemp(final Player player, final ICustomObjective obj, final int count,
final IQuest quest) {
final Quester quester = plugin.getQuester(player.getUniqueId());

View File

@ -875,7 +875,7 @@ public class Quester implements IQuester {
if (settings.canConfirmAbandon()) {
final ConversationFactory cf = new ConversationFactory(plugin).withModality(false)
.withPrefix(context -> ChatColor.GRAY.toString())
.withFirstPrompt(new QuestAbandonPrompt()).withTimeout(settings.getAcceptTimeout())
.withFirstPrompt(new QuestAbandonPrompt(plugin)).withTimeout(settings.getAcceptTimeout())
.thatExcludesNonPlayersWithMessage("Console may not perform this conversation!")
.addConversationAbandonedListener(plugin.getConvoListener());
cf.buildConversation(getPlayer()).begin();

View File

@ -18,11 +18,20 @@ public class QuestAbandonPrompt extends MiscStringPrompt {
private ConversationContext context;
private final Quests plugin;
/**
* @deprecated
*/
@Deprecated
public QuestAbandonPrompt() {
super(null);
plugin = null;
}
public QuestAbandonPrompt(Quests plugin) {
super(null);
this.plugin = plugin;
}
public QuestAbandonPrompt(final ConversationContext context) {
super(context);
plugin = (Quests)context.getPlugin();
@ -75,7 +84,7 @@ public class QuestAbandonPrompt extends MiscStringPrompt {
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
this.context = context;
if (plugin == null) {
return ChatColor.YELLOW + Lang.get("unknownError");
return ChatColor.YELLOW + Lang.get("itemCreateCriticalError");
}
final MiscPostQuestAbandonEvent event = new MiscPostQuestAbandonEvent(context, this);