Autorotate maps
This commit is contained in:
parent
3e8b23c6f4
commit
9669e960a7
|
@ -26,7 +26,7 @@ public class EnderchestWorldLoader
|
|||
{
|
||||
TimingManager.start(TIMINGS_PREFIX + "DownloadMap");
|
||||
String fileName = mapType + "_map.zip";
|
||||
File f = _webCall.getFile("map/" + mapType + "/random", fileName);
|
||||
File f = _webCall.getFile("map/" + mapType + "/next", fileName);
|
||||
TimingManager.stop(TIMINGS_PREFIX + "DownloadMap");
|
||||
|
||||
TimingManager.start(TIMINGS_PREFIX + "CreateFolders");
|
||||
|
|
|
@ -19,10 +19,20 @@
|
|||
<version>1.8.8-1.9-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mineplex</groupId>
|
||||
<artifactId>mineplex-core</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.zeroturnaround</groupId>
|
||||
<artifactId>zt-zip</artifactId>
|
||||
<version>1.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,7 +1,29 @@
|
|||
package nautilus.game.arcade.uhc;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.BiomeBase;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.protocol.HTTP;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.World;
|
||||
|
@ -14,20 +36,15 @@ import org.spigotmc.WatchdogThread;
|
|||
import org.zeroturnaround.zip.ZipEntrySource;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.ZipEntry;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import mineplex.core.common.Constants;
|
||||
import mineplex.core.common.api.ApiHost;
|
||||
|
||||
public class WorldGen extends JavaPlugin implements Runnable, Listener
|
||||
{
|
||||
private static final int TIMEOUT = (int) TimeUnit.SECONDS.toMillis(10);
|
||||
|
||||
private static final int MIN_X = -1000;
|
||||
private static final int MIN_Z = -1000;
|
||||
private static final int MAX_X = 1000;
|
||||
|
@ -240,6 +257,41 @@ public class WorldGen extends JavaPlugin implements Runnable, Listener
|
|||
|
||||
FileUtils.deleteQuietly(worldFolder);
|
||||
|
||||
getLogger().info("Finished generating world seed " + seed);
|
||||
RequestConfig config = RequestConfig.custom()
|
||||
.setConnectTimeout(TIMEOUT)
|
||||
.setSocketTimeout(TIMEOUT)
|
||||
.build();
|
||||
|
||||
CloseableHttpClient httpClient = HttpClientBuilder.create()
|
||||
.setDefaultRequestConfig(config)
|
||||
.build();
|
||||
|
||||
HttpPost request = new HttpPost("http://" + ApiHost.getEnderchestService().getHost() + ":" + ApiHost.getEnderchestService().getPort() + "/map/uhc/upload");
|
||||
request.addHeader(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
|
||||
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("name", outputFile.getName());
|
||||
jsonObject.addProperty("location", outputFile.toURI().toString());
|
||||
|
||||
request.setEntity(new StringEntity(Constants.GSON.toJson(jsonObject), StandardCharsets.UTF_8));
|
||||
|
||||
try
|
||||
{
|
||||
HttpResponse response = httpClient.execute(request);
|
||||
|
||||
if (response.getStatusLine().getStatusCode() != 200) {
|
||||
getLogger().severe("Failed to upload " + seed + ": " + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
|
||||
} else {
|
||||
getLogger().info("Uploaded " + seed + "!");
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
getLogger().info("Finished generating world seed " + seed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue