Fix afkcheck not being picked up by spy

This commit is contained in:
len 2021-04-08 18:13:47 +02:00
parent f30954cef5
commit 6b548bc8d6
3 changed files with 13 additions and 5 deletions

View File

@ -18,7 +18,7 @@ public enum Lang {
AFK_PREFIX("afk-prefix", "[AFK]"),
AFKCHECKTITLE("afkcheck-title", "AFK CHECK"),
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.");
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;

View File

@ -12,6 +12,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import java.util.List;
@ -40,7 +41,14 @@ public class AFKCheckCommand implements CommandExecutor, TabCompleter {
}
target.showTitle(Title.title(Component.text(Lang.AFKCHECKTITLE.toString(), NamedTextColor.RED),
Component.text(Lang.AFKCHECKSUBTITLE.toString(), NamedTextColor.RED)));
Bukkit.dispatchCommand(sender, "msg " + args[0] + " " + Lang.AFKCHECKCMESSAGE.toString());
if(sender instanceof Player) {
Player player = (Player) sender;
PlayerCommandPreprocessEvent commandEvent = new PlayerCommandPreprocessEvent(player, "/" + "msg " + args[0] + " " + Lang.AFKCHECKCMESSAGE.toString());
Bukkit.getPluginManager().callEvent(commandEvent);
player.performCommand("msg " + args[0] + " " + Lang.AFKCHECKCMESSAGE.toString());
} else {
Bukkit.dispatchCommand(sender, "msg " + args[0] + " " + Lang.AFKCHECKCMESSAGE.toString());
}
return true;
}

View File

@ -30,14 +30,14 @@ public class AFKListCommand implements CommandExecutor, TabCompleter {
if(System.currentTimeMillis() - standingTime > plugin.toggletime * 60 * 1000) {
afkplayers += 1;
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."))
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()));
message = message.append(userinfo);
}
}
Component component = Component.text(Lang.AFK_LIST.toString().replaceAll("%afkplayers%", Integer.toString(afkplayers)), NamedTextColor.YELLOW, TextDecoration.BOLD);
Component component = Component.text(Lang.AFK_LIST.toString().replaceAll("%afkplayers%", Integer.toString(afkplayers)), NamedTextColor.YELLOW);
sender.sendMessage(component.append(message));
return true;
}