diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-06-14 20:21:25 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-06-14 20:21:25 +0200 |
commit | d5416f1442dc80c816ab8d76c8cceaf391d0f481 (patch) | |
tree | 1b3f004341365faa294b98afa7bbd2f4b9ec5482 /src/main/java/cc/polyfrost/oneconfig/internal | |
parent | b6fc6b825455bd2ea3237463044e4e6c53fa2c5a (diff) | |
download | OneConfig-d5416f1442dc80c816ab8d76c8cceaf391d0f481.tar.gz OneConfig-d5416f1442dc80c816ab8d76c8cceaf391d0f481.tar.bz2 OneConfig-d5416f1442dc80c816ab8d76c8cceaf391d0f481.zip |
new sorting behavior
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/internal')
3 files changed, 16 insertions, 28 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java b/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java index efc4324..13e34ff 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java @@ -1,7 +1,5 @@ package cc.polyfrost.oneconfig.internal; -import cc.polyfrost.oneconfig.config.data.Mod; -import cc.polyfrost.oneconfig.config.data.ModType; import cc.polyfrost.oneconfig.events.EventManager; import cc.polyfrost.oneconfig.internal.command.OneConfigCommand; import cc.polyfrost.oneconfig.internal.config.OneConfigConfig; @@ -13,17 +11,10 @@ import cc.polyfrost.oneconfig.internal.hud.HudCore; import cc.polyfrost.oneconfig.utils.commands.CommandManager; import cc.polyfrost.oneconfig.utils.gui.GuiUtils; import cc.polyfrost.oneconfig.utils.hypixel.HypixelUtils; -import net.minecraftforge.fml.common.DummyModContainer; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.ModMetadata; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.File; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; /** * The main class of OneConfig. @@ -31,8 +22,6 @@ import java.util.List; @net.minecraftforge.fml.common.Mod(modid = "@ID@", name = "@NAME@", version = "@VER@") public class OneConfig { public static final File oneConfigDir = new File("./OneConfig"); - public static final List<Mod> loadedMods = new ArrayList<>(); - public static final List<ModMetadata> loadedOtherMods = new ArrayList<>(); public static final Logger LOGGER = LogManager.getLogger("@NAME@"); public static OneConfigConfig config; public static Preferences preferences; @@ -75,24 +64,10 @@ public class OneConfig { EventManager.INSTANCE.register(new HudCore()); EventManager.INSTANCE.register(HypixelUtils.INSTANCE); EventManager.INSTANCE.register(KeyBindHandler.INSTANCE); - reloadModsList(); + ConfigCore.sortMods(); initialized = true; } - public static void reloadModsList() { - loadedMods.addAll(ConfigCore.oneConfigMods); - LinkedHashSet<Mod> modData = new LinkedHashSet<>(ConfigCore.oneConfigMods); - for (ModContainer mod : Loader.instance().getActiveModList()) { - ModMetadata metadata = mod.getMetadata(); - loadedOtherMods.add(metadata); - String imageName = Loader.instance().activeModContainer() == null || Loader.instance().activeModContainer().getMetadata().logoFile.trim().equals("") ? null : "/" + Loader.instance().activeModContainer().getMetadata().logoFile; - Mod newMod = new Mod(metadata.name, ModType.THIRD_PARTY, imageName); - newMod.isShortCut = true; - if (mod instanceof DummyModContainer || newMod.name.equals("OneConfig")) continue; - if (modData.add(newMod)) loadedMods.add(newMod); - } - } - /** Returns weather this is an obfuscated environment, using a check for obfuscated name of net.minecraft.world.World.class. * @return true if this is an obfuscated environment, which is normal for Minecraft or false if not. */ public static boolean isObfuscated() { diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/OneConfigConfig.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/OneConfigConfig.java index 1986e9e..96fde65 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/config/OneConfigConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/OneConfigConfig.java @@ -22,7 +22,6 @@ public class OneConfigConfig extends InternalConfig { public static ArrayList<String> favoriteMods = new ArrayList<>(); public static ArrayList<OneColor> favoriteColors = new ArrayList<>(); public static ArrayList<OneColor> recentColors = new ArrayList<>(); - public static boolean allShowShortCut = false; public static boolean australia = false; public OneConfigConfig() { diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java index a1084a1..6b88afa 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java @@ -1,12 +1,16 @@ package cc.polyfrost.oneconfig.internal.config.core; import cc.polyfrost.oneconfig.config.data.Mod; +import cc.polyfrost.oneconfig.config.data.ModType; +import cc.polyfrost.oneconfig.internal.config.OneConfigConfig; import cc.polyfrost.oneconfig.internal.hud.HudCore; import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; public class ConfigCore { - public static ArrayList<Mod> oneConfigMods = new ArrayList<>(); + public static List<Mod> oneConfigMods = new ArrayList<>(); public static void saveAll() { for (Mod modData : oneConfigMods) { @@ -22,5 +26,15 @@ public class ConfigCore { for (Mod modData : data) { modData.config.init(modData); } + sortMods(); + } + + public static void sortMods() { + ArrayList<Mod> mods = new ArrayList<>(oneConfigMods); + oneConfigMods = mods.stream().filter((mod -> OneConfigConfig.favoriteMods.contains(mod.name))).sorted().collect(Collectors.toList()); + mods.removeAll(oneConfigMods); + oneConfigMods.addAll(mods.stream().filter(mod -> mod.modType != ModType.THIRD_PARTY).sorted().collect(Collectors.toList())); + mods.removeAll(oneConfigMods); + oneConfigMods.addAll(mods.stream().sorted().collect(Collectors.toList())); } } |