diff --git a/app/src/main/java/io/github/w1ll_du/MCUtilsBot/Bot.java b/app/src/main/java/io/github/w1ll_du/MCUtilsBot/Bot.java index beb8d67..c1bd29c 100644 --- a/app/src/main/java/io/github/w1ll_du/MCUtilsBot/Bot.java +++ b/app/src/main/java/io/github/w1ll_du/MCUtilsBot/Bot.java @@ -1,20 +1,18 @@ package io.github.w1ll_du.MCUtilsBot; -import javax.security.auth.login.LoginException; -import java.io.IOException; -import java.io.FileNotFoundException; -import java.util.HashMap; -import java.util.Map; -import java.util.LinkedHashMap; -import java.nio.file.Paths; +import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; -import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; import net.dv8tion.jda.api.JDABuilder; import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; -import org.apache.commons.collections4.BidiMap; -import org.apache.commons.collections4.bidimap.DualHashBidiMap; + +import javax.security.auth.login.LoginException; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.LinkedHashMap; +import java.util.Map; public class Bot { @@ -41,6 +39,8 @@ private Bot() throws LoginException { map.put("mc_server_ip", "5678901234"); map.put("rcon_port", "25575"); map.put("rcon_password", "password"); + // xisuma's vanillatweaks + map.put("afkDis", "false"); try { writer.writeValue(Paths.get("MCUtilsConfig.json").toFile(), map); } catch (Exception ex) { diff --git a/app/src/main/java/io/github/w1ll_du/MCUtilsBot/CommandManager.java b/app/src/main/java/io/github/w1ll_du/MCUtilsBot/CommandManager.java index 0341e49..388cc0e 100644 --- a/app/src/main/java/io/github/w1ll_du/MCUtilsBot/CommandManager.java +++ b/app/src/main/java/io/github/w1ll_du/MCUtilsBot/CommandManager.java @@ -4,25 +4,25 @@ import io.github.w1ll_du.MCUtilsBot.command.ICommand; import io.github.w1ll_du.MCUtilsBot.command.commands.*; import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; -import org.apache.commons.collections4.BidiMap; import javax.annotation.Nullable; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.ArrayList; import java.util.Map; import java.util.regex.Pattern; public class CommandManager { private final List commands = new ArrayList<>(); - public CommandManager() { + public CommandManager(Map conf) { addCommand(new statsCommand()); addCommand(new cmToMCommand()); addCommand(new ticksToHours()); addCommand(new ticksToMinutes()); addCommand(new rconCommand()); + if (conf.get("afkDis").equals("true")) addCommand(new checkAFKCommand()); } @Nullable diff --git a/app/src/main/java/io/github/w1ll_du/MCUtilsBot/Listener.java b/app/src/main/java/io/github/w1ll_du/MCUtilsBot/Listener.java index 35c0ef4..e0793d4 100644 --- a/app/src/main/java/io/github/w1ll_du/MCUtilsBot/Listener.java +++ b/app/src/main/java/io/github/w1ll_du/MCUtilsBot/Listener.java @@ -1,21 +1,21 @@ package io.github.w1ll_du.MCUtilsBot; -import javax.annotation.Nonnull; - import me.duncte123.botcommons.BotCommons; +import net.dv8tion.jda.api.events.ReadyEvent; import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; -import net.dv8tion.jda.api.events.ReadyEvent; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + +import javax.annotation.Nonnull; import java.io.IOException; import java.util.Map; public class Listener extends ListenerAdapter { private static final Logger LOGGER = LoggerFactory.getLogger(Listener.class); - private final CommandManager manager = new CommandManager(); + private final CommandManager manager; Map conf; private final String prefix; private final String owner_id; @@ -24,6 +24,7 @@ public Listener(Map conf) { this.conf = conf; prefix = conf.get("prefix"); owner_id = conf.get("owner_id"); + manager = new CommandManager(conf); } @Override diff --git a/app/src/main/java/io/github/w1ll_du/MCUtilsBot/command/commands/checkAFKCommand.java b/app/src/main/java/io/github/w1ll_du/MCUtilsBot/command/commands/checkAFKCommand.java new file mode 100644 index 0000000..6b3500d --- /dev/null +++ b/app/src/main/java/io/github/w1ll_du/MCUtilsBot/command/commands/checkAFKCommand.java @@ -0,0 +1,17 @@ +package io.github.w1ll_du.MCUtilsBot.command.commands; + +import io.github.w1ll_du.MCUtilsBot.Utils; +import io.github.w1ll_du.MCUtilsBot.command.CommandContext; +import io.github.w1ll_du.MCUtilsBot.command.ICommand; + +public class checkAFKCommand implements ICommand { + @Override + public void handle(CommandContext ctx) { + ctx.getChannel().sendMessage(Utils.rconCommand("team list afkDis.afk")).queue(); + } + + @Override + public String getName() { + return "checkAFK"; + } +}