aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/debug
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/debug')
-rw-r--r--src/main/java/de/hysky/skyblocker/debug/Debug.java27
-rw-r--r--src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java31
2 files changed, 25 insertions, 33 deletions
diff --git a/src/main/java/de/hysky/skyblocker/debug/Debug.java b/src/main/java/de/hysky/skyblocker/debug/Debug.java
index 1fc22d2a..86adcac6 100644
--- a/src/main/java/de/hysky/skyblocker/debug/Debug.java
+++ b/src/main/java/de/hysky/skyblocker/debug/Debug.java
@@ -1,14 +1,37 @@
package de.hysky.skyblocker.debug;
+import com.mojang.brigadier.Command;
+import com.mojang.brigadier.builder.LiteralArgumentBuilder;
+import de.hysky.skyblocker.SkyblockerMod;
+import de.hysky.skyblocker.utils.ItemUtils;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
+import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.fabricmc.loader.api.FabricLoader;
+import net.minecraft.text.Text;
+
+import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
public class Debug {
private static final boolean DEBUG_ENABLED = Boolean.parseBoolean(System.getProperty("skyblocker.debug", "false"));
+ public static boolean debugEnabled() {
+ return DEBUG_ENABLED || FabricLoader.getInstance().isDevelopmentEnvironment();
+ }
+
public static void init() {
- if (DEBUG_ENABLED || FabricLoader.getInstance().isDevelopmentEnvironment()) {
- ClientCommandRegistrationCallback.EVENT.register(DumpPlayersCommand::register);
+ if (debugEnabled()) {
+ ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(literal(SkyblockerMod.NAMESPACE).then(literal("debug")
+ .then(dumpPlayersCommand())
+ .then(ItemUtils.dumpHeldItemNbtCommand())
+ )));
}
}
+
+ private static LiteralArgumentBuilder<FabricClientCommandSource> dumpPlayersCommand() {
+ return literal("dumpPlayers")
+ .executes(context -> {
+ context.getSource().getWorld().getPlayers().forEach(player -> context.getSource().sendFeedback(Text.of("'" + player.getName().getString() + "'")));
+ return Command.SINGLE_SUCCESS;
+ });
+ }
}
diff --git a/src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java b/src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java
deleted file mode 100644
index 5f6e0362..00000000
--- a/src/main/java/de/hysky/skyblocker/debug/DumpPlayersCommand.java
+++ /dev/null
@@ -1,31 +0,0 @@
-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;
- }))));
- }
-}