Update toggle for cancel action timer, fixes #1941

This commit is contained in:
PikaMug 2022-05-07 02:24:39 -04:00
parent 56ccaaab32
commit 5ef365c861
9 changed files with 48 additions and 46 deletions

View File

@ -1173,8 +1173,7 @@ public class Quest implements IQuest {
}
}
final String[] messages = {
ChatColor.GOLD + Lang.get(player, "questCommandTitle").replace("<quest>", name),
ChatColor.RED + Lang.get(player, "questFailed")
ChatColor.RED + Lang.get(player, "questFailed").replace("<quest>", name)
};
quester.quitQuest(this, messages);
if (player.isOnline()) {

View File

@ -417,7 +417,8 @@ public class Action implements IAction {
}
if (timer > 0) {
player.sendMessage(ChatColor.GREEN + Lang.get(player, "timerStart")
.replace("<time>", ChatColor.RED + MiscUtil.getTime(timer * 1000L) + ChatColor.GREEN));
.replace("<time>", ChatColor.RED + MiscUtil.getTime(timer * 1000L) + ChatColor.GREEN)
.replace("<quest>", ChatColor.GOLD + quest.getName() + ChatColor.GREEN));
if (timer > 60) {
quester.getTimers().put(new ActionTimer(quester, quest, 60, false)
.runTaskLater(plugin, (timer - 60) * 20L).getTaskId(), quest);

View File

@ -444,9 +444,9 @@ public class BukkitActionFactory implements ActionFactory, ConversationAbandoned
}
}
if (context.getSessionData(CK.E_CANCEL_TIMER) != null) {
final String s = (String) context.getSessionData(CK.E_CANCEL_TIMER);
if (s != null && s.equalsIgnoreCase(Lang.get("yesWord"))) {
section.set("cancel-timer", true);
final Boolean b = (Boolean) context.getSessionData(CK.E_CANCEL_TIMER);
if (b != null) {
section.set("cancel-timer", b);
}
}
if (context.getSessionData(CK.E_DENIZEN) != null) {

View File

@ -12,10 +12,6 @@
package me.blackvein.quests.convo.actions.tasks;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt;
import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt;
@ -25,6 +21,9 @@ import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenStringProm
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import org.jetbrains.annotations.NotNull;
public class TimerPrompt extends ActionsEditorNumericPrompt {
@ -89,8 +88,13 @@ public class TimerPrompt extends ActionsEditorNumericPrompt {
}
}
case 2:
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.E_CANCEL_TIMER) + ChatColor.GRAY
+ ")";
if (context.getSessionData(CK.E_CANCEL_TIMER) == null) {
return ChatColor.GRAY + "(" + ChatColor.RED + Lang.get("false") + ChatColor.GRAY + ")";
} else {
final Boolean timerOpt = (Boolean) context.getSessionData(CK.E_CANCEL_TIMER);
return ChatColor.GRAY + "(" + (Boolean.TRUE.equals(timerOpt) ? ChatColor.GREEN + Lang.get("true")
: ChatColor.RED + Lang.get("false")) + ChatColor.GRAY + ")";
}
case 3:
return "";
default:
@ -101,7 +105,7 @@ public class TimerPrompt extends ActionsEditorNumericPrompt {
@Override
public @NotNull String getBasicPromptText(final ConversationContext context) {
if (context.getSessionData(CK.E_CANCEL_TIMER) == null) {
context.setSessionData(CK.E_CANCEL_TIMER, Lang.get("noWord"));
context.setSessionData(CK.E_CANCEL_TIMER, false);
}
final ActionsEditorPostOpenNumericPromptEvent event
@ -123,11 +127,11 @@ public class TimerPrompt extends ActionsEditorNumericPrompt {
case 1:
return new TimerFailPrompt(context);
case 2:
final String s = (String) context.getSessionData(CK.E_CANCEL_TIMER);
if (s != null && s.equalsIgnoreCase(Lang.get("yesWord"))) {
context.setSessionData(CK.E_CANCEL_TIMER, Lang.get("noWord"));
final Boolean b = (Boolean) context.getSessionData(CK.E_CANCEL_TIMER);
if (Boolean.TRUE.equals(b)) {
context.setSessionData(CK.E_CANCEL_TIMER, false);
} else {
context.setSessionData(CK.E_CANCEL_TIMER, Lang.get("yesWord"));
context.setSessionData(CK.E_CANCEL_TIMER, true);
}
return new TimerPrompt(context);
case 3:

View File

@ -330,7 +330,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "1" + ChatColor.RESET + " = " + ChatColor.GRAY
+ Lang.get("everything");
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "2" + ChatColor.RESET + " = " + ChatColor.GRAY
+ Lang.get("objectives");;
+ Lang.get("objectives");
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "3" + ChatColor.RESET + " = " + ChatColor.GRAY
+ Lang.get("stageEditorStages");
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "4" + ChatColor.RESET + " = " + ChatColor.GRAY
@ -460,37 +460,31 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
final Boolean commandsOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_COMMANDS);
if (commandsOpt == null) {
final boolean defaultOpt = new BukkitOptions().canAllowCommands();
return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN
+ Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED
+ Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")";
return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN + Lang.get("true")
: ChatColor.RED + Lang.get("false")) + ChatColor.GRAY + ")";
} else {
return ChatColor.GRAY + "(" + (commandsOpt ? ChatColor.GREEN
+ Lang.get(String.valueOf(commandsOpt)) : ChatColor.RED
+ Lang.get(String.valueOf(commandsOpt))) + ChatColor.GRAY + ")";
return ChatColor.GRAY + "(" + (commandsOpt ? ChatColor.GREEN + Lang.get("true")
: ChatColor.RED + Lang.get("false")) + ChatColor.GRAY + ")";
}
case 2:
final Boolean quittingOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_QUITTING);
if (quittingOpt == null) {
final boolean defaultOpt = new BukkitOptions().canAllowQuitting();
return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN
+ Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED
+ Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")";
return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN + Lang.get("true")
: ChatColor.RED + Lang.get("false")) + ChatColor.GRAY + ")";
} else {
return ChatColor.GRAY + "(" + (quittingOpt ? ChatColor.GREEN
+ Lang.get(String.valueOf(quittingOpt)) : ChatColor.RED
+ Lang.get(String.valueOf(quittingOpt))) + ChatColor.GRAY + ")";
return ChatColor.GRAY + "(" + (quittingOpt ? ChatColor.GREEN + Lang.get("true")
: ChatColor.RED + Lang.get("false")) + ChatColor.GRAY + ")";
}
case 3:
final Boolean ignoreOpt = (Boolean) context.getSessionData(CK.OPT_IGNORE_SILK_TOUCH);
if (ignoreOpt == null) {
final boolean defaultOpt = new BukkitOptions().canIgnoreSilkTouch();
return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN
+ Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED
+ Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")";
return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN + Lang.get("true")
: ChatColor.RED + Lang.get("false")) + ChatColor.GRAY + ")";
} else {
return ChatColor.GRAY + "(" + (ignoreOpt ? ChatColor.GREEN
+ Lang.get(String.valueOf(ignoreOpt)) : ChatColor.RED
+ Lang.get(String.valueOf(ignoreOpt))) + ChatColor.GRAY + ")";
return ChatColor.GRAY + "(" + (ignoreOpt ? ChatColor.GREEN + Lang.get("true")
: ChatColor.RED + Lang.get("false")) + ChatColor.GRAY + ")";
}
case 4:
return "";

