mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-05 23:11:56 +01:00
Lang implemented for Confirmation
This commit is contained in:
parent
a47ce3e57e
commit
53705616b8
@ -19,6 +19,7 @@ package com.djrapitops.plan.commands.subcommands;
|
||||
import com.djrapitops.plan.commands.use.Arguments;
|
||||
import com.djrapitops.plan.commands.use.CMDSender;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.CommandLang;
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
|
||||
@ -50,11 +51,11 @@ public class Confirmation {
|
||||
|
||||
public void onConfirm(CMDSender sender) {
|
||||
Consumer<Boolean> found = awaiting.getIfPresent(sender);
|
||||
if (found == null) throw new IllegalArgumentException("Confirmation expired, use the command again" /* TODO */);
|
||||
if (found == null) throw new IllegalArgumentException(locale.getString(CommandLang.CONFIRM_EXPIRED));
|
||||
try {
|
||||
found.accept(true);
|
||||
} catch (RuntimeException e) {
|
||||
sender.send("The accepted action errored upon execution: " + e /* TODO */);
|
||||
sender.send(locale.getString(CommandLang.CONFIRM_FAIL_ACCEPT, e));
|
||||
throw e;
|
||||
} finally {
|
||||
awaiting.invalidate(sender);
|
||||
@ -63,11 +64,11 @@ public class Confirmation {
|
||||
|
||||
public void onCancel(CMDSender sender) {
|
||||
Consumer<Boolean> found = awaiting.getIfPresent(sender);
|
||||
if (found == null) throw new IllegalArgumentException("Confirmation expired, use the command again" /* TODO */);
|
||||
if (found == null) throw new IllegalArgumentException(locale.getString(CommandLang.CONFIRM_EXPIRED));
|
||||
try {
|
||||
found.accept(false);
|
||||
} catch (RuntimeException e) {
|
||||
sender.send("The denied action errored upon execution: " + e /* TODO */);
|
||||
sender.send(locale.getString(CommandLang.CONFIRM_FAIL_DENY, e));
|
||||
throw e;
|
||||
} finally {
|
||||
awaiting.invalidate(sender);
|
||||
|
@ -22,6 +22,10 @@ package com.djrapitops.plan.settings.locale.lang;
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public enum CommandLang implements Lang {
|
||||
CONFIRM_EXPIRED("Cmd Confirm - Expired", "Confirmation expired, use the command again"),
|
||||
CONFIRM_FAIL_ACCEPT("Cmd Confirm - Fail on accept", "The accepted action errored upon execution: ${0}"),
|
||||
CONFIRM_FAIL_DENY("Cmd Confirm - Fail on deny", "The denied action errored upon execution: ${0}"),
|
||||
|
||||
FAIL_REQ_ARGS("Cmd FAIL - Requires Arguments", "§cArguments required (${0}) ${1}"),
|
||||
FAIL_REQ_ONE_ARG("Cmd FAIL - Require only one Argument", "§cSingle Argument required ${1}"),
|
||||
FAIL_NO_PERMISSION("Cmd FAIL - No Permission", "§cYou do not have the required permission."),
|
||||
|
Loading…
Reference in New Issue
Block a user