1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00

Merge pull request #1598 from Momshroom/master

Add confirmation to jobs skipquest and fixed it not being possible to…
This commit is contained in:
Zrips 2023-05-12 15:56:38 +03:00 committed by GitHub
commit 8f1402ff72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package com.gamingmesh.jobs.commands.list;
import java.util.List;
import com.gamingmesh.jobs.stuff.Util;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -24,8 +25,8 @@ public class skipquest implements Cmd {
LC.info_FeatureNotEnabled.sendMessage(sender);
return null;
}
if (args.length != 2 && args.length != 3) {
// Needs to allow longer so multiword quest names work
if (args.length < 2) {
return false;
}
@ -106,6 +107,23 @@ public class skipquest implements Cmd {
econ.getEconomy().withdrawPlayer(player, amount);
}
// Add confirmation if configured
if (Jobs.getGCManager().EnableConfirmation) {
java.util.UUID uuid = jPlayer.getUniqueId();
if (!Util.SKIPCONFIRM.contains(uuid)) {
Util.SKIPCONFIRM.add(uuid);
plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.SKIPCONFIRM.remove(uuid),
20 * Jobs.getGCManager().ConfirmExpiryTime);
Language.sendMessage(sender, "command.skipquest.confirmationNeed", "[questName]",
job.getDisplayName(), "[time]", Jobs.getGCManager().ConfirmExpiryTime);
return true;
}
Util.SKIPCONFIRM.remove(uuid);
}
jPlayer.replaceQuest(old);

View File

@ -482,6 +482,7 @@ public class LanguageManager {
c.get("command.skipquest.help.info", "Skip defined quest and get new one");
c.get("command.skipquest.help.args", "[jobname] [questname] (playerName)");
c.get("command.skipquest.output.questSkipForCost", "&2You skipped the quest and paid:&e %amount%$");
c.get("command.skipquest.confirmationNeed", "&cAre you sure you want to skip&e [questName]&c quest? Type the command again within&6 [time] seconds &cto confirm!");
Jobs.getGCManager().getCommandArgs().put("skipquest", Arrays.asList("[jobname]", "[questname]", "[playername]"));
c.get("command.quests.help.info", "List available quests");

View File

@ -50,6 +50,9 @@ public final class Util {
public static final List<UUID> LEAVECONFIRM = new ArrayList<>();
// for confirmation of skipping quest
public static final List<UUID> SKIPCONFIRM = new ArrayList<>();
public static List<Block> getPistonRetractBlocks(BlockPistonRetractEvent event) {
if (Version.isCurrentEqualOrHigher(Version.v1_8_R1)) {
return new ArrayList<>(event.getBlocks());

View File

@ -470,6 +470,7 @@ command:
args: '[jobname] [questname] (playerName)'
output:
questSkipForCost: '&2You skipped the quest and paid:&e %amount%$'
confirmationNeed: '&cAre you sure you want to skip&e [questName]&c quest? Type the command again within&6 [time] seconds &cto confirm!'
quests:
help:
info: List available quests