Squished remaining concurrency/checking bugs! Happy 4th o'July!

This commit is contained in:
Peter Miller 2014-07-04 02:19:20 -04:00
parent 2531dd7a8f
commit b56855c33c
4 changed files with 117 additions and 68 deletions

View File

@ -1,5 +1,6 @@
package mineplex.core.portal.Commands;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -31,7 +32,7 @@ public class SendCommand extends CommandBase<Portal>
}
@Override
public void Execute(Player player, String[] args)
public void Execute(final Player player, final String[] args)
{
Rank playerRank = CommandCenter.GetClientManager().Get(player).GetRank();
@ -40,7 +41,7 @@ public class SendCommand extends CommandBase<Portal>
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your arguments are inappropriate for this command!"));
return;
}
else if(args.length == 2)
else if(args.length == 1)
{
if((playerRank == Rank.OWNER) || (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN))
{
@ -53,19 +54,54 @@ public class SendCommand extends CommandBase<Portal>
catch(NullPointerException npe)
{
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your specified player, " + C.cGold + args[0] + C.cPurple + ", does not exist!"));
if(!_portal.DoesServerExist(args[1]))
{
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your specified server, " + C.cGold + args[1] + C.cPurple + ", does not exist!"));
}
return;
}
if(!_portal.DoesServerExist(args[1]))
}
String currentServer = sendPlayer.getServer().getPluginManager().getPlugin("Arcade").getConfig().getString("serverstatus.name");
UtilPlayer.message(player, F.main("SEND", C.cGold + args[0] + C.cPurple + " is currently on server: " + C.cGold + currentServer + C.cPurple + "!"));
return;
}
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your arguments are not allowed for this command!"));
return;
}
else if(args.length == 2)
{
if((playerRank == Rank.OWNER) || (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN))
{
_portal.DoesServerExist(args[1]);
Bukkit.getScheduler().runTaskLater(Plugin.GetPlugin(), new Runnable()
{
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your specified server, " + C.cGold + args[1] + C.cPurple + ", does not exist!"));
return;
}
SendPlayerToServerWithMessage(sendPlayer, args[1]);
UtilPlayer.message(player, F.main("SEND", C.cYellow + "You have sent player: " + C.cGold + args[0] + C.cYellow + " to server: " + C.cGold + args[1] + C.cYellow + "!"));
public void run()
{
Player sendPlayer;
try
{
sendPlayer = CommandCenter.GetClientManager().Get(args[0]).GetPlayer();
}
catch(NullPointerException npe)
{
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your specified player, " + C.cGold + args[0] + C.cPurple + ", does not exist!"));
if(!_portal.GetServerExists())
{
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your specified server, " + C.cGold + args[1] + C.cPurple + ", does not exist!"));
}
return;
}
if(!_portal.GetServerExists())
{
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your specified server, " + C.cGold + args[1] + C.cPurple + ", does not exist!"));
return;
}
if(sendPlayer.getServer().getPluginManager().getPlugin("Arcade").getConfig().getString("serverstatus.name").equalsIgnoreCase(args[1]))
{
UtilPlayer.message(player, F.main("SEND", C.cGold + args[0] + C.cPurple + " is already on server: " + C.cGold + args[1] + C.cPurple + "!"));
return;
}
SendPlayerToServerWithMessage(sendPlayer, args[1]);
UtilPlayer.message(player, F.main("SEND", C.cYellow + "You have sent player: " + C.cGold + args[0] + C.cYellow + " to server: " + C.cGold + args[1] + C.cYellow + "!"));
return;
}
}, 20);
return;
}
UtilPlayer.message(player, F.main("SEND", C.cPurple + "Your arguments are not allowed for this command!"));

View File

