Fixed Lobby sending with Portal.

This commit is contained in:
Jonathan Williams 2015-01-12 09:55:32 -08:00
parent ac709d09ce
commit e14dfcf313

View File

@ -66,70 +66,41 @@ public class Portal extends MiniPlugin
if (_connectingPlayers.contains(player.getName()))
return;
final boolean override = serverName.equalsIgnoreCase("Lobby");
final Rank playerRank = _clientManager.Get(player).GetRank();
runAsync(new Runnable()
if (override)
{
public void run()
sendPlayer(player, serverName);
}
else
{
runAsync(new Runnable()
{
final MinecraftServer server = _repository.getServerStatus(serverName);
if (server == null)
return;
Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable()
public void run()
{
public void run()
final MinecraftServer server = _repository.getServerStatus(serverName);
if (server == null)
return;
Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable()
{
if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.Has(Rank.ULTRA))
public void run()
{
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try
if (server.getPlayerCount() < server.getMaxPlayerCount() || playerRank.Has(Rank.ULTRA))
{
out.writeUTF("Connect");
out.writeUTF(serverName);
sendPlayer(player, serverName);
}
catch (IOException e)
{
// Can never happen
}
finally
{
try
{
out.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
player.sendPluginMessage(GetPlugin(), "BungeeCord", b.toByteArray());
_connectingPlayers.add(player.getName());
GetScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{
public void run()
{
_connectingPlayers.remove(player.getName());
}
}, 20L);
else
UtilPlayer.message(
player,
F.main(getName(), "You have been sent to " + C.cGold + serverName));
F.main(getName(), C.cGold + serverName + C.cRed + " is full!"));
}
else
UtilPlayer.message(
player,
F.main(getName(), C.cGold + serverName + C.cRed + " is full!"));
}
});
}
});
});
}
});
}
}
public static void transferPlayer(String playerName, String serverName)
@ -166,4 +137,46 @@ public class Portal extends MiniPlugin
addCommand(new ServerCommand(this));
addCommand(new SendCommand(this));
}
private void sendPlayer(final Player player, String serverName)
{
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try
{
out.writeUTF("Connect");
out.writeUTF(serverName);
}
catch (IOException e)
{
// Can never happen
}
finally
{
try
{
out.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
player.sendPluginMessage(GetPlugin(), "BungeeCord", b.toByteArray());
_connectingPlayers.add(player.getName());
GetScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{
public void run()
{
_connectingPlayers.remove(player.getName());
}
}, 20L);
UtilPlayer.message(
player,
F.main(getName(), "You have been sent to " + C.cGold + serverName));
}
}