mirror of
https://github.com/TeamMidnightDust/TimeChanger.git
synced 2025-12-16 10:05:09 +01:00
31 lines
1.3 KiB
Java
Executable File
31 lines
1.3 KiB
Java
Executable File
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.v2.ClientCommandManager;
|
|
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
|
import net.minecraft.text.Text;
|
|
|
|
import static net.fabricmc.fabric.api.client.command.v2.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(Text.translatable("command.timechanger.ctime.success").append(String.valueOf(time)));
|
|
return 1;
|
|
}
|
|
|
|
} |