Skip to content

Commit

Permalink
Dev to Master v.1.5.4 (#9)
Browse files Browse the repository at this point in the history
* Change ModPlugin name, change LunaSettings path usage to address possible crashes

* Fix crash when lunasettings is not enabled

* Fixed behavior for gate scan revealing gates in marketless systems and ability states

* Refactor method to gateIntelDoesNotExist

* Fix method (for real this time)

* Update changelog.txt
  • Loading branch information
AEROassault committed May 24, 2023
1 parent 83f217d commit 44dd0a3
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 36 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ScanThoseGates.version
Expand Up @@ -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",
}
5 changes: 5 additions & 0 deletions 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
Expand Down
Binary file modified jars/ScanThoseGates.jar
Binary file not shown.
5 changes: 0 additions & 5 deletions jars/source.url

This file was deleted.

6 changes: 3 additions & 3 deletions mod_info.json
Expand Up @@ -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"
}
13 changes: 11 additions & 2 deletions 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());
}
}
}
Expand Up @@ -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> T get(String id, Class<T> 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));
}
Expand All @@ -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){
Expand Down Expand Up @@ -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();
}
}
}
14 changes: 7 additions & 7 deletions src/scanthosegates/campaign/econ/abilities/GateScanner.java
Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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<LocationAPI> generateMarketSystemsHashset() {
Expand All @@ -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())) {
Expand Down
4 changes: 2 additions & 2 deletions src/scanthosegates/campaign/intel/CoronalHypershuntIntel.java
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/scanthosegates/campaign/intel/CryosleeperIntel.java
Expand Up @@ -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) {
Expand Down

0 comments on commit 44dd0a3

Please sign in to comment.