@ -1,5 +1,6 @@
package mineplex.core.portal.Commands;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -31,66 +32,73 @@ public class ServerCommand extends CommandBase<Portal>
}
@Override
public void Execute(Player player, String[] args)
public void Execute(final Player player, final String[] args)
{
Rank playerRank = CommandCenter.GetClientManager().Get(player).GetRank();
String serverName = Plugin.GetPlugin().getConfig().getString("serverstatus.name");
final Rank playerRank = CommandCenter.GetClientManager().Get(player).GetRank();
final String serverName = Plugin.GetPlugin().getConfig().getString("serverstatus.name");
if(args == null || args.length == 0)
{
UtilPlayer.message(player, F.main("SERVER", C.cYellow + "You are currently on server: " + C.cGold + serverName));
return;
return;
}
else if(args.length == 1)
{
if(serverName.equalsIgnoreCase(args[0]))
_portal.DoesServerExist(args[0]);
Bukkit.getServer().getScheduler().runTaskLater(Plugin.GetPlugin(), new Runnable()
{
UtilPlayer.message(player, F.main("SERVER", C.cPurple + "You are already on server: " + C.cGold + serverName + C.cPurple + "!"));
return;
}
if(!_portal.DoesServerExist(args[0]))
{
UtilPlayer.message(player, F.main("SERVER", C.cPurple + "Your specified server, " + C.cGold + args[0] + C.cPurple + ", does not exist!"));
return;
}
String servUp = args[0].toUpperCase();
if(!(servUp.contains("HERO") || servUp.contains("ULTRA") || servUp.contains("BETA")
|| servUp.contains("STAFF") || servUp.contains("TEST")))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
if(servUp.contains("HERO") && ((playerRank == Rank.OWNER)
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|| (playerRank == Rank.HELPER) || (playerRank == Rank.MAPDEV) || (playerRank == Rank.YOUTUBE)
|| (playerRank == Rank.ULTRA) || (playerRank == Rank.HERO)))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
if((servUp.contains("ULTRA") || servUp.contains("BETA")) && ((playerRank == Rank.OWNER)
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|| (playerRank == Rank.HELPER) || (playerRank == Rank.MAPDEV) || (playerRank == Rank.YOUTUBE)
|| (playerRank == Rank.ULTRA)))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
if(servUp.contains("STAFF") && ((playerRank == Rank.OWNER)
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|| (playerRank == Rank.HELPER)))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
if(servUp.contains("TEST") && ((playerRank == Rank.OWNER)
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
UtilPlayer.message(player, F.main("SERVER", C.cPurple + "Your arguments are not allowed for this command!"));
return;
public void run()
{
if(serverName.equalsIgnoreCase(args[0]))
{
UtilPlayer.message(player, F.main("SERVER", C.cPurple + "You are already on server: " + C.cGold + serverName + C.cPurple + "!"));
return;
}
if(!_portal.GetServerExists())
{
UtilPlayer.message(player, F.main("SERVER", C.cPurple + "Your specified server, " + C.cGold + args[0] + C.cPurple + ", does not exist!"));
return;
}
String servUp = args[0].toUpperCase();
if(!(servUp.contains("HERO") || servUp.contains("ULTRA") || servUp.contains("BETA")
|| servUp.contains("STAFF") || servUp.contains("TEST")))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
if(servUp.contains("HERO") && ((playerRank == Rank.OWNER)
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|| (playerRank == Rank.HELPER) || (playerRank == Rank.MAPDEV) || (playerRank == Rank.YOUTUBE)
|| (playerRank == Rank.ULTRA) || (playerRank == Rank.HERO)))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
if((servUp.contains("ULTRA") || servUp.contains("BETA")) && ((playerRank == Rank.OWNER)
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|| (playerRank == Rank.HELPER) || (playerRank == Rank.MAPDEV) || (playerRank == Rank.YOUTUBE)
|| (playerRank == Rank.ULTRA)))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
if(servUp.contains("STAFF") && ((playerRank == Rank.OWNER)
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)
|| (playerRank == Rank.HELPER)))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
if(servUp.contains("TEST") && ((playerRank == Rank.OWNER)
|| (playerRank == Rank.DEVELOPER) || (playerRank == Rank.ADMIN) || (playerRank == Rank.MODERATOR)))
{
SendPlayerToServerWithMessage(player, args[0]);
return;
}
UtilPlayer.message(player, F.main("SERVER", C.cPurple + "Your arguments are not allowed for this command!"));
return;
}
}, 20);
}
else
{

View File

@ -29,7 +29,8 @@ public class Portal extends MiniPlugin
private List<String> _transfers = new ArrayList<String>();
private boolean _retrieve = true;
private volatile boolean _serverExists = false;
private boolean _serverExists = false;
public Portal(JavaPlugin plugin)
{
@ -103,7 +104,7 @@ public class Portal extends MiniPlugin
}
}
public boolean DoesServerExist(final String serverName)
public void DoesServerExist(final String serverName)
{
synchronized (_transferLock)
{
@ -113,8 +114,12 @@ public class Portal extends MiniPlugin
{
_serverExists = _repository.doesServerExist(serverName);
}
});
});
}
}
public boolean GetServerExists()
{
return _serverExists;
}

View File

@ -231,7 +231,7 @@ public class PortalRepository
try
{
if (_altConnection == null)
if (_altConnection == null || _altConnection.isClosed())
{
_altConnection = DriverManager.getConnection(_altConnectString, _userName, _password);
}