mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-17 12:54:03 +00:00
admin cmd done
This commit is contained in:
47
src/main/java/me/totalfreedom/plex/cache/DataUtils.java
vendored
Normal file
47
src/main/java/me/totalfreedom/plex/cache/DataUtils.java
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
package me.totalfreedom.plex.cache;
|
||||
|
||||
import me.totalfreedom.plex.Plex;
|
||||
import me.totalfreedom.plex.player.PlexPlayer;
|
||||
import me.totalfreedom.plex.storage.StorageType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DataUtils
|
||||
{
|
||||
|
||||
public static boolean hasPlayedBefore(UUID uuid)
|
||||
{
|
||||
if (Plex.get().getStorageType() == StorageType.MONGO)
|
||||
{
|
||||
return Plex.get().getMongoPlayerData().exists(uuid);
|
||||
} else {
|
||||
return Plex.get().getSqlPlayerData().exists(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
public static PlexPlayer getPlayer(UUID uuid)
|
||||
{
|
||||
if (PlayerCache.getPlexPlayerMap().containsKey(uuid))
|
||||
{
|
||||
return PlayerCache.getPlexPlayerMap().get(uuid);
|
||||
}
|
||||
|
||||
if (Plex.get().getStorageType() == StorageType.MONGO)
|
||||
{
|
||||
return Plex.get().getMongoPlayerData().getByUUID(uuid);
|
||||
} else {
|
||||
return Plex.get().getSqlPlayerData().getByUUID(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
public static void update(PlexPlayer plexPlayer)
|
||||
{
|
||||
if (Plex.get().getStorageType() == StorageType.MONGO)
|
||||
{
|
||||
Plex.get().getMongoPlayerData().update(plexPlayer);
|
||||
} else {
|
||||
Plex.get().getSqlPlayerData().update(plexPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -55,6 +55,7 @@ public class MongoPlayerData
|
||||
updateOps.execute();
|
||||
}
|
||||
|
||||
|
||||
public void save(PlexPlayer plexPlayer)
|
||||
{
|
||||
datastore.save(plexPlayer);
|
||||
|
@@ -1,11 +1,12 @@
|
||||
package me.totalfreedom.plex.cache;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import me.totalfreedom.plex.player.PlexPlayer;
|
||||
import me.totalfreedom.plex.player.PunishedPlayer;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerCache
|
||||
{
|
||||
private static final Map<UUID, PlexPlayer> plexPlayerMap = Maps.newHashMap();
|
||||
|
Reference in New Issue
Block a user