From bcc8f65ac8fb7d9cd14bdfe920a141754c9d4dd9 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 14 Dec 2019 20:49:55 -0500 Subject: [PATCH] More cleanup --- core/src/io/anuke/mindustry/ClientLauncher.java | 2 +- core/src/io/anuke/mindustry/mod/Mods.java | 10 +++++++--- core/src/io/anuke/mindustry/ui/dialogs/ModsDialog.java | 6 ++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/src/io/anuke/mindustry/ClientLauncher.java b/core/src/io/anuke/mindustry/ClientLauncher.java index 08363a67be..5d04c44010 100644 --- a/core/src/io/anuke/mindustry/ClientLauncher.java +++ b/core/src/io/anuke/mindustry/ClientLauncher.java @@ -123,7 +123,7 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform for(ApplicationListener listener : modules){ listener.init(); } - mods.each(Mod::init); + mods.eachClass(Mod::init); finished = true; Events.fire(new ClientLoadEvent()); super.resize(graphics.getWidth(), graphics.getHeight()); diff --git a/core/src/io/anuke/mindustry/mod/Mods.java b/core/src/io/anuke/mindustry/mod/Mods.java index 0a35c0d089..7f2ef573f6 100644 --- a/core/src/io/anuke/mindustry/mod/Mods.java +++ b/core/src/io/anuke/mindustry/mod/Mods.java @@ -243,13 +243,16 @@ public class Mods implements Loadable{ } resolveModState(); - - //sort mods to make sure servers handle them properly. - mods.sort(Structs.comparing(m -> m.name)); + sortMods(); buildFiles(); } + private void sortMods(){ + //sort mods to make sure servers handle them properly. + mods.sort(Structs.comps(Structs.comparingInt(m -> -m.state.ordinal()), Structs.comparing(m -> m.name))); + } + private void resolveModState(){ mods.each(this::updateDependencies); @@ -483,6 +486,7 @@ public class Mods implements Loadable{ requiresReload = true; mod.state = enabled ? ModState.enabled : ModState.disabled; mods.each(this::updateDependencies); + sortMods(); } } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/ModsDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/ModsDialog.java index a9a39816fb..a2e1f8b168 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/ModsDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/ModsDialog.java @@ -2,7 +2,6 @@ package io.anuke.mindustry.ui.dialogs; import io.anuke.arc.*; import io.anuke.arc.Net.*; -import io.anuke.arc.collection.*; import io.anuke.arc.files.*; import io.anuke.arc.util.*; import io.anuke.arc.util.io.*; @@ -110,11 +109,10 @@ public class ModsDialog extends FloatingDialog{ if(!mods.list().isEmpty()){ cont.pane(table -> { table.margin(10f).top(); - Array all = Array.withArrays(mods.all(), mods.disabled()); boolean anyDisabled = false; - for(LoadedMod mod : all){ - if(!mod.enabled() && !anyDisabled && mods.all().size > 0){ + for(LoadedMod mod : mods.list()){ + if(!mod.enabled() && !anyDisabled && mods.list().size > 0){ anyDisabled = true; table.row(); table.addImage().growX().height(4f).pad(6f).color(Pal.gray);