9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-25 18:09:17 +00:00

Lost Frequencies - Black Friday

This commit is contained in:
Dreeam
2025-04-07 19:46:00 -04:00
parent 6a07ebf769
commit e5dd121809
109 changed files with 151 additions and 152 deletions

View File

@@ -0,0 +1,37 @@
package org.purpurmc.purpur.command;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
import java.util.Collection;
import java.util.Collections;
public class AFKCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
dispatcher.register(Commands.literal("afk")
.requires((listener) -> listener.hasPermission(2, "bukkit.command.afk"))
.executes((context) -> execute(context.getSource(), Collections.singleton(context.getSource().getPlayerOrException())))
.then(Commands.argument("targets", EntityArgument.players())
.requires(listener -> listener.hasPermission(2, "bukkit.command.afk.other"))
.executes((context) -> execute(context.getSource(), EntityArgument.getPlayers(context, "targets")))
)
);
}
private static int execute(CommandSourceStack sender, Collection<ServerPlayer> targets) {
for (ServerPlayer player : targets) {
boolean afk = player.isCommandAfk
? !player.commandAfkStatus
: !player.isAfk();
if (afk) player.setAfk(true);
player.isCommandAfk = false;
}
return targets.size();
}
}