From 3873256a79589ccff9d100b51152f4d1fd508c24 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Sat, 11 Nov 2023 03:23:01 -0500 Subject: Blobbercyst Glow --- src/main/java/de/hysky/skyblocker/debug/Debug.java | 13 +++++++++ .../hysky/skyblocker/debug/DumpPlayersCommand.java | 34 ++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/main/java/de/hysky/skyblocker/debug/Debug.java create mode 100644 src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java (limited to 'src/main/java/de/hysky/skyblocker/debug') diff --git a/src/main/java/de/hysky/skyblocker/debug/Debug.java b/src/main/java/de/hysky/skyblocker/debug/Debug.java new file mode 100644 index 00000000..5991f72c --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/debug/Debug.java @@ -0,0 +1,13 @@ +package de.hysky.skyblocker.debug; + +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; + +public class Debug { + private static final boolean DEBUG_ENABLED = Boolean.parseBoolean(System.getProperty("skyblocker.debug", "false")); + + public static void init() { + if (DEBUG_ENABLED) { + ClientCommandRegistrationCallback.EVENT.register(DumpPlayersCommand::register); + } + } +} diff --git a/src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java b/src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java new file mode 100644 index 00000000..598672ef --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java @@ -0,0 +1,34 @@ +package de.hysky.skyblocker.debug; + +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; + +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.client.MinecraftClient; +import net.minecraft.command.CommandRegistryAccess; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.text.Text; + +public class DumpPlayersCommand { + + static void register(CommandDispatcher dispatcher, CommandRegistryAccess registryAccess) { + dispatcher.register(literal(SkyblockerMod.NAMESPACE) + .then(literal("debug") + .then(literal("dumpPlayers") + .executes(context -> { + FabricClientCommandSource source = context.getSource(); + MinecraftClient client = source.getClient(); + + client.world.getEntities().forEach(e -> { + if (e instanceof PlayerEntity player) { + source.sendFeedback(Text.of("\"" + player.getName().getString() + "\"")); + } + }); + + return Command.SINGLE_SUCCESS; + })))); + } +} -- cgit From fb249dcac9581945d35a89c417bb54afe4ed7c32 Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Mon, 13 Nov 2023 19:29:54 -0500 Subject: Refactor debug --- src/main/java/de/hysky/skyblocker/debug/Debug.java | 3 ++- .../de/hysky/skyblocker/debug/DumpPlayersCommand.java | 15 ++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/debug') diff --git a/src/main/java/de/hysky/skyblocker/debug/Debug.java b/src/main/java/de/hysky/skyblocker/debug/Debug.java index 5991f72c..1fc22d2a 100644 --- a/src/main/java/de/hysky/skyblocker/debug/Debug.java +++ b/src/main/java/de/hysky/skyblocker/debug/Debug.java @@ -1,12 +1,13 @@ package de.hysky.skyblocker.debug; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; +import net.fabricmc.loader.api.FabricLoader; public class Debug { private static final boolean DEBUG_ENABLED = Boolean.parseBoolean(System.getProperty("skyblocker.debug", "false")); public static void init() { - if (DEBUG_ENABLED) { + if (DEBUG_ENABLED || FabricLoader.getInstance().isDevelopmentEnvironment()) { ClientCommandRegistrationCallback.EVENT.register(DumpPlayersCommand::register); } } diff --git a/src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java b/src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java index 598672ef..5f6e0362 100644 --- a/src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java +++ b/src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java @@ -1,17 +1,15 @@ package de.hysky.skyblocker.debug; -import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; - 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.client.MinecraftClient; 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 dispatcher, CommandRegistryAccess registryAccess) { @@ -20,14 +18,13 @@ public class DumpPlayersCommand { .then(literal("dumpPlayers") .executes(context -> { FabricClientCommandSource source = context.getSource(); - MinecraftClient client = source.getClient(); - - client.world.getEntities().forEach(e -> { + + source.getWorld().getEntities().forEach(e -> { if (e instanceof PlayerEntity player) { - source.sendFeedback(Text.of("\"" + player.getName().getString() + "\"")); + source.sendFeedback(Text.of("'" + player.getName().getString() + "'")); } }); - + return Command.SINGLE_SUCCESS; })))); } -- cgit