Merge pull request #128 in MIN/mineplex from md_5/mineplexer/leak to develop

* commit '6cf08193dfbedb08352fd3a450022afac0ecd331':
  Fix small memory leak in Mineplexer.
This commit is contained in:
Shaun Bennett 2016-01-20 12:23:13 -06:00
commit c7bb380a56
2 changed files with 10 additions and 8 deletions

View File

@ -1,5 +1,6 @@
package mineplex.bungee.playerTracker;
import java.util.UUID;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.PlayerJoinCommand;
import mineplex.serverdata.commands.ServerCommand;
@ -21,7 +22,7 @@ public class PlayerJoinHandler implements CommandCallback
{
PlayerJoinCommand joinCommand = (PlayerJoinCommand)command;
_playerTracker.kickPlayerIfOnline(joinCommand.getUuid());
_playerTracker.kickPlayerIfOnline(UUID.fromString(joinCommand.getUuid()));
}
}
}

View File

@ -2,6 +2,7 @@ package mineplex.bungee.playerTracker;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@ -27,7 +28,7 @@ public class PlayerTracker implements Listener, Runnable
// Repository storing player status' across network.
private DataRepository<PlayerStatus> _repository;
private HashSet<String> _onlineUUIDs = new HashSet<String>();
private Set<UUID> _onlineUUIDs = new HashSet<>();
private Plugin _plugin;
@ -76,32 +77,32 @@ public class PlayerTracker implements Listener, Runnable
@EventHandler
public void playerConnect(final PostLoginEvent event)
{
_onlineUUIDs.add(event.getPlayer().getUniqueId().toString());
_onlineUUIDs.add(event.getPlayer().getUniqueId());
}
@Override
public void run()
{
HashSet<String> onlineUUIDs = new HashSet<String>();
Set<UUID> onlineUUIDs = new HashSet<>();
for (ProxiedPlayer player : _plugin.getProxy().getPlayers())
{
onlineUUIDs.add(player.getUniqueId().toString());
onlineUUIDs.add(player.getUniqueId());
}
_onlineUUIDs = onlineUUIDs;
}
public boolean isPlayerOnline(String uuid)
public boolean isPlayerOnline(UUID uuid)
{
return _onlineUUIDs.contains(uuid);
}
public void kickPlayerIfOnline(String uuid)
public void kickPlayerIfOnline(UUID uuid)
{
if (_onlineUUIDs.contains(uuid))
{
ProxiedPlayer player = _plugin.getProxy().getPlayer(UUID.fromString(uuid));
ProxiedPlayer player = _plugin.getProxy().getPlayer(uuid);
if (player != null)
player.disconnect("You have logged in from another location.");