diff --git a/.gitignore b/.gitignore index 863e013..5df879d 100644 --- a/.gitignore +++ b/.gitignore @@ -159,3 +159,4 @@ $RECYCLE.BIN/ /steamapps.json /test.json /steam_api.md5 +/src/main/java/util/env/Default.java diff --git a/src/main/java/util/SteamAppsListCache.java b/src/main/java/util/SteamAppsListCache.java index 4064820..d7422d5 100644 --- a/src/main/java/util/SteamAppsListCache.java +++ b/src/main/java/util/SteamAppsListCache.java @@ -11,6 +11,7 @@ import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import pojo.App; import pojo.SteamAppsList; +import util.env.MainEnv; import java.io.*; import java.lang.reflect.Type; @@ -24,11 +25,22 @@ import java.util.stream.Collectors; public class SteamAppsListCache { - private static final String KEY = "E427256C579D3CDF1D504810E8F5B948"; private SteamAppsList list = new SteamAppsList(); private File cacheFile = new File("steamapps.json"); + private MainEnv env; + //private String key; public SteamAppsListCache() { + try { + Class envDefault = Class.forName("util.env.Default"); + env = (MainEnv) envDefault.newInstance(); + //System.out.println(env.getKey()); + } catch (ClassNotFoundException e) { + env = new MainEnv(); + } catch (IllegalAccessException | InstantiationException e) { + // Only thrown by newInstance() + e.printStackTrace(); + } boolean fileFound = true; try { getListFromFile(); @@ -85,7 +97,7 @@ public class SteamAppsListCache { private List getApps() { HttpResponse httpResponse = Unirest.get("https://api.steampowered.com/IStoreService/GetAppList/v1/" + - "?key=" + KEY + "&include_games=1&max_results=50000").asString(); + "?key=" + env.getKey() + "&include_games=1&max_results=50000").asString(); return new Gson() .fromJson(httpResponse.getBody(), App.Rezponze.Download.class) .getResponse().getApps(); diff --git a/src/main/java/util/env/MainEnv.java b/src/main/java/util/env/MainEnv.java new file mode 100644 index 0000000..52cd44a --- /dev/null +++ b/src/main/java/util/env/MainEnv.java @@ -0,0 +1,9 @@ +package util.env; + +public class MainEnv { + String key = ""; + + public String getKey() { + return key; + } +}