From f30954cef5370d4e14a5827d12c037c7a4fdbaa8 Mon Sep 17 00:00:00 2001 From: len <40720638+destro174@users.noreply.github.com> Date: Mon, 5 Apr 2021 01:37:46 +0200 Subject: [PATCH] fix aflist components lambda --- .../afkdectector/command/AFKCheckCommand.java | 4 ---- .../afkdectector/command/AFKListCommand.java | 17 ++++++++--------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/alttd/afkdectector/command/AFKCheckCommand.java b/src/main/java/com/alttd/afkdectector/command/AFKCheckCommand.java index 06b794c..4623e63 100755 --- a/src/main/java/com/alttd/afkdectector/command/AFKCheckCommand.java +++ b/src/main/java/com/alttd/afkdectector/command/AFKCheckCommand.java @@ -2,20 +2,16 @@ package com.alttd.afkdectector.command; import com.alttd.afkdectector.AFKDetector; import com.alttd.afkdectector.Lang; -import com.alttd.afkdectector.afkplayer.AFKPlayer; import net.kyori.adventure.audience.Audience; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; -import net.kyori.adventure.text.format.TextDecoration; import net.kyori.adventure.title.Title; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; import org.bukkit.entity.Player; -import org.checkerframework.checker.units.qual.A; import java.util.List; diff --git a/src/main/java/com/alttd/afkdectector/command/AFKListCommand.java b/src/main/java/com/alttd/afkdectector/command/AFKListCommand.java index 0cff69d..d13fb33 100755 --- a/src/main/java/com/alttd/afkdectector/command/AFKListCommand.java +++ b/src/main/java/com/alttd/afkdectector/command/AFKListCommand.java @@ -24,22 +24,21 @@ public class AFKListCommand implements CommandExecutor, TabCompleter { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { int afkplayers = 0; - Component message = Component.text(""); + Component message = Component.empty(); for (AFKPlayer afkplayer : plugin.players.values()) { long standingTime = afkplayer.getstandingTime(); if(System.currentTimeMillis() - standingTime > plugin.toggletime * 60 * 1000) { afkplayers += 1; - message.append(Component.newline()); - Component userinfo = Component.text(afkplayer.getPlayerName(), NamedTextColor.DARK_PURPLE); - userinfo.append(Component.text(" has been afk for " + (System.currentTimeMillis() - standingTime) / 1000 + " seconds.")); - userinfo.hoverEvent(Component.text("Click here to send an afkcheck to " + afkplayer.getPlayerName() + "!" , NamedTextColor.GRAY).asHoverEvent()); - userinfo.clickEvent(net.kyori.adventure.text.event.ClickEvent.runCommand("/afkcheck " + afkplayer.getPlayerName())); - message.append(userinfo); + message = message.append(Component.newline()); + Component userinfo = Component.text(afkplayer.getPlayerName(), NamedTextColor.DARK_PURPLE) + .append(Component.text(" has been afk for " + (System.currentTimeMillis() - standingTime) / 1000 + " seconds.")) + .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())); + message = message.append(userinfo); } } Component component = Component.text(Lang.AFK_LIST.toString().replaceAll("%afkplayers%", Integer.toString(afkplayers)), NamedTextColor.YELLOW, TextDecoration.BOLD); - component.append(message); - sender.sendMessage(component); + sender.sendMessage(component.append(message)); return true; }