Skip to content

Commit 2ce586d

Browse files
committed
Add Config Debugging Command
1 parent 8a8575c commit 2ce586d

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package choonster.testmod3.command;
2+
3+
import choonster.testmod3.config.ModConfig;
4+
import net.minecraft.command.CommandBase;
5+
import net.minecraft.command.CommandException;
6+
import net.minecraft.command.ICommandSender;
7+
import net.minecraft.server.MinecraftServer;
8+
import net.minecraft.util.text.TextComponentString;
9+
10+
import java.util.stream.Collectors;
11+
12+
/**
13+
* Print the contents of {@link ModConfig#exampleMapField} to the chat for debugging purposes.
14+
*
15+
* @author Choonster
16+
*/
17+
public class CommandDebugConfig extends CommandBase {
18+
@Override
19+
public String getName() {
20+
return "debugconfig";
21+
}
22+
23+
@Override
24+
public String getUsage(final ICommandSender iCommandSender) {
25+
return "/debugconfig";
26+
}
27+
28+
@Override
29+
public void execute(final MinecraftServer minecraftServer, final ICommandSender iCommandSender, final String[] strings) throws CommandException {
30+
final String config = ModConfig.exampleMapField.entrySet().stream().map(Object::toString).collect(Collectors.joining(", "));
31+
iCommandSender.sendMessage(new TextComponentString(config));
32+
}
33+
}

src/main/java/choonster/testmod3/init/ModCommands.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ public static void registerSubCommands(final CommandTestMod3 commandTestMod3) {
3232
commandTestMod3.addSubcommand(new CommandMaxHealthSet());
3333
commandTestMod3.addSubcommand(new CommandMaxHealthGet());
3434
commandTestMod3.addSubcommand(new CommandTreeHelp(commandTestMod3));
35+
commandTestMod3.addSubcommand(new CommandDebugConfig());
3536
}
3637
}

0 commit comments

Comments
 (0)