Fixed personal servers overriding existing servergroups.

This commit is contained in:
Jonathan Williams 2015-02-09 00:15:18 -08:00
parent 44bab01e33
commit f98d6e0534

View File

@ -122,22 +122,41 @@ public class PersonalServerManager extends MiniPlugin
createGroup(player, serverName, 12, 24, "Smash");
}
private void createGroup(final Player host, final String serverName, int minPlayers, int maxPlayers, String games)
private void createGroup(final Player host, final String serverName, final int minPlayers, final int maxPlayers, final String games)
{
final ServerGroup serverGroup = new ServerGroup(serverName, serverName, host.getName(), 1024, 1, 1, 0, UtilMath.random.nextInt(250) + 19999, true, "arcade.zip", "Arcade.jar", "plugins/Arcade/", minPlayers, maxPlayers,
true, false, false, games, "Player", false, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU);
GetPlugin().getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
{
public void run()
{
_repository.updateServerGroup(serverGroup);
Bukkit.getScheduler().runTask(GetPlugin(), new Runnable()
for (ServerGroup existingServerGroup : _repository.getServerGroups(null))
{
if (existingServerGroup.getPrefix().equalsIgnoreCase(serverName) || existingServerGroup.getName().equalsIgnoreCase(serverName))
{
if (host.getName().equalsIgnoreCase(existingServerGroup.getHost()))
host.sendMessage(F.main(getName(), "Your server is still being created. If you haven't been connected in 20 seconds, type /server " + serverName + "-1."));
else
host.sendMessage(C.cRed + "Sorry, but you're not allowed to create a MPS server because you have chosen a name to glitch the system :)");
return;
}
}
final ServerGroup serverGroup = new ServerGroup(serverName, serverName, host.getName(), 1024, 1, 1, 0, UtilMath.random.nextInt(250) + 19999, true, "arcade.zip", "Arcade.jar", "plugins/Arcade/", minPlayers, maxPlayers,
true, false, false, games, "Player", false, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU);
GetPlugin().getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
{
public void run()
{
host.sendMessage(F.main(getName(), serverName + "-1 successfully created. You will be sent to it shortly."));
host.sendMessage(F.main(getName(), "If you haven't been connected in 20 seconds, type /server " + serverName + "-1."));
_repository.updateServerGroup(serverGroup);
Bukkit.getScheduler().runTask(GetPlugin(), new Runnable()
{
public void run()
{
host.sendMessage(F.main(getName(), serverName + "-1 successfully created. You will be sent to it shortly."));
host.sendMessage(F.main(getName(), "If you haven't been connected in 20 seconds, type /server " + serverName + "-1."));
}
});
}
});
}