aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java
blob: 5f6e0362d0b0fabedba5ab85d1b9209cbd9307f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package de.hysky.skyblocker.debug;

import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import de.hysky.skyblocker.SkyblockerMod;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;

import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;

public class DumpPlayersCommand {
	
	static void register(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess registryAccess) {
		dispatcher.register(literal(SkyblockerMod.NAMESPACE)
				.then(literal("debug")
						.then(literal("dumpPlayers")
								.executes(context -> {
									FabricClientCommandSource source = context.getSource();

									source.getWorld().getEntities().forEach(e -> {
										if (e instanceof PlayerEntity player) {
											source.sendFeedback(Text.of("'" + player.getName().getString() + "'"));
										}
									});

									return Command.SINGLE_SUCCESS;
								}))));
	}
}