Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
Conflicts: Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java
This commit is contained in:
commit
424a9defa9
@ -3,6 +3,7 @@ package mineplex.bungee.status;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -13,19 +14,19 @@ public class InternetStatus implements Runnable
|
||||
{
|
||||
private Plugin _plugin;
|
||||
private StatusRepository _repository;
|
||||
|
||||
|
||||
public InternetStatus(Plugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
|
||||
|
||||
ListenerInfo listenerInfo = _plugin.getProxy().getConfigurationAdapter().getListeners().iterator().next();
|
||||
boolean us = !new File("eu.dat").exists();
|
||||
String address = listenerInfo.getHost().getAddress().getHostAddress() + ":" + listenerInfo.getHost().getPort();
|
||||
|
||||
|
||||
_repository = new StatusRepository(address, us);
|
||||
_repository.initialize();
|
||||
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 1L, 1L, TimeUnit.MINUTES);
|
||||
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 5L, 5L, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -36,24 +37,44 @@ public class InternetStatus implements Runnable
|
||||
|
||||
private boolean isOnline()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (InetAddress.getByName("www.google.com").isReachable(1000))
|
||||
return true;
|
||||
else if (InetAddress.getByName("www.espn.com").isReachable(1000))
|
||||
return true;
|
||||
else if (InetAddress.getByName("www.bing.com").isReachable(1000))
|
||||
return true;
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (testUrl("www.google.com"))
|
||||
return true;
|
||||
else if (testUrl("www.espn.com"))
|
||||
return true;
|
||||
else if (testUrl("www.bing.com"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean testUrl(String url)
|
||||
{
|
||||
Socket socket = null;
|
||||
boolean reachable = false;
|
||||
|
||||
try
|
||||
{
|
||||
socket = new Socket(url, 80);
|
||||
reachable = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Meh i don't care
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (socket != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
socket.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return reachable;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,9 @@ import net.minecraft.server.v1_7_R3.Blocks;
|
||||
import net.minecraft.server.v1_7_R3.ChunkCoordIntPair;
|
||||
import net.minecraft.server.v1_7_R3.ChunkSection;
|
||||
import net.minecraft.server.v1_7_R3.EnumSkyBlock;
|
||||
import net.minecraft.server.v1_7_R3.ExceptionWorldConflict;
|
||||
import net.minecraft.server.v1_7_R3.IContainer;
|
||||
import net.minecraft.server.v1_7_R3.IProgressUpdate;
|
||||
import net.minecraft.server.v1_7_R3.MinecraftServer;
|
||||
import net.minecraft.server.v1_7_R3.PacketPlayOutMapChunkBulk;
|
||||
import net.minecraft.server.v1_7_R3.PacketPlayOutMultiBlockChange;
|
||||
@ -135,12 +137,14 @@ public class MapUtil
|
||||
|
||||
public static void ChunkBlockChange(Location location, int id, byte data)
|
||||
{
|
||||
ChunkBlockChange(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), id, data);
|
||||
ChunkBlockChange(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), id,
|
||||
data);
|
||||
}
|
||||
|
||||
public static void ChunkBlockChange(World world, int x, int y, int z, int id, byte data)
|
||||
{
|
||||
if (changeChunkBlock(x & 15, y, z & 15, ((CraftWorld) world).getHandle().getChunkAt(x >> 4, z >> 4), Block.e(id), data))
|
||||
{
|
||||
if (changeChunkBlock(x & 15, y, z & 15, ((CraftWorld) world).getHandle().getChunkAt(x >> 4, z >> 4),
|
||||
Block.e(id), data))
|
||||
{
|
||||
((CraftWorld) world).getHandle().notify(x, y, z);
|
||||
}
|
||||
@ -177,19 +181,25 @@ public class MapUtil
|
||||
{
|
||||
UnloadWorld(plugin, world, false);
|
||||
}
|
||||
|
||||
|
||||
public static void UnloadWorld(JavaPlugin plugin, World world, boolean save)
|
||||
{
|
||||
if (save)
|
||||
world.save();
|
||||
|
||||
world.setAutoSave(save);
|
||||
|
||||
for (Entity entity : world.getEntities())
|
||||
{
|
||||
entity.remove();
|
||||
try
|
||||
{
|
||||
((CraftWorld) world).getHandle().save(true, (IProgressUpdate) null);
|
||||
}
|
||||
catch (ExceptionWorldConflict e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
((CraftWorld) world).getHandle().saveLevel();
|
||||
}
|
||||
|
||||
world.setAutoSave(save);
|
||||
|
||||
CraftServer server = (CraftServer) plugin.getServer();
|
||||
CraftWorld craftWorld = (CraftWorld) world;
|
||||
|
||||
@ -198,6 +208,11 @@ public class MapUtil
|
||||
Iterator<net.minecraft.server.v1_7_R3.Chunk> chunkIterator = ((CraftWorld) world).getHandle().chunkProviderServer.chunks
|
||||
.values().iterator();
|
||||
|
||||
for (Entity entity : world.getEntities())
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
|
||||
while (chunkIterator.hasNext())
|
||||
{
|
||||
net.minecraft.server.v1_7_R3.Chunk chunk = chunkIterator.next();
|
||||
|
@ -320,21 +320,18 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
}
|
||||
|
||||
//Unload World > Copy
|
||||
String worldName = _worldManager.prepMapParse(world);
|
||||
World parseableWorld = _worldManager.prepMapParse(world);
|
||||
|
||||
if (worldName == null)
|
||||
if (parseableWorld == null)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Could not prepare world for parsing!"));
|
||||
return;
|
||||
}
|
||||
|
||||
//World to be Parsed
|
||||
World parseableWorld = Bukkit.getWorld(worldName);
|
||||
|
||||
event.getPlayer().teleport(new Location(parseableWorld, 0, 30 ,0));
|
||||
//event.getPlayer().teleport(new Location(parseableWorld, 0, 30 ,0));
|
||||
|
||||
//Parse the World
|
||||
//_curParse = new Parse(this, parseableWorld, msg.split(" "), parseLoc, gameType, "Default", "Default");
|
||||
_curParse = new Parse(this, parseableWorld, msg.split(" "), parseLoc, gameType, "Default", "Default");
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/worlds"))
|
||||
{
|
||||
@ -364,7 +361,6 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
try
|
||||
{
|
||||
_worldManager.finalizeParsedWorld(_curParse.getGameType(), _curParse.getWorld());
|
||||
Announce("ZIP Created! Thank you, please come again!");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ public class WorldManager
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
public String prepMapParse(World world)
|
||||
public World prepMapParse(World world)
|
||||
{
|
||||
//Unload World
|
||||
MapUtil.UnloadWorld(_plugin, world, true);
|
||||
@ -62,9 +62,7 @@ public class WorldManager
|
||||
return null;
|
||||
}
|
||||
|
||||
Bukkit.createWorld(new WorldCreator("parse_" + world.getName()));
|
||||
|
||||
return "parse_" + world.getName();
|
||||
return Bukkit.createWorld(new WorldCreator("parse_" + world.getName()));
|
||||
}
|
||||
|
||||
public void finalizeParsedWorld(String gameType, World world)
|
||||
|
Loading…
Reference in New Issue
Block a user