View File

@ -209,7 +209,7 @@ public class BlockListener implements Listener {
if (plugin.canUseQuests(player.getUniqueId())) {
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState()
.getData().toItemStack().getDurability());
final IQuester quester = plugin.getQuester(player.getUniqueId());
final Quester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType placeType = ObjectiveType.PLACE_BLOCK;
final ObjectiveType breakType = ObjectiveType.BREAK_BLOCK;
final Set<String> dispatchedQuestIDs = new HashSet<>();
@ -220,9 +220,11 @@ public class BlockListener implements Listener {
}
if (quester.getCurrentQuestsTemp().containsKey(quest)) {
IStage currentStage = quester.getCurrentStage(quest);
final IStage currentStage = quester.getCurrentStage(quest);
if (currentStage.containsObjective(placeType)) quester.placeBlock(quest, blockItemStack);
if (currentStage.containsObjective(placeType)) {
quester.placeBlock(quest, blockItemStack);
}
if (currentStage.containsObjective(breakType)) {
for (final ItemStack is : quester.getQuestData(quest).blocksBroken) {
@ -235,7 +237,7 @@ public class BlockListener implements Listener {
}
final QuesterPreUpdateObjectiveEvent preEvent
= new QuesterPreUpdateObjectiveEvent((Quester) quester, quest,
= new QuesterPreUpdateObjectiveEvent(quester, quest,
new BukkitObjective(placeType, is.getAmount(), toBreak.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent);
@ -245,7 +247,7 @@ public class BlockListener implements Listener {
quester.getQuestData(quest).blocksBroken.set(index, is);
final QuesterPostUpdateObjectiveEvent postEvent
= new QuesterPostUpdateObjectiveEvent((Quester) quester, quest,
= new QuesterPostUpdateObjectiveEvent(quester, quest,
new BukkitObjective(placeType, newAmount, toBreak.getAmount()));
plugin.getServer().getPluginManager().callEvent(postEvent);
}

View File

@ -40,7 +40,8 @@ public class QuestsLog4JFilter extends AbstractFilter {
return Result.DENY;
}
// Paper outputs errors when dependencies for module events are missing
return message.startsWith("Plugin Quests") ? Result.DENY : Result.NEUTRAL;
return (message.contains("Plugin Quests") && message.contains("failed to register events"))
? Result.DENY : Result.NEUTRAL;
}
@Override

View File

@ -41,7 +41,8 @@ public class ActionTimer extends BukkitRunnable {
quester.updateJournal();
} else {
quester.getPlayer().sendMessage(ChatColor.GREEN + Lang.get(quester.getPlayer(), "timerMessage")
.replace("<time>", ChatColor.RED + MiscUtil.getTime(time * 1000L) + ChatColor.GREEN));
.replace("<time>", ChatColor.RED + MiscUtil.getTime(time * 1000L) + ChatColor.GREEN)
.replace("<quest>", ChatColor.GOLD + quest.getName() + ChatColor.GREEN));
}
}
}

View File

@ -576,7 +576,7 @@ overrideCreateEnter: "Enter replacement text, <clear>, <cancel>"
questObjectivesTitle: "---(<quest>)---"
questCompleteTitle: '**QUEST COMPLETE: <quest>**'
questRewardsTitle: "Rewards"
questFailed: "*QUEST FAILED*"
questFailed: "**QUEST FAILED: <quest>**"
questMaxAllowed: "You may only have up to <number> quests."
questAlreadyOn: "You are already on that quest!"
questTooEarly: "You may not take <quest> again for another <time>."
@ -805,8 +805,8 @@ blocksWithin: "within <amount> blocks of"
experience: "Experience"
partiesExperience: "Parties experience"
timePrompt: "Enter amount of time (in seconds), <clear>, <cancel>"
timerMessage: "Time left to finish the quest/stage: <time>"
timerStart: "You have <time> to finish this quest/stage"
timerMessage: "Time left to progress <quest>: <time>"
timerStart: "You have <time> to progress <quest>."
noPermission: "You do not have permission to do that."
trialMode: "Trial Mode"
modeDeny: "You are unable to do that in <mode>."