Mineplex2018-withcommit/Plugins/Mineplex.Cache/src/mineplex/cache/player/PlayerCache.java
NewGarbo b47665e115 lots of work on outposts,
fixed gold dupe glitch,
fixed clans ban gui title being "Customize New Gear".
2016-01-02 14:02:50 +00:00

66 lines
1.3 KiB
Java

package mineplex.cache.player;
import java.util.UUID;
import mineplex.serverdata.Region;
import mineplex.serverdata.redis.RedisDataRepository;
import mineplex.serverdata.servers.ServerManager;
public class PlayerCache
{
private static PlayerCache _instance = null;
private RedisDataRepository<PlayerInfo> _repository;
public static PlayerCache getInstance()
{
if (_instance == null)
_instance = new PlayerCache();
return _instance;
}
private PlayerCache()
{
_repository = new RedisDataRepository<PlayerInfo>(
ServerManager.getMasterConnection(),
ServerManager.getSlaveConnection(),
Region.ALL,
PlayerInfo.class,
"playercache");
}
public void addPlayer(PlayerInfo player)
{
try
{
_repository.addElement(player, 60 * 60 * 6); // 6 Hours
}
catch (Exception exception)
{
System.out.println("Error adding player info in PlayerCache : " + exception.getMessage());
// exception.printStackTrace();
}
}
public PlayerInfo getPlayer(UUID uuid)
{
try
{
return _repository.getElement(uuid.toString());
}
catch (Exception exception)
{
System.out.println("Error retrieving player info in PlayerCache : " + exception.getMessage());
exception.printStackTrace();
}
return null;
}
public void clean()
{
_repository.clean();
}
}