diff --git a/.idea/artifacts/ScanThoseGates.xml b/.idea/artifacts/ScanThoseGates_jar.xml similarity index 93% rename from .idea/artifacts/ScanThoseGates.xml rename to .idea/artifacts/ScanThoseGates_jar.xml index a8ccd5e..38b56e2 100644 --- a/.idea/artifacts/ScanThoseGates.xml +++ b/.idea/artifacts/ScanThoseGates_jar.xml @@ -1,5 +1,5 @@ - + $PROJECT_DIR$/jars diff --git a/ScanThoseGates.version b/ScanThoseGates.version index a415e6a..53c9a6e 100644 --- a/ScanThoseGates.version +++ b/ScanThoseGates.version @@ -6,8 +6,8 @@ { "major":1, "minor":5, - "patch":3, + "patch":4, }, - "starsectorVersion":"0.96a-RC9", + "starsectorVersion":"0.96a-RC10", "directDownloadURL":"https://github.com/AEROassault/ScanThoseGates/releases/latest/download/ScanThoseGates.zip", } \ No newline at end of file diff --git a/changelog.txt b/changelog.txt index 78f5787..2f66070 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +Version 1.5.4 +- Fixed mod crash due to lack of LunaLib soft dependency in some situations +- Renamed method for checking gate intel and inverted behavior +- Added gate intel check to make sure scan ability cannot be reactivated if no new gates can be activated or have intel to be added. + Version 1.5.3 - LunaSettings integration - Allow gate scan to add inactive gates to intel without activating them diff --git a/jars/ScanThoseGates.jar b/jars/ScanThoseGates.jar index 89e6903..17e658e 100644 Binary files a/jars/ScanThoseGates.jar and b/jars/ScanThoseGates.jar differ diff --git a/jars/source.url b/jars/source.url deleted file mode 100644 index 8737751..0000000 --- a/jars/source.url +++ /dev/null @@ -1,5 +0,0 @@ -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,11 -[InternetShortcut] -IDList= -URL=https://github.com/AEROassault/ScanThoseGates diff --git a/mod_info.json b/mod_info.json index c9e263a..1b63474 100644 --- a/mod_info.json +++ b/mod_info.json @@ -2,9 +2,9 @@ "id":"scan_those_gates", "name":"Scan Those Gates", "author":"AERO", - "version":"1.5.3", + "version":"1.5.4", "description":"Adds abilities to scan gates and reveal megastructure locations.", - "gameVersion":"0.96a-RC9", + "gameVersion":"0.96a-RC10", "jars":["jars/ScanThoseGates.jar"], - "modPlugin":"scanthosegates.ModPlugin" + "modPlugin":"scanthosegates.ScannerModPlugin" } \ No newline at end of file diff --git a/src/scanthosegates/LunaSettingsChangedListener.java b/src/scanthosegates/LunaSettingsChangedListener.java index 2c18238..ea372e9 100644 --- a/src/scanthosegates/LunaSettingsChangedListener.java +++ b/src/scanthosegates/LunaSettingsChangedListener.java @@ -1,12 +1,21 @@ package scanthosegates; +import lunalib.lunaSettings.LunaSettings; import lunalib.lunaSettings.LunaSettingsListener; +import static scanthosegates.ScannerModPlugin.lunaLibEnabled; + public class LunaSettingsChangedListener implements LunaSettingsListener { @Override public void settingsChanged(String idOfModWithChangedSettings) { - if (idOfModWithChangedSettings.equals(ModPlugin.ID)) { - ModPlugin.readSettings(); + if (idOfModWithChangedSettings.equals(ScannerModPlugin.ID)) { + ScannerModPlugin.readSettings(); + } + } + + public static void addToManagerIfNeeded() { + if(lunaLibEnabled && !LunaSettings.hasSettingsListenerOfClass(LunaSettingsChangedListener.class)) { + LunaSettings.addSettingsListener(new LunaSettingsChangedListener()); } } } \ No newline at end of file diff --git a/src/scanthosegates/ModPlugin.java b/src/scanthosegates/ScannerModPlugin.java similarity index 80% rename from src/scanthosegates/ModPlugin.java rename to src/scanthosegates/ScannerModPlugin.java index 2b7dfe4..64be7b6 100644 --- a/src/scanthosegates/ModPlugin.java +++ b/src/scanthosegates/ScannerModPlugin.java @@ -15,16 +15,19 @@ import java.util.MissingResourceException; -public class ModPlugin extends BaseModPlugin { - private static final Logger log = Global.getLogger(ModPlugin.class); +import static scanthosegates.LunaSettingsChangedListener.addToManagerIfNeeded; + +public class ScannerModPlugin extends BaseModPlugin { + private static final Logger log = Global.getLogger(ScannerModPlugin.class); static {log.setLevel(Level.ALL);} public static final String ID = "scan_those_gates"; - public static final String PREFIX = "stg_"; - static final String LUNALIB_ID = "lunalib"; + public static final String MOD_PREFIX = "stg_"; public static final String INTEL_MEGASTRUCTURES = "Megastructures"; + public static boolean lunaLibEnabled = Global.getSettings().getModManager().isModEnabled("lunalib"); + static T get(String id, Class type) throws Exception { - if (Global.getSettings().getModManager().isModEnabled(LUNALIB_ID)) { - if (type == Boolean.class) return type.cast(LunaSettings.getBoolean(ModPlugin.ID, PREFIX + id)); + if (lunaLibEnabled) { + if (type == Boolean.class) return type.cast(LunaSettings.getBoolean(ScannerModPlugin.ID, MOD_PREFIX + id)); } else { if (type == Boolean.class) return type.cast(Global.getSettings().getBoolean(id)); } @@ -39,9 +42,9 @@ static void readSettings() { log.debug("Failed to read lunaSettings. Exception: " + e); } } - public static boolean - RevealAllGates = false, - ActivateAllGates = false; + + public static boolean RevealAllGates = false; + public static boolean ActivateAllGates = false; @Override public void onGameLoad(boolean newGame){ @@ -70,12 +73,14 @@ public void onGameLoad(boolean newGame){ Global.getSector().getListenerManager().addListener(new RelocationListener(), true); Global.getSector().getListenerManager().addListener(new SalvagingListener(), true); + + readSettings(); } @Override - public void onApplicationLoad() { - if (Global.getSettings().getModManager().isModEnabled(LUNALIB_ID)) { - LunaSettings.addSettingsListener(new LunaSettingsChangedListener()); + public void onApplicationLoad() throws Exception { + if (lunaLibEnabled){ + addToManagerIfNeeded(); } } } diff --git a/src/scanthosegates/campaign/econ/abilities/GateScanner.java b/src/scanthosegates/campaign/econ/abilities/GateScanner.java index ed250f4..33d4962 100644 --- a/src/scanthosegates/campaign/econ/abilities/GateScanner.java +++ b/src/scanthosegates/campaign/econ/abilities/GateScanner.java @@ -19,8 +19,8 @@ import java.util.HashSet; import static java.lang.Math.pow; -import static scanthosegates.ModPlugin.ActivateAllGates; -import static scanthosegates.ModPlugin.RevealAllGates; +import static scanthosegates.ScannerModPlugin.ActivateAllGates; +import static scanthosegates.ScannerModPlugin.RevealAllGates; public class GateScanner extends BaseDurationAbility { public static String UNSCANNED_GATES = "$UnscannedGatesFound"; @@ -62,7 +62,7 @@ protected void applyEffect(float amount, float level) { revealThatGate = true; } finally { try { - if (!doesGateIntelExist(gate)) { + if (gateIntelDoesNotExist(gate)) { if (RevealAllGates) { Global.getSector().getIntelManager().addIntel(new GateIntel(gate)); } else if (revealThatGate) { @@ -153,14 +153,14 @@ else if (!Global.getSector().getMemoryWithoutUpdate().getBoolean(UNSCANNED_GATES addIncompatibleToTooltip(tooltip, expanded); } - public boolean doesGateIntelExist(SectorEntityToken gate) { + public boolean gateIntelDoesNotExist(SectorEntityToken gate) { for (IntelInfoPlugin intel : Global.getSector().getIntelManager().getIntel(GateIntel.class)){ GateIntel gi = (GateIntel) intel; if (gi.getGate() == gate) { - return true; + return false; } } - return false; + return true; } public HashSet generateMarketSystemsHashset() { @@ -184,7 +184,7 @@ public void checkForGates() { if (ActivateAllGates) { Global.getSector().getMemoryWithoutUpdate().set(UNSCANNED_GATES, true); return; - } else if (RevealAllGates) { + } else if (RevealAllGates && gateIntelDoesNotExist(gate)) { Global.getSector().getMemoryWithoutUpdate().set(UNSCANNED_GATES, true); return; } else if (systemsWithMarkets.contains(gate.getContainingLocation())) { diff --git a/src/scanthosegates/campaign/intel/CoronalHypershuntIntel.java b/src/scanthosegates/campaign/intel/CoronalHypershuntIntel.java index b4cb5f6..69da55a 100644 --- a/src/scanthosegates/campaign/intel/CoronalHypershuntIntel.java +++ b/src/scanthosegates/campaign/intel/CoronalHypershuntIntel.java @@ -7,14 +7,14 @@ import com.fs.starfarer.api.ui.SectorMapAPI; import com.fs.starfarer.api.ui.TooltipMakerAPI; import com.fs.starfarer.api.util.Misc; -import scanthosegates.ModPlugin; +import scanthosegates.ScannerModPlugin; import scanthosegates.campaign.intel.button.LayInCourse; import java.awt.*; import java.util.Set; public class CoronalHypershuntIntel extends BaseIntel { - public static final String INTEL_HYPERSHUNT = ModPlugin.INTEL_MEGASTRUCTURES; + public static final String INTEL_HYPERSHUNT = ScannerModPlugin.INTEL_MEGASTRUCTURES; private final SectorEntityToken hypershunt; public CoronalHypershuntIntel(SectorEntityToken hypershunt) { diff --git a/src/scanthosegates/campaign/intel/CryosleeperIntel.java b/src/scanthosegates/campaign/intel/CryosleeperIntel.java index bccad46..398245a 100644 --- a/src/scanthosegates/campaign/intel/CryosleeperIntel.java +++ b/src/scanthosegates/campaign/intel/CryosleeperIntel.java @@ -7,14 +7,14 @@ import com.fs.starfarer.api.ui.SectorMapAPI; import com.fs.starfarer.api.ui.TooltipMakerAPI; import com.fs.starfarer.api.util.Misc; -import scanthosegates.ModPlugin; +import scanthosegates.ScannerModPlugin; import scanthosegates.campaign.intel.button.LayInCourse; import java.awt.*; import java.util.Set; public class CryosleeperIntel extends BaseIntel { - public static final String INTEL_CRYOSLEEPER = ModPlugin.INTEL_MEGASTRUCTURES; + public static final String INTEL_CRYOSLEEPER = ScannerModPlugin.INTEL_MEGASTRUCTURES; private final SectorEntityToken cryosleeper; public CryosleeperIntel(SectorEntityToken cryosleeper) {