mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-11 01:41:55 +01:00
Error messages to Confirmation if not caught
This commit is contained in:
parent
7087aa2f78
commit
6f2cd157ff
@ -51,15 +51,27 @@ public class Confirmation {
|
|||||||
public void onConfirm(CMDSender sender) {
|
public void onConfirm(CMDSender sender) {
|
||||||
Consumer<Boolean> found = awaiting.getIfPresent(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("Confirmation expired, use the command again" /* TODO */);
|
||||||
found.accept(true);
|
try {
|
||||||
awaiting.invalidate(sender);
|
found.accept(true);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
sender.send("The accepted action errored upon execution: " + e /* TODO */);
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
awaiting.invalidate(sender);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCancel(CMDSender sender) {
|
public void onCancel(CMDSender sender) {
|
||||||
Consumer<Boolean> found = awaiting.getIfPresent(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("Confirmation expired, use the command again" /* TODO */);
|
||||||
found.accept(false);
|
try {
|
||||||
awaiting.invalidate(sender);
|
found.accept(false);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
sender.send("The denied action errored upon execution: " + e /* TODO */);
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
awaiting.invalidate(sender);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onAcceptCommand(CMDSender sender, Arguments arguments) {
|
public void onAcceptCommand(CMDSender sender, Arguments arguments) {
|
||||||
|
Loading…
Reference in New Issue
Block a user