refactor: getAction in context
This commit is contained in:
@@ -87,6 +87,10 @@ public class CommandContext {
|
||||
return returnLowerCase ? string.toLowerCase() : string;
|
||||
}
|
||||
|
||||
public String getAction () throws CommandException {
|
||||
return getString(false, true, true, "action");
|
||||
}
|
||||
|
||||
public Integer getInteger (boolean required) throws CommandException {
|
||||
final String string = getString(false, required, "integer");
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class CloopCommand extends Command {
|
||||
public Component execute(CommandContext context) throws CommandException {
|
||||
final Bot bot = context.bot;
|
||||
|
||||
final String action = context.getString(false, true, true);
|
||||
final String action = context.getAction();
|
||||
|
||||
switch (action) {
|
||||
case "add" -> {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class EvalCommand extends Command {
|
||||
|
||||
if (!bot.eval.connected) throw new CommandException(Component.text("Eval server is not online"));
|
||||
|
||||
final String action = context.getString(false, true);
|
||||
final String action = context.getAction();
|
||||
|
||||
switch (action) {
|
||||
case "run" -> {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class IPFilterCommand extends Command {
|
||||
public Component execute(CommandContext context) throws CommandException {
|
||||
final Bot bot = context.bot;
|
||||
|
||||
final String action = context.getString(false, true, true);
|
||||
final String action = context.getAction();
|
||||
|
||||
switch (action) {
|
||||
case "add" -> {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class MailCommand extends Command {
|
||||
|
||||
// kinda messy ngl
|
||||
|
||||
final String action = context.getString(false, true, true);
|
||||
final String action = context.getAction();
|
||||
|
||||
switch (action) {
|
||||
case "send" -> DatabasePlugin.executorService.submit(() -> {
|
||||
|
||||
@@ -64,7 +64,7 @@ public class MusicCommand extends Command {
|
||||
public Component execute(CommandContext context) throws CommandException {
|
||||
if (context.bot.music.locked && !(context instanceof ConsoleCommandContext)) throw new CommandException(Component.text("Managing music is currently locked"));
|
||||
|
||||
final String action = context.getString(false, true, true);
|
||||
final String action = context.getAction();
|
||||
|
||||
root = MusicPlayerPlugin.SONG_DIR;
|
||||
return switch (action) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class WhitelistCommand extends Command {
|
||||
public Component execute(CommandContext context) throws CommandException {
|
||||
final Bot bot = context.bot;
|
||||
|
||||
final String action = context.getString(false, true, true);
|
||||
final String action = context.getAction();
|
||||
|
||||
switch (action) {
|
||||
case "enable" -> {
|
||||
|
||||
Reference in New Issue
Block a user