From 11cbad3e775bea671bb37e4b3b1f59a8c96551e9 Mon Sep 17 00:00:00 2001 From: destro174 <40720638+destro174@users.noreply.github.com> Date: Fri, 9 Jul 2021 09:20:46 +0200 Subject: [PATCH] Add Minimessage --- pom.xml | 18 +- .../com/alttd/afkdectector/AFKCheckTimer.java | 15 +- .../com/alttd/afkdectector/AFKDetector.java | 168 +++--------------- .../java/com/alttd/afkdectector/Lang.java | 68 ------- .../com/alttd/afkdectector/MessageTimer.java | 19 +- .../afkdectector/afkplayer/AFKPlayer.java | 8 +- .../afkdectector/command/AFKCheckCommand.java | 15 +- .../afkdectector/command/AFKListCommand.java | 24 ++- .../afkdectector/config/AbstractConfig.java | 144 +++++++++++++++ .../com/alttd/afkdectector/config/Config.java | 70 ++++++++ .../alttd/afkdectector/config/Messages.java | 34 ++++ .../afkdectector/config/MessagesConfig.java | 31 ++++ .../com/alttd/afkdectector/util/Logger.java | 27 +++ 13 files changed, 396 insertions(+), 245 deletions(-) delete mode 100755 src/main/java/com/alttd/afkdectector/Lang.java create mode 100644 src/main/java/com/alttd/afkdectector/config/AbstractConfig.java create mode 100644 src/main/java/com/alttd/afkdectector/config/Config.java create mode 100644 src/main/java/com/alttd/afkdectector/config/Messages.java create mode 100644 src/main/java/com/alttd/afkdectector/config/MessagesConfig.java create mode 100644 src/main/java/com/alttd/afkdectector/util/Logger.java diff --git a/pom.xml b/pom.xml index 18fd552..1ce3d1c 100755 --- a/pom.xml +++ b/pom.xml @@ -31,17 +31,21 @@ - papermc - https://papermc.io/repo/repository/maven-public/ + Alttd-Nexus + http://leo:8081/snapshots/ + + + dv8tion + m2-dv8tion + https://m2.dv8tion.net/releases - - com.destroystokyo.paper - paper-api - 1.16.5-R0.1-SNAPSHOT - provided + + com.alttd + galaxy-api + 1.17-R0.1-SNAPSHOT \ No newline at end of file diff --git a/src/main/java/com/alttd/afkdectector/AFKCheckTimer.java b/src/main/java/com/alttd/afkdectector/AFKCheckTimer.java index f84414b..778efdc 100755 --- a/src/main/java/com/alttd/afkdectector/AFKCheckTimer.java +++ b/src/main/java/com/alttd/afkdectector/AFKCheckTimer.java @@ -3,6 +3,10 @@ package com.alttd.afkdectector; import java.util.UUID; import com.alttd.afkdectector.afkplayer.AFKPlayer; +import com.alttd.afkdectector.config.Config; +import com.alttd.afkdectector.config.Messages; +import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.text.minimessage.Template; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -35,7 +39,7 @@ public class AFKCheckTimer extends BukkitRunnable{ pastLocation = player.getLocation(); afkplayer.setplayerToSphereCenter(pastLocation); } - if (player.getLocation().distanceSquared(pastLocation) > plugin.radius * plugin.radius) { + if (player.getLocation().distanceSquared(pastLocation) > Config.RADIUS * Config.RADIUS) { if(player.getLocation().getYaw() != pastLocation.getYaw() && player.getLocation().getPitch() != pastLocation.getPitch()) { afkplayer.setplayerToSphereCenter(pastLocation); afkplayer.setstandingTime(System.currentTimeMillis()); @@ -51,20 +55,19 @@ public class AFKCheckTimer extends BukkitRunnable{ } } long standingTime = afkplayer.getstandingTime(); - if(System.currentTimeMillis() - standingTime > plugin.toggletime * 60 * 1000 && !afkplayer.isafk()) { + if(System.currentTimeMillis() - standingTime > Config.TOGGLETIME * 60 * 1000 && !afkplayer.isafk()) { afkplayer.setafk(true); player.setSleepingIgnored(true); //player.setCanPickupItems(false); plugin.AFKPlayers.addEntry(player.getName()); - Bukkit.broadcast( - ChatColor.translateAlternateColorCodes('&', Lang.AFKTOGGLEON.toString().replace("%player%", player.getName())), "afkdetector.notify"); + Bukkit.broadcast(MiniMessage.get().parse(Messages.AFKTOGGLEON.getMessage(), Template.of("player", player.getName())), "afkdetector.notify"); } if(System.currentTimeMillis() - standingTime > afkplayer.getafkTime() * 60 * 1000) { MessageTimer currentTimer = plugin.messageTimers.get(uuid); if(currentTimer == null) { - currentTimer = new MessageTimer(plugin, uuid, plugin.messageRepeats); + currentTimer = new MessageTimer(plugin, uuid, Config.MESSAGEREPEATS); plugin.messageTimers.put(uuid, currentTimer); - new MessageTimer(plugin, uuid, plugin.messageRepeats).init(); + new MessageTimer(plugin, uuid, Config.MESSAGEREPEATS).init(); } } else { MessageTimer currentTimer = plugin.messageTimers.get(uuid); diff --git a/src/main/java/com/alttd/afkdectector/AFKDetector.java b/src/main/java/com/alttd/afkdectector/AFKDetector.java index 0bf3fbe..3cd6bdc 100755 --- a/src/main/java/com/alttd/afkdectector/AFKDetector.java +++ b/src/main/java/com/alttd/afkdectector/AFKDetector.java @@ -3,14 +3,9 @@ package com.alttd.afkdectector; import com.alttd.afkdectector.afkplayer.AFKPlayer; import com.alttd.afkdectector.command.AFKCheckCommand; import com.alttd.afkdectector.command.AFKListCommand; -import net.kyori.adventure.audience.Audience; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scoreboard.Scoreboard; -import org.bukkit.scoreboard.ScoreboardManager; -import org.bukkit.scoreboard.Team; - +import com.alttd.afkdectector.config.Config; +import com.alttd.afkdectector.config.MessagesConfig; import org.bukkit.Bukkit; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -19,49 +14,34 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.permissions.PermissionAttachmentInfo; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scoreboard.Scoreboard; +import org.bukkit.scoreboard.ScoreboardManager; +import org.bukkit.scoreboard.Team; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.*; +import java.util.HashMap; +import java.util.UUID; public class AFKDetector extends JavaPlugin implements Listener{ + public static AFKDetector instance; + public HashMap players = new HashMap<>(); public HashMap messageTimers = new HashMap<>(); public HashMap PlayerAfkTime = new HashMap<>(); - public boolean sleepignore, serverfull, countdownenabled, fulloverride; - public int radius, flagTime, messageDelay, messageRepeats, defaultafkTime, maxafkTime, toggletime, commandcooldown, playerlimit; - public int fadein, stay, fadeout = 0; - public String title, subtitle, message, title1, title2 = ""; - public String kickCommand = "kick ${ChatColor.RED}You have been kicked for being AFK."; - /** - * Adventure - */ - private Audience audience; - - /** - * events that cancel - */ - public boolean chatWillCancel, commandWillCancel; - + public boolean fulloverride; /** * afkplayers need to be added to a team. */ Team AFKPlayers; - /** - * Messages.yml - */ - public static YamlConfiguration LANG; - public static File LANG_FILE; - - @Override public void onEnable() { try { - loadSettings(); + instance = this; + Config.reload(); + MessagesConfig.reload(); settupAfkState(); getServer().getPluginManager().registerEvents(this, this); //getCommand("afk").setExecutor(new AFKCommand(this)); @@ -101,108 +81,13 @@ public class AFKDetector extends JavaPlugin implements Listener{ AFKPlayers.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER); //AFKPlayers.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER); } - - /** - * Load the config.yml file. - * @return The config.yml config. - */ - private void loadSettings() { - saveDefaultConfig(); - - /** - * Player section - */ - sleepignore = getConfig().getBoolean("player.sleep" ,false); - radius = getConfig().getInt("player.radius", 4); - toggletime = getConfig().getInt("player.toggle-time", 5); - defaultafkTime = getConfig().getInt("player.afk-time", 5); - maxafkTime = getConfig().getInt("player.maxafk-time", 5); - serverfull = getConfig().getBoolean("player.serverfull" ,false); - playerlimit = Math.round(Bukkit.getMaxPlayers() * 90 / 100); - commandcooldown = getConfig().getInt("player.commandcooldown"); - /** - * Countdown section - */ - countdownenabled = getConfig().getBoolean("countdown.enabled" ,false); - message = getConfig().getString("countdown.message"); - title1 = getConfig().getString("countdown.title1"); - title2 = getConfig().getString("countdown.title2"); - fadein = getConfig().getInt("countdown.fadein", 10); - stay = getConfig().getInt("countdown.stay", 50); - fadeout = getConfig().getInt("countdown.fadeout", 10); - messageDelay = getConfig().getInt("countdown.message-delay", 30); - messageRepeats = getConfig().getInt("countdown.message-repeats", 4); - kickCommand = getConfig().getString("countdown.kick-command"); - /** - * events - */ - chatWillCancel = getConfig().getBoolean("events.chat", true); - commandWillCancel = getConfig().getBoolean("events.commands", true); - loadLang(); - } - - /** - * Load the lang.yml file. - * @return - * @return The lang.yml config. - */ - public YamlConfiguration loadLang() { - File lang = new File(getDataFolder(), "lang.yml"); - if (!lang.exists()) { - try { - getDataFolder().mkdir(); - lang.createNewFile(); - InputStreamReader defConfigStream = new InputStreamReader(this.getResource("lang.yml")); - if (defConfigStream != null) { - YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); - defConfig.save(lang); - Lang.setFile(defConfig); - return defConfig; - } - } catch(IOException e) { - e.printStackTrace(); // So they notice - this.setEnabled(false); // Without it loaded, we can't send them messages - } - } - YamlConfiguration conf = YamlConfiguration.loadConfiguration(lang); - for(Lang item:Lang.values()) { - if (conf.getString(item.getPath()) == null) { - conf.set(item.getPath(), item.getDefault()); - } - } - Lang.setFile(conf); - LANG = conf; - LANG_FILE = lang; - try { - conf.save(getLangFile()); - } catch(IOException e) { - e.printStackTrace(); - } - return conf; - } - - /** - * Gets the lang.yml config. - * @return The lang.yml config. - */ - public YamlConfiguration getLang() { - return LANG; - } - - /** - * Get the lang.yml file. - * @return The lang.yml file. - */ - public File getLangFile() { - return LANG_FILE; - } /** * Get the afk time for a player */ public int getaAllowedAfktime(Player player) { - if(fulloverride) { - return defaultafkTime; + if(Config.SERVERFULL) { + return Config.DEFAULTAFKTIME; } return PlayerAfkTime.get(player.getUniqueId()); } @@ -213,14 +98,14 @@ public class AFKDetector extends JavaPlugin implements Listener{ if (attachmentInfo.getPermission().startsWith(permissionPrefix)) { String perm = attachmentInfo.getPermission(); int Time = Integer.parseInt(perm.substring(perm.lastIndexOf(".") + 1)); - if(Time >= maxafkTime) { - return maxafkTime; - } else if(Time < maxafkTime) { + if(Time >= Config.MAXAFKTIME) { + return Config.MAXAFKTIME; + } else { return Time; } } } - return defaultafkTime; + return Config.DEFAULTAFKTIME; } @EventHandler @@ -230,7 +115,7 @@ public class AFKDetector extends JavaPlugin implements Listener{ PlayerAfkTime.put(player.getUniqueId(), getPlayerAfktime(player)); players.put(player.getUniqueId(), new AFKPlayer(player, this)); } - if(Bukkit.getOnlinePlayers().size() >= playerlimit && !fulloverride) { + if(Bukkit.getOnlinePlayers().size() >= Config.PLAYERLIMIT && !Config.SERVERFULL) { fulloverride = true; } } @@ -242,14 +127,14 @@ public class AFKDetector extends JavaPlugin implements Listener{ if (player != null) { players.remove(player.getUniqueId()); } - if(Bukkit.getOnlinePlayers().size() < playerlimit && fulloverride){ + if(Bukkit.getOnlinePlayers().size() < Config.PLAYERLIMIT && fulloverride){ fulloverride = false; } } @EventHandler public void onTalkCancel(AsyncPlayerChatEvent event) { - if (!chatWillCancel) { + if (!Config.CHATWILLCANCEL) { return; } Player player = event.getPlayer(); @@ -260,7 +145,7 @@ public class AFKDetector extends JavaPlugin implements Listener{ @EventHandler public void oncommandCancel(PlayerCommandPreprocessEvent event) { - if (!commandWillCancel) { + if (!Config.COMMANDWILLCANCEL) { return; } Player player = event.getPlayer(); @@ -284,5 +169,8 @@ public class AFKDetector extends JavaPlugin implements Listener{ } } }*/ - + + public static AFKDetector getInstance() { + return instance; + } } diff --git a/src/main/java/com/alttd/afkdectector/Lang.java b/src/main/java/com/alttd/afkdectector/Lang.java deleted file mode 100755 index bf29621..0000000 --- a/src/main/java/com/alttd/afkdectector/Lang.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.alttd.afkdectector; - -import org.bukkit.ChatColor; -import org.bukkit.configuration.file.YamlConfiguration; - -/** -* An enum for requesting strings from the language file. -*/ -public enum Lang { - TITLE("title-name", "&4[&fAFKDetector&4]:"), - COOLDOWN("cooldown-message", "You need to wait %timeleft% seconds before using this command."), - INVALID_PLAYER("invalid-args", "&cInvalid args!usage: -p:playername"), - INVALID_REASON("invalid-reason" , "&cInvalid args! usage: -r:reason"), - NOT_ONLINE("player-notonline", "&cInvalid args! player not online"), - PLAYER_ONLY("player-only", "Teri have you ever seen an afk console?"), - NO_PERMS("no-permissions", "&cYou don''t have permission for that!"), - AFK_LIST("afk-list", "There are %afkplayers% afk."), - AFK_PREFIX("afk-prefix", "[AFK]"), - AFKCHECKTITLE("afkcheck-title", "AFK CHECK"), - AFKTOGGLEON("afk-toggle-on", "&b%player% is not afk."), - AFKTOGGLEOFF("afk-toggle-off", "&b%player% is no longer afk."), - AFKCHECKSUBTITLE("afkcheck-subtitle", "Please respond to the dm from staff!"), - AFKCHECKCMESSAGE("afkcheck-message", "Hey, since you're near a farm and not moving. I'm making sure you aren't afk. Please respond to me if you're not AFK."); - - - private String path; - private String def; - private static YamlConfiguration LANG; - - /** - * Lang enum constructor. - * @param path The string path. - * @param start The default string. - */ - Lang(String path, String start) { - this.path = path; - this.def = start; - } - - /** - * Set the {@code YamlConfiguration} to use. - * @param config The config to set. - */ - public static void setFile(YamlConfiguration config) { - LANG = config; - } - - @Override - public String toString() { - return ChatColor.translateAlternateColorCodes('&', LANG.getString(this.path, def)); - } - - /** - * Get the default value of the path. - * @return The default value of the path. - */ - public String getDefault() { - return this.def; - } - - /** - * Get the path to the string. - * @return The path to the string. - */ - public String getPath() { - return this.path; - } -} \ No newline at end of file diff --git a/src/main/java/com/alttd/afkdectector/MessageTimer.java b/src/main/java/com/alttd/afkdectector/MessageTimer.java index ddbc64b..f1acf6e 100755 --- a/src/main/java/com/alttd/afkdectector/MessageTimer.java +++ b/src/main/java/com/alttd/afkdectector/MessageTimer.java @@ -2,6 +2,10 @@ package com.alttd.afkdectector; import java.util.UUID; +import com.alttd.afkdectector.config.Config; +import com.alttd.afkdectector.config.Messages; +import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.title.Title; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -20,7 +24,7 @@ public class MessageTimer extends BukkitRunnable { } public void init() { - runTaskTimer(plugin, 0, plugin.messageDelay * 20); + runTaskTimer(plugin, 0, Config.MESSAGEDELAY * 20); } // TODO get a better string builder @@ -40,10 +44,13 @@ public class MessageTimer extends BukkitRunnable { cancel(); return; } - if(plugin.countdownenabled) { - player.sendTitle(ChatColor.translateAlternateColorCodes('&', plugin.title1), - ChatColor.translateAlternateColorCodes('&', plugin.title2), plugin.fadein, plugin.stay, plugin.fadeout); - player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.message)); + if(Config.COUNTDOWNENABLED) { + MiniMessage miniMessage = MiniMessage.get(); + Title title = Title.title(miniMessage.parse(Messages.COUNTDOWNTITLE1.getMessage()), + miniMessage.parse(Messages.COUNTDOWNTITLE2.getMessage())); + //Title.Times.of(Config.FADEIN, Config.STAY, Config.STAY); + player.showTitle(title); + player.sendMessage(miniMessage.parse(Messages.COUNTDOWNMESSAGE.getMessage())); } repeats = repeats - 1; @@ -53,7 +60,7 @@ public class MessageTimer extends BukkitRunnable { } //Bukkit.dispatchCommand(Bukkit.getConsoleSender(), plugin.kickCommand.replace("%player%", player.getName())); plugin.messageTimers.remove(player.getUniqueId()); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), return_placeholders(plugin.kickCommand, player)); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), return_placeholders(Config.KICKCOMMAND, player)); cancel(); } } else { diff --git a/src/main/java/com/alttd/afkdectector/afkplayer/AFKPlayer.java b/src/main/java/com/alttd/afkdectector/afkplayer/AFKPlayer.java index eb26682..f873883 100755 --- a/src/main/java/com/alttd/afkdectector/afkplayer/AFKPlayer.java +++ b/src/main/java/com/alttd/afkdectector/afkplayer/AFKPlayer.java @@ -2,7 +2,9 @@ package com.alttd.afkdectector.afkplayer; import java.util.UUID; -import com.alttd.afkdectector.Lang; +import com.alttd.afkdectector.config.Messages; +import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.text.minimessage.Template; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -27,8 +29,6 @@ public class AFKPlayer { this.standingTime = System.currentTimeMillis(); this.afkTime = plugin.getaAllowedAfktime(player); this.isafk = false; - //plugin.getLogger().info("Loading " + playerName + ", Time " + standingTime + ", allowed afktime " + afkTime); - } public String getPlayerName() { @@ -69,7 +69,7 @@ public class AFKPlayer { public void ResetAFK() { if(isafk) { - Bukkit.broadcast(ChatColor.translateAlternateColorCodes('&', Lang.AFKTOGGLEOFF.toString().replace("%player%", playerName)), "afkdetector.notify"); + Bukkit.broadcast(MiniMessage.get().parse(Messages.AFKTOGGLEOFF.getMessage(), Template.of("player", playerName)), "afkdetector.notify"); } standingTime = System.currentTimeMillis(); playerToSphereCenter = Bukkit.getPlayer(getPlayerUuid()).getLocation(); diff --git a/src/main/java/com/alttd/afkdectector/command/AFKCheckCommand.java b/src/main/java/com/alttd/afkdectector/command/AFKCheckCommand.java index 7c10be4..57c0054 100755 --- a/src/main/java/com/alttd/afkdectector/command/AFKCheckCommand.java +++ b/src/main/java/com/alttd/afkdectector/command/AFKCheckCommand.java @@ -1,10 +1,11 @@ package com.alttd.afkdectector.command; import com.alttd.afkdectector.AFKDetector; -import com.alttd.afkdectector.Lang; +import com.alttd.afkdectector.config.Messages; import net.kyori.adventure.audience.Audience; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.title.Title; import org.bukkit.Bukkit; import org.bukkit.command.Command; @@ -39,15 +40,17 @@ public class AFKCheckCommand implements CommandExecutor, TabCompleter { sender.sendMessage(Component.text(command.getUsage(), NamedTextColor.RED)); return true; } - target.showTitle(Title.title(Component.text(Lang.AFKCHECKTITLE.toString(), NamedTextColor.RED), - Component.text(Lang.AFKCHECKSUBTITLE.toString(), NamedTextColor.RED))); + MiniMessage miniMessage = MiniMessage.get(); + target.showTitle(Title.title(miniMessage.parse(Messages.AFKCHECKTITLE.getMessage()), + miniMessage.parse(Messages.AFKCHECKSUBTITLE.getMessage()))); if(sender instanceof Player) { Player player = (Player) sender; - PlayerCommandPreprocessEvent commandEvent = new PlayerCommandPreprocessEvent(player, "/" + "msg " + args[0] + " " + Lang.AFKCHECKCMESSAGE.toString()); + String cmd = "msg " + args[0] + " " + Messages.AFKCHECKMESSAGE.getMessage(); + PlayerCommandPreprocessEvent commandEvent = new PlayerCommandPreprocessEvent(player, "/" + cmd); Bukkit.getPluginManager().callEvent(commandEvent); - player.performCommand("msg " + args[0] + " " + Lang.AFKCHECKCMESSAGE.toString()); + player.performCommand(cmd); } else { - Bukkit.dispatchCommand(sender, "msg " + args[0] + " " + Lang.AFKCHECKCMESSAGE.toString()); + Bukkit.dispatchCommand(sender, "msg " + args[0] + " " + Messages.AFKCHECKMESSAGE.getMessage()); } return true; } diff --git a/src/main/java/com/alttd/afkdectector/command/AFKListCommand.java b/src/main/java/com/alttd/afkdectector/command/AFKListCommand.java index 48b18ad..5e510bb 100755 --- a/src/main/java/com/alttd/afkdectector/command/AFKListCommand.java +++ b/src/main/java/com/alttd/afkdectector/command/AFKListCommand.java @@ -1,16 +1,19 @@ package com.alttd.afkdectector.command; import com.alttd.afkdectector.AFKDetector; -import com.alttd.afkdectector.Lang; import com.alttd.afkdectector.afkplayer.AFKPlayer; +import com.alttd.afkdectector.config.Config; +import com.alttd.afkdectector.config.Messages; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; -import net.kyori.adventure.text.format.TextDecoration; +import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.text.minimessage.Template; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; +import java.util.ArrayList; import java.util.List; public class AFKListCommand implements CommandExecutor, TabCompleter { @@ -25,19 +28,24 @@ public class AFKListCommand implements CommandExecutor, TabCompleter { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { int afkplayers = 0; Component message = Component.empty(); + MiniMessage miniMessage = MiniMessage.get(); for (AFKPlayer afkplayer : plugin.players.values()) { long standingTime = afkplayer.getstandingTime(); - if(System.currentTimeMillis() - standingTime > plugin.toggletime * 60 * 1000) { + if(System.currentTimeMillis() - standingTime > Config.TOGGLETIME * 60 * 1000) { afkplayers += 1; message = message.append(Component.newline()); - Component userinfo = Component.text(afkplayer.getPlayerName(), NamedTextColor.GOLD) - .append(Component.text(" has been afk for " + (System.currentTimeMillis() - standingTime) / 1000 + " seconds.", NamedTextColor.WHITE)) - .hoverEvent(Component.text("Click here to send an afkcheck to " + afkplayer.getPlayerName() + "!" , NamedTextColor.GRAY).asHoverEvent()) - .clickEvent(net.kyori.adventure.text.event.ClickEvent.runCommand("/afkcheck " + afkplayer.getPlayerName())); + List