Fix redis working on the same thread
This commit is contained in:
parent
1fbadfa4f4
commit
d6c3b330b5
@ -428,7 +428,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
FriendData friends = _friendsManager.Get(sender);
|
||||
FriendStatus friend = null;
|
||||
|
||||
/*if (!adminMessage)
|
||||
if (!adminMessage)
|
||||
{
|
||||
|
||||
for (FriendStatus friendInfo : friends.getFriends())
|
||||
@ -449,7 +449,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
friend = friendInfo;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
// We now have the friend object, if its not null. We are sending the message to that player.
|
||||
|
||||
|
@ -100,14 +100,14 @@ public class PartyManager extends MiniPlugin
|
||||
|
||||
boolean destLobby = event.getServer().equalsIgnoreCase("lobby");
|
||||
|
||||
/*RedisPartyData data = new RedisPartyData(party, destLobby ? _serverName : null);
|
||||
RedisPartyData data = new RedisPartyData(party, destLobby ? _serverName : null);
|
||||
|
||||
if (!destLobby)
|
||||
{
|
||||
data.setTargetServers(event.getServer());
|
||||
}
|
||||
|
||||
data.publish();*/
|
||||
data.publish();
|
||||
|
||||
if (!destLobby)
|
||||
{
|
||||
@ -115,7 +115,7 @@ public class PartyManager extends MiniPlugin
|
||||
{
|
||||
if (player != event.getPlayer())
|
||||
{
|
||||
_portal.sendPlayerToServer(player, event.getServer());
|
||||
_portal.sendPlayerToServer(player, event.getServer(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,14 +76,22 @@ public class Portal extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPlayerToServer(final Player player, final String serverName)
|
||||
public void sendPlayerToServer(Player player, String serverName)
|
||||
{
|
||||
sendPlayerToServer(player, serverName, true);
|
||||
}
|
||||
|
||||
public void sendPlayerToServer(final Player player, final String serverName, boolean callEvent)
|
||||
{
|
||||
if (_connectingPlayers.contains(player.getName()))
|
||||
return;
|
||||
|
||||
ServerTransferEvent event = new ServerTransferEvent(player, serverName);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (callEvent)
|
||||
{
|
||||
ServerTransferEvent event = new ServerTransferEvent(player, serverName);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
final boolean override = serverName.equalsIgnoreCase("Lobby");
|
||||
final Rank playerRank = _clientManager.Get(player).GetRank();
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class ServerCommandManager
|
||||
final Jedis jedis = _jedisPool.getResource();
|
||||
|
||||
// Spin up a new thread and subscribe to the Redis pubsub network
|
||||
Thread thread = new Thread(new Runnable()
|
||||
Thread thread = new Thread("Redis Manager")
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
@ -60,7 +60,7 @@ public class ServerCommandManager
|
||||
_jedisPool.returnResource(jedis);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
thread.start();
|
||||
}
|
||||
@ -100,7 +100,7 @@ public class ServerCommandManager
|
||||
* @param commandType - the type of command being received
|
||||
* @param serializedCommand - the serialized {@link ServerCommand} data.
|
||||
*/
|
||||
public void handleCommand(String commandType, String serializedCommand)
|
||||
public void handleCommand(final String commandType, String serializedCommand)
|
||||
{
|
||||
if (!isServerInitialized())
|
||||
{
|
||||
@ -111,19 +111,26 @@ public class ServerCommandManager
|
||||
if (_commandTypes.containsKey(commandType))
|
||||
{
|
||||
Class<? extends ServerCommand> commandClazz = _commandTypes.get(commandType).getCommandType();
|
||||
ServerCommand serverCommand = Utility.deserialize(serializedCommand, commandClazz);
|
||||
final ServerCommand serverCommand = Utility.deserialize(serializedCommand, commandClazz);
|
||||
|
||||
if (!serverCommand.isTargetServer(_localServerName))
|
||||
return;
|
||||
|
||||
// TODO: Run synchronously?
|
||||
CommandCallback callback = _commandTypes.get(commandType).getCallback();
|
||||
serverCommand.run(); // Run server command without callback
|
||||
|
||||
if (callback != null)
|
||||
new Thread("Redis Command " + commandType)
|
||||
{
|
||||
callback.run(serverCommand); // Run callback
|
||||
}
|
||||
public void run()
|
||||
{
|
||||
// TODO: Run synchronously?
|
||||
CommandCallback callback = _commandTypes.get(commandType).getCallback();
|
||||
serverCommand.run(); // Run server command without callback
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
callback.run(serverCommand); // Run callback
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user