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 | |
parent | a280f436af2ed03840544c1fddca843b8583199b (diff) |
Add `/omvm` command showing configurations.
-rw-r--r-- | gradle.properties | 2 | ||||
-rw-r--r-- | src/main/java/com/keuin/ohmyvanillamc/OhMyVanillaMinecraft.java | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/gradle.properties b/gradle.properties index 8407992..d6d83c4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.16.4 yarn_mappings=1.16.4+build.9 loader_version=0.11.0 # Mod Properties -mod_version=1.4.1 +mod_version=1.4.2 maven_group=com.keuin.omvm archives_base_name=oh-my-vanilla-mc # Dependencies 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 + } + })); + } + }); + } } |