diff options
author | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2023-11-13 19:29:54 -0500 |
---|---|---|
committer | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2023-11-13 19:30:33 -0500 |
commit | fb249dcac9581945d35a89c417bb54afe4ed7c32 (patch) | |
tree | 846de752e6130d3c0fe954d5a1d4a41819fa5ea5 | |
parent | a9aa80a1764054eda7fef37417aed868130ad890 (diff) | |
download | Skyblocker-fb249dcac9581945d35a89c417bb54afe4ed7c32.tar.gz Skyblocker-fb249dcac9581945d35a89c417bb54afe4ed7c32.tar.bz2 Skyblocker-fb249dcac9581945d35a89c417bb54afe4ed7c32.zip |
Refactor debug
-rw-r--r-- | src/main/java/de/hysky/skyblocker/debug/Debug.java | 3 | ||||
-rw-r--r-- | src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java | 15 |
2 files changed, 8 insertions, 10 deletions
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<FabricClientCommandSource> 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; })))); } |