Skip to content

Commit

Permalink
fixed another part of #2 (forge version list)
Browse files Browse the repository at this point in the history
  • Loading branch information
dries007 committed Oct 11, 2014
1 parent 9fa04ac commit 972c0f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/doubledoordev/backend/server/Server.java
Expand Up @@ -852,16 +852,16 @@ public boolean stopServer() throws ServerOnlineException
if (!getOnline()) return false;
try
{
getRCon().stop();
printLine("----=====##### STOPPING SERVER WITH RCON #####=====-----");
getRCon().stop();
return true;
}
catch (Exception e)
{
printLine("----=====##### STOPPING SERVER VIA STREAM #####=====-----");
PrintWriter printWriter = new PrintWriter(process.getOutputStream());
printWriter.println("stop");
printWriter.flush();
printLine("----=====##### STOPPING SERVER VIA STREAM #####=====-----");
return false;
}
}
Expand Down
26 changes: 17 additions & 9 deletions src/main/java/net/doubledoordev/backend/util/Runnables.java
Expand Up @@ -82,21 +82,29 @@ public void run()
JsonObject latest = versionList.getAsJsonObject("promos");
HashSet<Integer> buildsWithoutInstaller = new HashSet<>();

nameBuildMap.put("~~==## \\/ Recommended Versions \\/ ##==~~", null);
for (Map.Entry<String, JsonElement> element : latest.entrySet())
{
nameBuildMap.put(String.format("%s (build %d)", element.getKey(), element.getValue().getAsInt()), element.getValue().getAsInt());
}
nameBuildMap.put("~~==## \\/ Specific Versions \\/ ##==~~", null);
for (Map.Entry<String, JsonElement> entry : versionList.getAsJsonObject("number").entrySet())
String lastMc = "";
ArrayList<Map.Entry<String, JsonElement>> entries = new ArrayList<>(versionList.getAsJsonObject("number").entrySet());
for (int i = entries.size() - 1; i > 0; i--)
{
JsonObject object = entry.getValue().getAsJsonObject();
JsonObject object = entries.get(i).getValue().getAsJsonObject();
String mc = object.get("mcversion").getAsString();
String version = object.get("version").getAsString();
int build = object.get("build").getAsInt();

nameBuildMap.put(String.format("%s (MC %s)", object.get("version").getAsString(), object.get("mcversion").getAsString()), object.get("build").getAsInt());
buildVersionMap.put(object.get("build").getAsInt(), String.format("%s-%s", object.get("mcversion").getAsString(), object.get("version").getAsString()));
if (!lastMc.equals(mc) && hasInstaller(object))
{
nameBuildMap.put(String.format("~~~~~~~~~~========== %s ==========~~~~~~~~~~", mc), 0);
lastMc = mc;
}

if (!hasInstaller(object)) buildsWithoutInstaller.add(object.get("build").getAsInt());
nameBuildMap.put(String.format("%s (MC %s)", version, mc), build);
buildVersionMap.put(build, String.format("%s-%s", mc, version));

if (!hasInstaller(object)) buildsWithoutInstaller.add(build);
}
synchronized (NAME_VERSION_MAP)
{
Expand All @@ -115,8 +123,8 @@ public void run()
}

};
static long lastMCVersions = 0L;
static final Runnable MC_VERSIONS_DOWNLOADER = new Runnable()
static long lastMCVersions = 0L;
static final Runnable MC_VERSIONS_DOWNLOADER = new Runnable()
{
@Override
public void run()
Expand Down

0 comments on commit 972c0f0

Please sign in to comment.