diff --git a/gradle.properties b/gradle.properties old mode 100644 new mode 100755 index e3d3086..ead9db9 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.11.7 # Mod Properties - mod_version = 1.0.1 + mod_version = 1.1.0 maven_group = eu.midnightdust archives_base_name = timechanger @@ -17,4 +17,4 @@ org.gradle.jvmargs=-Xmx1G fabric_version=0.40.1+1.17 cloth_config_version = 5.0.38 - mod_menu_version = 2.1.1 \ No newline at end of file + mod_menu_version = 2.0.2 \ No newline at end of file diff --git a/src/main/java/eu/midnightdust/timechanger/TimeChangerClient.java b/src/main/java/eu/midnightdust/timechanger/TimeChangerClient.java old mode 100644 new mode 100755 index 1c49321..c199555 --- a/src/main/java/eu/midnightdust/timechanger/TimeChangerClient.java +++ b/src/main/java/eu/midnightdust/timechanger/TimeChangerClient.java @@ -1,9 +1,11 @@ package eu.midnightdust.timechanger; +import eu.midnightdust.timechanger.command.CTimeCommand; import eu.midnightdust.timechanger.config.TimeChangerConfig; import me.shedaniel.autoconfig.AutoConfig; import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer; import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager; public class TimeChangerClient implements ClientModInitializer { @@ -13,5 +15,8 @@ public class TimeChangerClient implements ClientModInitializer { public void onInitializeClient() { AutoConfig.register(TimeChangerConfig.class, JanksonConfigSerializer::new); TC_CONFIG = AutoConfig.getConfigHolder(TimeChangerConfig.class).getConfig(); + ClientCommandManager.DISPATCHER.register(ClientCommandManager.literal("ctime") + .then(CTimeCommand.command()) + ); } } diff --git a/src/main/java/eu/midnightdust/timechanger/command/CTimeCommand.java b/src/main/java/eu/midnightdust/timechanger/command/CTimeCommand.java new file mode 100755 index 0000000..f5a856a --- /dev/null +++ b/src/main/java/eu/midnightdust/timechanger/command/CTimeCommand.java @@ -0,0 +1,31 @@ +package eu.midnightdust.timechanger.command; + +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import eu.midnightdust.timechanger.TimeChangerClient; +import eu.midnightdust.timechanger.config.TimeChangerConfig; +import me.shedaniel.autoconfig.AutoConfig; +import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource; +import net.minecraft.text.TranslatableText; + +import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.argument; + +public class CTimeCommand { + + public static LiteralArgumentBuilder command() { + return ClientCommandManager.literal("set").then( + argument("time", IntegerArgumentType.integer(0)) + .executes(ctx -> setTime(ctx.getSource(), IntegerArgumentType.getInteger(ctx, "time"))) + ); + } + + private static int setTime(FabricClientCommandSource source, int time) { + TimeChangerClient.TC_CONFIG.custom_time = time; + AutoConfig.getConfigHolder(TimeChangerConfig.class).save(); + + source.sendFeedback(new TranslatableText("command.timechanger.ctime.success").append(String.valueOf(time))); + return 1; + } + +} \ No newline at end of file diff --git a/src/main/resources/assets/timechanger/lang/en_us.json b/src/main/resources/assets/timechanger/lang/en_us.json old mode 100644 new mode 100755 index e60910e..7f2d116 --- a/src/main/resources/assets/timechanger/lang/en_us.json +++ b/src/main/resources/assets/timechanger/lang/en_us.json @@ -2,5 +2,6 @@ "text.autoconfig.timechanger.title":"Time Changer Config", "text.autoconfig.timechanger.option.custom_time":"Custom Time", "text.autoconfig.timechanger.option.whitelist":"Server Allowlist", - "text.autoconfig.timechanger.option.blacklist":"Use Allowlist as Blocklist?" + "text.autoconfig.timechanger.option.blacklist":"Use Allowlist as Blocklist?", + "command.timechanger.ctime.success": "Successfully set the client time to " } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json old mode 100644 new mode 100755 index 54de67c..1d31439 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -33,6 +33,6 @@ ], "depends": { - "autoconfig1u": "*" + "cloth-config2": "*" } }