Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Fixed DB error
Browse files Browse the repository at this point in the history
  • Loading branch information
Fi0x committed Dec 7, 2022
1 parent 07da31f commit c12783e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/fi0x/edct/logic/database/DBHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ public static ArrayList<Integer> getCommodityIDs(boolean onlyMissing, long minAv
{
while(results != null && results.next())
{
String name = results.getString("CommodityName");
if(BlacklistHandler.getBlacklistedCommodities().contains(name))
int id = results.getInt("InaraID");
if(BlacklistHandler.isIDBlacklisted(id))
continue;
ids.add(results.getInt("InaraID"));
ids.add(id);
}
} catch(Exception e)
{
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/com/fi0x/edct/logic/filesystem/BlacklistHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fi0x.edct.Main;
import com.fi0x.edct.logging.LogName;
import com.fi0x.edct.logic.database.DBHandler;
import io.fi0x.javalogger.logging.Logger;

import java.io.BufferedReader;
Expand All @@ -15,6 +16,7 @@

public class BlacklistHandler
{
private static ArrayList<Integer> BLACKLISTED_IDS = null;
public static ArrayList<String> getBlacklistSystems()
{
ArrayList<String> blacklistedStations = new ArrayList<>();
Expand All @@ -38,7 +40,14 @@ public static ArrayList<String> getBlacklistSystems()

return blacklistedStations;
}
public static ArrayList<String> getBlacklistedCommodities()
public static boolean isIDBlacklisted(int id)
{
if(BLACKLISTED_IDS == null)
generateBlacklistedCommodityIDs();
return BLACKLISTED_IDS.contains(id);
}

private static void generateBlacklistedCommodityIDs()
{
ArrayList<String> blacklistedCommodities = new ArrayList<>();
try
Expand All @@ -59,7 +68,9 @@ public static ArrayList<String> getBlacklistedCommodities()
Logger.log("Could not read the blacklist", LogName.WARNING, e, 992);
}

return blacklistedCommodities;
BLACKLISTED_IDS = new ArrayList<>();
for(String commodity : blacklistedCommodities)
BLACKLISTED_IDS.add(DBHandler.getCommodityIDByName(commodity));
}

public static void addSystemToBlacklist(String systemName)
Expand Down

0 comments on commit c12783e

Please sign in to comment.