fix aflist components lambda
This commit is contained in:
parent
738d5dcffc
commit
f30954cef5
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user