Skip to content

Commit

Permalink
add checkAFK
Browse files Browse the repository at this point in the history
  • Loading branch information
W1llDu committed Feb 1, 2022
1 parent 10ff5fa commit 2cf2c2d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
20 changes: 10 additions & 10 deletions app/src/main/java/io/github/w1ll_du/MCUtilsBot/Bot.java
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ICommand> commands = new ArrayList<>();

public CommandManager() {
public CommandManager(Map<String, String> 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
Expand Down
9 changes: 5 additions & 4 deletions app/src/main/java/io/github/w1ll_du/MCUtilsBot/Listener.java
Original file line number Diff line number Diff line change
@@ -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<String, String> conf;
private final String prefix;
private final String owner_id;
Expand All @@ -24,6 +24,7 @@ public Listener(Map<String, String> conf) {
this.conf = conf;
prefix = conf.get("prefix");
owner_id = conf.get("owner_id");
manager = new CommandManager(conf);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
}
}

0 comments on commit 2cf2c2d

Please sign in to comment.