Skip to content

Commit

Permalink
TimeChanger 1.1.0 - 1.17 and /ctime command
Browse files Browse the repository at this point in the history
  • Loading branch information
Motschen committed Oct 1, 2021
1 parent 2f1d171 commit 56e5e5f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
mod_menu_version = 2.0.2
5 changes: 5 additions & 0 deletions src/main/java/eu/midnightdust/timechanger/TimeChangerClient.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -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())
);
}
}
Original file line number Diff line number Diff line change
@@ -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<FabricClientCommandSource> 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;
}

}
3 changes: 2 additions & 1 deletion src/main/resources/assets/timechanger/lang/en_us.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
],

"depends": {
"autoconfig1u": "*"
"cloth-config2": "*"
}
}

0 comments on commit 56e5e5f

Please sign in to comment.