Clean up maps on local server

This commit is contained in:
samczsun 2017-02-18 14:10:57 -05:00 committed by cnr
parent 9669e960a7
commit dedcd254b0

View File

@ -277,12 +277,33 @@ public class WorldGen extends JavaPlugin implements Runnable, Listener
try try
{ {
getLogger().info("Uploading " + seed + "!");
HttpResponse response = httpClient.execute(request); HttpResponse response = httpClient.execute(request);
if (response.getStatusLine().getStatusCode() != 200) { if (response.getStatusLine().getStatusCode() != 200)
{
if (response.getStatusLine().getStatusCode() == 409)
{
getLogger().warning("Oops - Server rejected " + seed + " because it was already generated");
if (!outputFile.delete())
{
getLogger().warning("Could not clean up " + seed);
}
}
else
{
getLogger().severe("Failed to upload " + seed + ": " + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase()); getLogger().severe("Failed to upload " + seed + ": " + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
} else { }
}
else
{
getLogger().info("Uploaded " + seed + "!"); getLogger().info("Uploaded " + seed + "!");
if (!outputFile.delete())
{
getLogger().warning("Could not clean up " + seed);
}
} }
} }
catch (IOException e) catch (IOException e)