diff --git a/src/client/java/dev/xdpxi/xdlib/XDsLibraryClient.java b/src/client/java/dev/xdpxi/xdlib/XDsLibraryClient.java index d545502..2318c7a 100644 --- a/src/client/java/dev/xdpxi/xdlib/XDsLibraryClient.java +++ b/src/client/java/dev/xdpxi/xdlib/XDsLibraryClient.java @@ -1,6 +1,5 @@ package dev.xdpxi.xdlib; -import dev.xdpxi.xdlib.config.configManager; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -28,7 +27,6 @@ public class XDsLibraryClient implements ClientModInitializer { public static int duration = -1; public static List list = new ArrayList<>(); public static Map WorldCloudHeights = new HashMap<>(); - public configManager CONFIG_MANAGER; public static boolean isWindows() { return System.getProperty("os.name").toLowerCase().contains("windows"); @@ -86,9 +84,6 @@ public boolean isNoEarlyLoaders() { @Override public void onInitializeClient() { - configManager.registerConfig(); - CONFIG_MANAGER = new configManager(); - ClientTickEvents.END_CLIENT_TICK.register(client -> { if (client.player != null) { StatusEffectInstance darknessEffect = client.player.getStatusEffect(StatusEffects.DARKNESS); diff --git a/src/client/java/dev/xdpxi/xdlib/config/clothConfig/modConfigScreen.java b/src/client/java/dev/xdpxi/xdlib/config/clothConfig/modConfigScreen.java deleted file mode 100644 index 8151391..0000000 --- a/src/client/java/dev/xdpxi/xdlib/config/clothConfig/modConfigScreen.java +++ /dev/null @@ -1,33 +0,0 @@ -package dev.xdpxi.xdlib.config.clothConfig; - -import dev.xdpxi.xdlib.config.configManager; -import me.shedaniel.clothconfig2.api.ConfigBuilder; -import me.shedaniel.clothconfig2.gui.entries.BooleanListEntry; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.Text; - -import java.util.function.Consumer; - -public class modConfigScreen { - public Screen getModConfigScreen(Screen parent) { - configManager.ConfigData configData = configManager.configData; - - ConfigBuilder builder = ConfigBuilder.create() - .setParentScreen(parent) - .setTitle(Text.of("XDLib Configuration")); - - builder.getOrCreateCategory(Text.of("Main")) - .addEntry(createBooleanToggle(builder, "Enable Custom Modmenu Badges", configData.isCustomBadges(), configData::setCustomBadges, true)) - .addEntry(createBooleanToggle(builder, "Enable Title Screen Warnings", configData.isTitlePopups(), configData::setTitlePopups, false)); - - return builder.build(); - } - - private BooleanListEntry createBooleanToggle(ConfigBuilder builder, String text, boolean initialValue, Consumer consumer, boolean defaultValue) { - return builder.entryBuilder() - .startBooleanToggle(Text.of(text), initialValue) - .setDefaultValue(defaultValue) - .setSaveConsumer(consumer) - .build(); - } -} \ No newline at end of file diff --git a/src/client/java/dev/xdpxi/xdlib/config/configManager.java b/src/client/java/dev/xdpxi/xdlib/config/configManager.java deleted file mode 100644 index 7b4b33e..0000000 --- a/src/client/java/dev/xdpxi/xdlib/config/configManager.java +++ /dev/null @@ -1,87 +0,0 @@ -package dev.xdpxi.xdlib.config; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import dev.xdpxi.xdlib.api.mod.loader; -import net.minecraft.client.gui.screen.Screen; - -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; - -public class configManager { - public static final String CONFIG_FILE_NAME = "config.json"; - private static final boolean clothConfig = loader.isModLoaded("cloth-config"); - public static ConfigData configData; - public final File configFile; - public final Gson gson; - - public configManager() { - File configDir = new File("config" + File.separator + "xdlib"); - gson = new GsonBuilder().setPrettyPrinting().create(); - - if (!configDir.exists()) { - configDir.mkdirs(); - } - configFile = new File(configDir, CONFIG_FILE_NAME); - - if (!configFile.exists()) { - write(new ConfigData()); - } else { - configData = read(); - } - } - - public static void registerConfig() { - new configManager(); - } - - public void write(ConfigData configData) { - try { - if (!configFile.exists()) { - configFile.createNewFile(); - } - try (FileWriter writer = new FileWriter(configFile)) { - gson.toJson(configData, writer); - } - } catch (IOException ignored) { - } - } - - public ConfigData read() { - try (FileReader reader = new FileReader(configFile)) { - return gson.fromJson(reader, ConfigData.class); - } catch (IOException ignored) { - return null; - } - } - - public Screen getModConfigScreen(ConfigData configData, Screen parent) { - if (clothConfig) { - return getModConfigScreen(configManager.configData, parent); - } - return parent; - } - - public static class ConfigData { - private boolean customBadges = true; - private boolean titlePopups = false; - - public boolean isCustomBadges() { - return customBadges; - } - - public void setCustomBadges(boolean customBadges) { - this.customBadges = customBadges; - } - - public boolean isTitlePopups() { - return titlePopups; - } - - public void setTitlePopups(boolean titlePopups) { - this.titlePopups = titlePopups; - } - } -} \ No newline at end of file diff --git a/src/client/java/dev/xdpxi/xdlib/config/modMenuIntegration.java b/src/client/java/dev/xdpxi/xdlib/config/modMenuIntegration.java deleted file mode 100644 index 072055c..0000000 --- a/src/client/java/dev/xdpxi/xdlib/config/modMenuIntegration.java +++ /dev/null @@ -1,21 +0,0 @@ -package dev.xdpxi.xdlib.config; - -import com.terraformersmc.modmenu.api.ConfigScreenFactory; -import com.terraformersmc.modmenu.api.ModMenuApi; -import dev.xdpxi.xdlib.api.mod.loader; -import dev.xdpxi.xdlib.config.clothConfig.modConfigScreen; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; - -@Environment(EnvType.CLIENT) -public class modMenuIntegration implements ModMenuApi { - private static final boolean clothConfig = loader.isModLoaded("cloth-config"); - - @Override - public ConfigScreenFactory getModConfigScreenFactory() { - if (clothConfig) { - return parent -> new modConfigScreen().getModConfigScreen(parent); - } - return null; - } -} \ No newline at end of file diff --git a/src/client/java/dev/xdpxi/xdlib/mixin/client/ModBadgeRendererMixin.java b/src/client/java/dev/xdpxi/xdlib/mixin/client/ModBadgeRendererMixin.java index 99571d3..105e869 100644 --- a/src/client/java/dev/xdpxi/xdlib/mixin/client/ModBadgeRendererMixin.java +++ b/src/client/java/dev/xdpxi/xdlib/mixin/client/ModBadgeRendererMixin.java @@ -3,7 +3,6 @@ import com.terraformersmc.modmenu.util.mod.Mod; import com.terraformersmc.modmenu.util.mod.ModBadgeRenderer; import dev.xdpxi.xdlib.api.mod.loader; -import dev.xdpxi.xdlib.config.configManager; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.gui.DrawContext; import net.minecraft.text.OrderedText; @@ -33,30 +32,28 @@ public abstract class ModBadgeRendererMixin { @Inject(method = "draw", at = @At("TAIL")) public void drawCustomBadges(DrawContext DrawContext, int mouseX, int mouseY, CallbackInfo ci) { - if (configManager.configData.isCustomBadges()) { - try { - FabricLoader.getInstance().getModContainer(mod.getId()).orElse(null) - .getMetadata().getCustomValue("mcb").getAsArray().forEach(customValue -> { - var obj = customValue.getAsObject(); - var name = obj.get("name").getAsString(); - var outline = obj.get("outlineColor").getAsNumber().intValue(); - var fill = obj.get("fillColor").getAsNumber().intValue(); - drawBadge(DrawContext, Text.literal(name).asOrderedText(), outline, fill, mouseX, mouseY); - }); - } catch (Exception ignored) { - } - try { - FabricLoader.getInstance().getModContainer(mod.getId()).orElse(null) - .getMetadata().getCustomValue("xdlib").getAsObject() - .get("badges").getAsArray().forEach(customValue -> { - var obj = customValue.getAsObject(); - var name = obj.get("name").getAsString(); - var outline = obj.get("outlineColor").getAsNumber().intValue(); - var fill = obj.get("fillColor").getAsNumber().intValue(); - drawBadge(DrawContext, Text.literal(name).asOrderedText(), outline, fill, mouseX, mouseY); - }); - } catch (Exception ignored) { - } + try { + FabricLoader.getInstance().getModContainer(mod.getId()).orElse(null) + .getMetadata().getCustomValue("mcb").getAsArray().forEach(customValue -> { + var obj = customValue.getAsObject(); + var name = obj.get("name").getAsString(); + var outline = obj.get("outlineColor").getAsNumber().intValue(); + var fill = obj.get("fillColor").getAsNumber().intValue(); + drawBadge(DrawContext, Text.literal(name).asOrderedText(), outline, fill, mouseX, mouseY); + }); + } catch (Exception ignored) { + } + try { + FabricLoader.getInstance().getModContainer(mod.getId()).orElse(null) + .getMetadata().getCustomValue("xdlib").getAsObject() + .get("badges").getAsArray().forEach(customValue -> { + var obj = customValue.getAsObject(); + var name = obj.get("name").getAsString(); + var outline = obj.get("outlineColor").getAsNumber().intValue(); + var fill = obj.get("fillColor").getAsNumber().intValue(); + drawBadge(DrawContext, Text.literal(name).asOrderedText(), outline, fill, mouseX, mouseY); + }); + } catch (Exception ignored) { } } } \ No newline at end of file diff --git a/src/client/java/dev/xdpxi/xdlib/mixin/client/TitleScreenMixin.java b/src/client/java/dev/xdpxi/xdlib/mixin/client/TitleScreenMixin.java deleted file mode 100644 index 72eae02..0000000 --- a/src/client/java/dev/xdpxi/xdlib/mixin/client/TitleScreenMixin.java +++ /dev/null @@ -1,39 +0,0 @@ -package dev.xdpxi.xdlib.mixin.client; - -import dev.xdpxi.xdlib.support; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.TitleScreen; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.concurrent.CompletableFuture; - -@Mixin(TitleScreen.class) -public class TitleScreenMixin { - @Unique - private static boolean Shown = false; - - @Inject(method = "init", at = @At("TAIL")) - public void onInit(CallbackInfo ci) { - if (!Shown) { - CompletableFuture.supplyAsync(() -> { - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - return 0; - }).thenAcceptAsync(result -> { - Shown = true; - MinecraftClient client = MinecraftClient.getInstance(); - Screen currentScreen = client.currentScreen; - client.execute(() -> client.setScreen(new support(Text.empty(), currentScreen))); - }, MinecraftClient.getInstance()); - } - } -} \ No newline at end of file diff --git a/src/client/java/dev/xdpxi/xdlib/support.java b/src/client/java/dev/xdpxi/xdlib/support.java deleted file mode 100644 index bb54f8a..0000000 --- a/src/client/java/dev/xdpxi/xdlib/support.java +++ /dev/null @@ -1,74 +0,0 @@ -package dev.xdpxi.xdlib; - -import dev.xdpxi.xdlib.api.mod.loader; -import dev.xdpxi.xdlib.config.configManager; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.toast.SystemToast; -import net.minecraft.text.Text; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.CompletableFuture; - -public class support extends Screen { - private static final Logger LOGGER = LoggerFactory.getLogger("xdlib"); - private static boolean shownToast = false; - private final Screen parent; - - public support(Text title, Screen parent) { - super(title); - this.parent = parent; - } - - @Override - public void close() { - this.client.setScreen(this.parent); - } - - @Override - protected void init() { - if (configManager.configData.isTitlePopups()) { - showPopups(); - } - - CompletableFuture.supplyAsync(() -> { - try { - Thread.sleep(1); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - return 0; - }).thenAcceptAsync(result -> { - close(); - }, MinecraftClient.getInstance()); - } - - private void showPopups() { - if (!shownToast) { - shownToast = true; - if (!loader.isModLoaded("cloth-config")) { - LOGGER.warn("[XDLib] - Recommends the use of 'cloth-config'"); - this.client.getToastManager().add( - new SystemToast(SystemToast.Type.NARRATOR_TOGGLE, Text.of("XD's Library"), Text.of("Recommends the use of 'cloth-config'")) - ); - } - if (updateChecker.isUpdate()) { - LOGGER.warn("[XDLib] - An update is available!"); - this.client.getToastManager().add( - new SystemToast(SystemToast.Type.NARRATOR_TOGGLE, Text.of("XD's Library"), Text.of("An update is available!")) - ); - } - } - } - - @Override - public void render(DrawContext context, int mouseX, int mouseY, float delta) { - if (this.client == null || this.textRenderer == null) { - return; - } - - super.render(context, mouseX, mouseY, delta); - } -} \ No newline at end of file diff --git a/src/client/resources/xdlib.client.mixins.json b/src/client/resources/xdlib.client.mixins.json index b103d91..9b1b2af 100644 --- a/src/client/resources/xdlib.client.mixins.json +++ b/src/client/resources/xdlib.client.mixins.json @@ -21,8 +21,7 @@ "MultiplayerServerListWidgetMixin", "ProgressScreenMixin", "ScreenAccessor", - "SoundSystemMixin", - "TitleScreenMixin" + "SoundSystemMixin" ], "injectors": { "defaultRequire": 1