timestamp
This commit is contained in:
parent
4aa82637aa
commit
7444d71b6b
3 changed files with 53 additions and 70 deletions
|
|
@ -1,8 +1,8 @@
|
|||
package de.lunarakai.yukisstuff;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.chat.TextColor;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
|
|
@ -26,9 +26,13 @@ public class ClientModEvents {
|
|||
|
||||
private static net.minecraft.network.chat.Component modifyMessages(net.minecraft.network.chat.Component componentIn) {
|
||||
MutableComponent component = net.minecraft.network.chat.Component.literal("");
|
||||
boolean showTimestamp = Config.HANDLER.instance().showTimestamp;
|
||||
if(showTimestamp) {
|
||||
MutableComponent t = net.minecraft.network.chat.Component.literal("[" + time() + "] ");
|
||||
t.setStyle(Style.EMPTY.withColor(ChatFormatting.GOLD));
|
||||
int color = Config.HANDLER.instance().colorRGB.getRGB();
|
||||
t.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(color)));
|
||||
component.append(t);
|
||||
}
|
||||
component.append(componentIn);
|
||||
componentIn = component;
|
||||
return componentIn;
|
||||
|
|
|
|||
|
|
@ -1,30 +1,23 @@
|
|||
package de.lunarakai.yukisstuff;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import dev.isxander.yacl3.api.ConfigCategory;
|
||||
import dev.isxander.yacl3.api.Option;
|
||||
import dev.isxander.yacl3.api.YetAnotherConfigLib;
|
||||
import dev.isxander.yacl3.api.controller.ColorControllerBuilder;
|
||||
import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder;
|
||||
import dev.isxander.yacl3.config.v2.api.ConfigClassHandler;
|
||||
import dev.isxander.yacl3.config.v2.api.SerialEntry;
|
||||
import dev.isxander.yacl3.config.v2.api.serializer.GsonConfigSerializerBuilder;
|
||||
import dev.isxander.yacl3.platform.YACLPlatform;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.fml.event.config.ModConfigEvent;
|
||||
import net.neoforged.neoforge.client.config.NeoForgeClientConfig;
|
||||
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.common.NeoForgeMod;
|
||||
import net.neoforged.neoforge.common.config.NeoForgeCommonConfig;
|
||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
// An example config class. This is not required, but it's a good idea to have one to keep your config organized.
|
||||
// Demonstrates how to use Neo's config APIs
|
||||
@EventBusSubscriber(modid = Yukisstuff.MODID)
|
||||
public class Config {
|
||||
public static ConfigClassHandler<Config> HANDLER = ConfigClassHandler.createBuilder(Config.class)
|
||||
|
|
@ -38,4 +31,39 @@ public class Config {
|
|||
|
||||
@SerialEntry
|
||||
public boolean showTimestamp = true;
|
||||
|
||||
@SerialEntry
|
||||
public Color colorRGB = Color.decode("#FFFFFF");
|
||||
|
||||
public void registerYaclGui() {
|
||||
ModLoadingContext.get().registerExtensionPoint(
|
||||
IConfigScreenFactory.class,
|
||||
() -> (client, parent) -> YetAnotherConfigLib
|
||||
.createBuilder().title(net.minecraft.network.chat.Component.literal("Yuki's Stuff"))
|
||||
.category(ConfigCategory.createBuilder()
|
||||
.name(net.minecraft.network.chat.Component.literal("Basic"))
|
||||
.tooltip(net.minecraft.network.chat.Component.literal("Basic functionality of the mod")) // optional
|
||||
.option(Option.<Boolean>createBuilder()
|
||||
.name(net.minecraft.network.chat.Component.literal("Show Chat Message Timestamp"))
|
||||
.binding(
|
||||
true, // default
|
||||
() -> Config.HANDLER.instance().showTimestamp, // getter
|
||||
newValue -> Config.HANDLER.instance().showTimestamp = newValue // setter
|
||||
)
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build())
|
||||
.option(Option.<Color>createBuilder()
|
||||
.name(Component.literal("Chat Timestamp Color"))
|
||||
.binding(
|
||||
Color.decode("#FFFFFF"),
|
||||
() -> Config.HANDLER.instance().colorRGB,
|
||||
newValue -> Config.HANDLER.instance().colorRGB = newValue
|
||||
)
|
||||
.controller(ColorControllerBuilder::create)
|
||||
.build()
|
||||
)
|
||||
.build())
|
||||
.save(Config.HANDLER::save)
|
||||
.build().generateScreen(parent));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,70 +1,21 @@
|
|||
package de.lunarakai.yukisstuff;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import dev.isxander.yacl3.api.*;
|
||||
import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder;
|
||||
import dev.isxander.yacl3.config.v2.api.ConfigClassHandler;
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.config.ModConfig;
|
||||
import net.neoforged.neoforge.client.event.ClientChatReceivedEvent;
|
||||
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
|
||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
// The value here should match an entry in the META-INF/neoforge.mods.toml file
|
||||
@Mod(Yukisstuff.MODID)
|
||||
public class Yukisstuff {
|
||||
public static final String MODID = "yukisstuff";
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
|
||||
// The constructor for the mod class is the first code that is run when your mod is loaded.
|
||||
// FML will recognize some parameter types like IEventBus or ModContainer and pass them in automatically.
|
||||
public Yukisstuff(IEventBus modEventBus, ModContainer modContainer) {
|
||||
// Register our mod's ModConfigSpec so that FML can create and load the config file for us
|
||||
//modContainer.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new);
|
||||
Config.HANDLER.save();
|
||||
Config.HANDLER.load();
|
||||
|
||||
boolean showTimestamp = Config.HANDLER.instance().showTimestamp;
|
||||
ModLoadingContext.get().registerExtensionPoint(
|
||||
IConfigScreenFactory.class,
|
||||
() -> (client, parent) -> YetAnotherConfigLib.createBuilder()
|
||||
.title(Component.literal("Used for narration. Could be used to render a title in the future."))
|
||||
.category(ConfigCategory.createBuilder()
|
||||
.name(Component.literal("Name of the category"))
|
||||
.tooltip(Component.literal("This text will appear as a tooltip when you hover or focus the button with Tab. There is no need to add \n to wrap as YACL will do it for you."))
|
||||
.group(OptionGroup.createBuilder()
|
||||
.name(Component.literal("Name of the group"))
|
||||
.description(OptionDescription.of(Component.literal("This text will appear when you hover over the name or focus on the collapse button with Tab.")))
|
||||
.option(Option.<Boolean>createBuilder()
|
||||
.name(Component.literal("Show Timestamp"))
|
||||
.description(OptionDescription.of(Component.literal("This text will appear as a tooltip when you hover over the option.")))
|
||||
.binding(true, () -> showTimestamp, newVal -> {
|
||||
Config.HANDLER.instance().showTimestamp = newVal;
|
||||
Config.HANDLER.save();
|
||||
})
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build())
|
||||
.build())
|
||||
.build())
|
||||
.build().generateScreen(parent));
|
||||
Config.HANDLER.instance().registerYaclGui();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue