Convert PortalRepository's redis host fetch to ServerManager constant, and remove debug code section.

This commit is contained in:
Ty 2014-08-13 16:37:05 -04:00
parent 1bbb42214d
commit 4b4f43ac16
3 changed files with 8 additions and 19 deletions

View File

@ -46,8 +46,7 @@ public class Portal extends MiniPlugin
Bukkit.getMessenger().registerOutgoingPluginChannel(GetPlugin(), "BungeeCord"); Bukkit.getMessenger().registerOutgoingPluginChannel(GetPlugin(), "BungeeCord");
String host = plugin.getConfig().getString("serverstatus.connectionurl"); _repository = new PortalRepository();
_repository = new PortalRepository(host);
} }
public void SendAllPlayers(String serverName) public void SendAllPlayers(String serverName)
@ -150,23 +149,12 @@ public class Portal extends MiniPlugin
AddCommand(new ServerCommand(this)); AddCommand(new ServerCommand(this));
AddCommand(new SendCommand(this)); AddCommand(new SendCommand(this));
} }
boolean sent = false;
@EventHandler @EventHandler
public void checkForServerTransfers(UpdateEvent event) public void checkForServerTransfers(UpdateEvent event)
{ {
if (event.getType() != UpdateType.SEC || Bukkit.getOnlinePlayers().length == 0) if (event.getType() != UpdateType.SEC || Bukkit.getOnlinePlayers().length == 0)
return; return;
// DEBUG CODE - REMOVE THIS
if (Bukkit.getOnlinePlayers().length > 0 && !sent)
{
Player player = Bukkit.getOnlinePlayers()[0];
if (player.isSneaking())
{
System.out.println("Debug transferring player " + player.getName());
AddTransferRecord(player.getName(), "TEST-2");
sent = true;
}
}
_retrieve = !_retrieve; _retrieve = !_retrieve;

View File

@ -6,6 +6,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import mineplex.serverdata.ServerManager;
import mineplex.serverdata.Utility; import mineplex.serverdata.Utility;
import redis.clients.jedis.Jedis; import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPool;
@ -25,11 +26,11 @@ public class PortalRepository
/** /**
* Class constructor * Class constructor
* @param host - the host name connection URL for the repository database
*/ */
public PortalRepository(String host) public PortalRepository()
{ {
this._jedisPool = new JedisPool(new JedisPoolConfig(), host); this._jedisPool = new JedisPool(new JedisPoolConfig(), ServerManager.DEFAULT_REDIS_HOST,
ServerManager.DEFAULT_REDIS_PORT);
} }
/** /**

View File

@ -12,10 +12,10 @@ import java.util.Map;
public class ServerManager public class ServerManager
{ {
// The host of the default redis database used for server repository // The host of the default redis database used for server repository
private static String DEFAULT_REDIS_HOST = "10.33.53.16"; public final static String DEFAULT_REDIS_HOST = "10.33.53.16";
// The default port used by redis databases // The default port used by redis databases
private static int DEFAULT_REDIS_PORT = 6379; public final static int DEFAULT_REDIS_PORT = 6379;
// The cached repository instances // The cached repository instances
private static Map<Region, ServerRepository> repositories = new HashMap<Region, ServerRepository>(); private static Map<Region, ServerRepository> repositories = new HashMap<Region, ServerRepository>();