diff options
author | Keuin <[email protected]> | 2021-01-15 01:19:52 +0800 |
---|---|---|
committer | keuin <[email protected]> | 2021-01-15 01:19:52 +0800 |
commit | d044c4ebf8c4ad577711afb1875ce5265bc669d8 (patch) | |
tree | a280a2d9335e8ec7c73aa04966da0261924a1f43 /src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java | |
parent | a280f436af2ed03840544c1fddca843b8583199b (diff) |
Add `/omvm` command showing configurations.
Diffstat (limited to 'src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java')
-rw-r--r-- | src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java b/src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java index fe9080e..76936fa 100644 --- a/src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java +++ b/src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java @@ -3,7 +3,15 @@ package com.keuin.ohmyvanillamc; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonIOException; +import com.mojang.brigadier.Command; +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; +import net.minecraft.server.command.CommandManager; +import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.text.LiteralText; import java.io.*; import java.nio.charset.StandardCharsets; @@ -64,5 +72,19 @@ public class OhMyVanillaMinecraft implements ModInitializer { LOGGER.info("Configuration: \n==========\n" + configuration + "\n=========="); + CommandRegistrationCallback.EVENT.register(new CommandRegistrationCallback() { + @Override + public void register(CommandDispatcher<ServerCommandSource> commandDispatcher, boolean b) { + commandDispatcher.register(CommandManager.literal("omvm").executes(new Command<ServerCommandSource>() { + @Override + public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException { + String text = "OhMyVanillaMinecraft\n==========\n" + getConfiguration() + "\n=========="; + context.getSource().sendFeedback(new LiteralText(text), false); + return 1; // 1: success, -1: fail + } + })); + } + }); + } } |