feat(cache): reworked implementation
This commit is contained in:
parent
f0b9c62a1b
commit
17fa5e81e7
19 changed files with 169 additions and 103 deletions
|
@ -70,12 +70,16 @@ public class NickoBukkit extends JavaPlugin {
|
|||
dataStore = new PlayerDataStore(mojangAPI, getNickoConfig());
|
||||
nameStore = new PlayerNameStore();
|
||||
|
||||
if (!dataStore.getStorage().isError()) {
|
||||
getLogger().info("Loading persistence...");
|
||||
if (!dataStore.getStorage().getProvider().init()) {
|
||||
dataStore.getStorage().setError(true);
|
||||
getLogger().severe("Failed to open persistence, data will NOT be saved!");
|
||||
}
|
||||
getLogger().info("Loading persistence...");
|
||||
if (!dataStore.getStorage().getProvider().init()) {
|
||||
dataStore.getStorage().setError(true);
|
||||
getLogger().severe("Failed to open persistence, data will NOT be saved!");
|
||||
}
|
||||
|
||||
getLogger().info("Loading cache...");
|
||||
if (!dataStore.getCache().getProvider().init()) {
|
||||
dataStore.getCache().setError(true);
|
||||
getLogger().severe("Failed to open cache, data will NOT be saved!");
|
||||
}
|
||||
|
||||
if (!unitTesting) {
|
||||
|
|
|
@ -12,23 +12,20 @@ public class Configuration {
|
|||
@JsonProperty("redis")
|
||||
private final DataSourceConfiguration redisConfiguration;
|
||||
private final String prefix;
|
||||
private final Boolean local;
|
||||
private final Boolean customLocale;
|
||||
|
||||
public Configuration(DataSourceConfiguration sqlConfiguration, DataSourceConfiguration redisConfiguration, String prefix, Boolean local, Boolean customLocale) {
|
||||
public Configuration(DataSourceConfiguration sqlConfiguration, DataSourceConfiguration redisConfiguration, String prefix, Boolean customLocale) {
|
||||
this.sqlConfiguration = sqlConfiguration;
|
||||
this.redisConfiguration = redisConfiguration;
|
||||
this.prefix = prefix;
|
||||
this.local = local;
|
||||
this.customLocale = customLocale;
|
||||
}
|
||||
|
||||
public Configuration() {
|
||||
this(
|
||||
new DataSourceConfiguration("", 3306, "", ""),
|
||||
new DataSourceConfiguration("", 6379, "", ""),
|
||||
new DataSourceConfiguration(false, "", 3306, "", ""),
|
||||
new DataSourceConfiguration(false, "", 6379, "", ""),
|
||||
"",
|
||||
false,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
@ -45,10 +42,6 @@ public class Configuration {
|
|||
return prefix;
|
||||
}
|
||||
|
||||
public Boolean isLocal() {
|
||||
return local;
|
||||
}
|
||||
|
||||
public Boolean isCustomLocale() {
|
||||
return customLocale;
|
||||
}
|
||||
|
|
|
@ -1,22 +1,28 @@
|
|||
package xyz.atnrch.nicko.config;
|
||||
|
||||
public class DataSourceConfiguration {
|
||||
public static final DataSourceConfiguration SQL_EMPTY = new DataSourceConfiguration("127.0.0.1", 3306, "root", "");
|
||||
public static final DataSourceConfiguration REDIS_EMPTY = new DataSourceConfiguration("127.0.0.1", 6379, "", "");
|
||||
public static final DataSourceConfiguration SQL_EMPTY = new DataSourceConfiguration(false, "127.0.0.1", 3306, "root", "");
|
||||
public static final DataSourceConfiguration REDIS_EMPTY = new DataSourceConfiguration(false, "127.0.0.1", 6379, "", "");
|
||||
|
||||
private final boolean enabled;
|
||||
private final String address;
|
||||
private final Integer port;
|
||||
private final String username;
|
||||
private final String password;
|
||||
|
||||
public DataSourceConfiguration(String address, Integer port, String username, String password) {
|
||||
public DataSourceConfiguration(boolean enabled, String address, Integer port, String username, String password) {
|
||||
this.enabled = enabled;
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public DataSourceConfiguration() { this("", 0, "", ""); }
|
||||
public DataSourceConfiguration() { this(false, "", 0, "", ""); }
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package xyz.atnrch.nicko.disguise;
|
||||
|
||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||
import com.comphenix.protocol.wrappers.*;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Multimap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import xyz.atnrch.nicko.NickoBukkit;
|
||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
|
@ -13,9 +17,6 @@ import xyz.atnrch.nicko.storage.name.PlayerNameStore;
|
|||
import xyz.atnrch.nicko.wrapper.WrapperPlayServerRespawn;
|
||||
import xyz.atnrch.nicko.wrapper.WrapperPlayerServerPlayerInfo;
|
||||
import xyz.atnrch.nicko.wrapper.WrapperPlayerServerPlayerInfoRemove;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
@ -157,14 +158,15 @@ public class AppearanceManager {
|
|||
|
||||
private void updateTabList(WrappedGameProfile gameProfile, String displayName) {
|
||||
final WrapperPlayerServerPlayerInfoRemove remove = new WrapperPlayerServerPlayerInfoRemove();
|
||||
remove.setUUIDs(ImmutableList.of(player.getUniqueId()));
|
||||
final WrapperPlayerServerPlayerInfo update = new WrapperPlayerServerPlayerInfo();
|
||||
update.setActions(EnumSet.of(EnumWrappers.PlayerInfoAction.ADD_PLAYER,
|
||||
final EnumSet<EnumWrappers.PlayerInfoAction> actions = EnumSet.of(
|
||||
EnumWrappers.PlayerInfoAction.REMOVE_PLAYER, // Necessary for 1.19.2 and below
|
||||
EnumWrappers.PlayerInfoAction.ADD_PLAYER,
|
||||
EnumWrappers.PlayerInfoAction.INITIALIZE_CHAT,
|
||||
EnumWrappers.PlayerInfoAction.UPDATE_LISTED,
|
||||
EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME,
|
||||
EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE,
|
||||
EnumWrappers.PlayerInfoAction.UPDATE_LATENCY));
|
||||
EnumWrappers.PlayerInfoAction.UPDATE_LATENCY);
|
||||
update.setData(ImmutableList.of(new PlayerInfoData(
|
||||
player.getUniqueId(),
|
||||
player.getPing(),
|
||||
|
@ -177,7 +179,12 @@ public class AppearanceManager {
|
|||
// No, I'll not waste another day fixing their mess. Go cry about it to Mojang.
|
||||
// (Long live NoEncryption!)
|
||||
)));
|
||||
remove.sendPacket(player);
|
||||
if (MinecraftVersion.FEATURE_PREVIEW_UPDATE.atOrAbove()) {
|
||||
actions.remove(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
|
||||
remove.setUUIDs(ImmutableList.of(player.getUniqueId()));
|
||||
remove.sendPacket(player);
|
||||
}
|
||||
update.setActions(actions);
|
||||
update.sendPacket(player);
|
||||
}
|
||||
}
|
|
@ -1,18 +1,17 @@
|
|||
package xyz.atnrch.nicko.event;
|
||||
|
||||
import xyz.atnrch.nicko.NickoBukkit;
|
||||
import xyz.atnrch.nicko.disguise.AppearanceManager;
|
||||
import xyz.atnrch.nicko.disguise.ActionResult;
|
||||
import xyz.atnrch.nicko.disguise.NickoProfile;
|
||||
import xyz.atnrch.nicko.i18n.I18N;
|
||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
import xyz.atnrch.nicko.storage.PlayerDataStore;
|
||||
import xyz.atnrch.nicko.storage.name.PlayerNameStore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import xyz.atnrch.nicko.NickoBukkit;
|
||||
import xyz.atnrch.nicko.disguise.ActionResult;
|
||||
import xyz.atnrch.nicko.disguise.AppearanceManager;
|
||||
import xyz.atnrch.nicko.i18n.I18N;
|
||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
import xyz.atnrch.nicko.storage.PlayerDataStore;
|
||||
import xyz.atnrch.nicko.storage.name.PlayerNameStore;
|
||||
|
||||
public class PlayerJoinListener implements Listener {
|
||||
@EventHandler
|
||||
|
@ -25,8 +24,6 @@ public class PlayerJoinListener implements Listener {
|
|||
nameStore.storeName(player);
|
||||
|
||||
// TODO: 2/20/23 BungeeCord transfer
|
||||
|
||||
dataStore.performProfileUpdate(player.getUniqueId(), NickoProfile.EMPTY_PROFILE);
|
||||
Bukkit.getScheduler().runTaskLater(instance, () -> {
|
||||
final AppearanceManager appearanceManager = AppearanceManager.get(player);
|
||||
if (appearanceManager.hasData()) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package xyz.atnrch.nicko.storage.cache;
|
||||
package xyz.atnrch.nicko.storage;
|
||||
|
||||
import xyz.atnrch.nicko.disguise.ActionResult;
|
||||
import xyz.atnrch.nicko.disguise.NickoProfile;
|
|
@ -1,4 +1,4 @@
|
|||
package xyz.atnrch.nicko.storage.cache;
|
||||
package xyz.atnrch.nicko.storage;
|
||||
|
||||
public interface CacheProvider {
|
||||
boolean init();
|
|
@ -1,19 +1,18 @@
|
|||
package xyz.atnrch.nicko.storage;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.atnrch.nicko.config.Configuration;
|
||||
import xyz.atnrch.nicko.disguise.ActionResult;
|
||||
import xyz.atnrch.nicko.disguise.NickoProfile;
|
||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
import xyz.atnrch.nicko.mojang.MojangAPI;
|
||||
import xyz.atnrch.nicko.mojang.MojangUtils;
|
||||
import xyz.atnrch.nicko.storage.cache.Cache;
|
||||
import xyz.atnrch.nicko.storage.cache.redis.RedisCache;
|
||||
import xyz.atnrch.nicko.storage.json.JSONStorage;
|
||||
import xyz.atnrch.nicko.storage.map.MapCache;
|
||||
import xyz.atnrch.nicko.storage.redis.RedisCache;
|
||||
import xyz.atnrch.nicko.storage.sql.SQLStorage;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -21,21 +20,11 @@ public class PlayerDataStore {
|
|||
private final Storage storage;
|
||||
private final Cache cache;
|
||||
private final MojangAPI mojangAPI;
|
||||
private final HashMap<UUID, NickoProfile> profiles = new HashMap<>();
|
||||
|
||||
public PlayerDataStore(MojangAPI mojangAPI, Configuration configuration) {
|
||||
this.mojangAPI = mojangAPI;
|
||||
this.storage = configuration.isLocal() ? new JSONStorage() : new SQLStorage(configuration);
|
||||
this.cache = new RedisCache(); // The only option for now!
|
||||
}
|
||||
|
||||
public void performProfileUpdate(UUID uuid, NickoProfile profile) {
|
||||
if (!profiles.containsKey(uuid)) {
|
||||
profiles.put(uuid, profile);
|
||||
return;
|
||||
}
|
||||
|
||||
profiles.replace(uuid, profile);
|
||||
this.storage = configuration.getSqlConfiguration().isEnabled() ? new SQLStorage(configuration) : new JSONStorage();
|
||||
this.cache = configuration.getRedisConfiguration().isEnabled() ? new RedisCache(configuration) : new MapCache();
|
||||
}
|
||||
|
||||
public Optional<NickoProfile> getData(UUID uuid) {
|
||||
|
@ -43,15 +32,15 @@ public class PlayerDataStore {
|
|||
return Optional.empty();
|
||||
}
|
||||
|
||||
if (profiles.containsKey(uuid)) {
|
||||
return Optional.of(profiles.get(uuid));
|
||||
if (cache.isCached(uuid)) {
|
||||
return cache.retrieve(uuid);
|
||||
} else if (storage.isStored(uuid)) {
|
||||
final Optional<NickoProfile> retrievedProfile = storage.retrieve(uuid);
|
||||
retrievedProfile.ifPresent(profile -> profiles.put(uuid, profile));
|
||||
retrievedProfile.ifPresent(profile -> cache.cache(uuid, profile));
|
||||
return retrievedProfile;
|
||||
} else {
|
||||
final NickoProfile newProfile = NickoProfile.EMPTY_PROFILE.clone();
|
||||
profiles.put(uuid, newProfile);
|
||||
cache.cache(uuid, newProfile);
|
||||
return Optional.of(newProfile);
|
||||
}
|
||||
}
|
||||
|
@ -74,12 +63,14 @@ public class PlayerDataStore {
|
|||
}
|
||||
|
||||
public ActionResult<Void> saveData(Player player) {
|
||||
if (storage.isError()) { return new ActionResult<>(I18NDict.Error.UNEXPECTED_ERROR); }
|
||||
if (!profiles.containsKey(player.getUniqueId())) { return new ActionResult<>(I18NDict.Error.UNEXPECTED_ERROR); }
|
||||
if (storage.isError()) return new ActionResult<>(I18NDict.Error.UNEXPECTED_ERROR);
|
||||
if (!cache.isCached(player.getUniqueId())) return new ActionResult<>(I18NDict.Error.UNEXPECTED_ERROR);
|
||||
if (!cache.retrieve(player.getUniqueId()).isPresent())
|
||||
return new ActionResult<>(I18NDict.Error.UNEXPECTED_ERROR);
|
||||
|
||||
final ActionResult<Void> store = storage.store(player.getUniqueId(), profiles.get(player.getUniqueId()));
|
||||
profiles.remove(player.getUniqueId());
|
||||
return store;
|
||||
// TODO (Ineanto, 5/20/23): Remove value from cache
|
||||
//profiles.remove(player.getUniqueId());
|
||||
return storage.store(player.getUniqueId(), cache.retrieve(player.getUniqueId()).get());
|
||||
}
|
||||
|
||||
public Storage getStorage() {
|
||||
|
|
44
src/main/java/xyz/atnrch/nicko/storage/map/MapCache.java
Normal file
44
src/main/java/xyz/atnrch/nicko/storage/map/MapCache.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package xyz.atnrch.nicko.storage.map;
|
||||
|
||||
import xyz.atnrch.nicko.disguise.ActionResult;
|
||||
import xyz.atnrch.nicko.disguise.NickoProfile;
|
||||
import xyz.atnrch.nicko.storage.Cache;
|
||||
import xyz.atnrch.nicko.storage.CacheProvider;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MapCache extends Cache {
|
||||
private MapCacheProvider provider;
|
||||
|
||||
@Override
|
||||
public CacheProvider getProvider() {
|
||||
if (provider == null) {
|
||||
provider = new MapCacheProvider();
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<Void> cache(UUID uuid, NickoProfile profile) {
|
||||
final HashMap<UUID, NickoProfile> profiles = provider.getMap();
|
||||
profiles.put(uuid, profile);
|
||||
return new ActionResult<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCached(UUID uuid) {
|
||||
final HashMap<UUID, NickoProfile> profiles = provider.getMap();
|
||||
return profiles.containsKey(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<NickoProfile> retrieve(UUID uuid) {
|
||||
final HashMap<UUID, NickoProfile> profiles = provider.getMap();
|
||||
if (isCached(uuid)) {
|
||||
return Optional.of(profiles.get(uuid));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package xyz.atnrch.nicko.storage.map;
|
||||
|
||||
import xyz.atnrch.nicko.disguise.NickoProfile;
|
||||
import xyz.atnrch.nicko.storage.CacheProvider;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MapCacheProvider implements CacheProvider {
|
||||
private HashMap<UUID, NickoProfile> profiles;
|
||||
|
||||
@Override
|
||||
public boolean init() {
|
||||
if (profiles == null) {
|
||||
profiles = new HashMap<>();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean close() {
|
||||
profiles = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
public HashMap<UUID, NickoProfile> getMap() {
|
||||
return profiles;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package xyz.atnrch.nicko.storage.cache.redis;
|
||||
package xyz.atnrch.nicko.storage.redis;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
@ -6,8 +6,8 @@ import redis.clients.jedis.Jedis;
|
|||
import xyz.atnrch.nicko.config.Configuration;
|
||||
import xyz.atnrch.nicko.disguise.ActionResult;
|
||||
import xyz.atnrch.nicko.disguise.NickoProfile;
|
||||
import xyz.atnrch.nicko.storage.cache.Cache;
|
||||
import xyz.atnrch.nicko.storage.cache.CacheProvider;
|
||||
import xyz.atnrch.nicko.storage.Cache;
|
||||
import xyz.atnrch.nicko.storage.CacheProvider;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
|
@ -1,7 +1,7 @@
|
|||
package xyz.atnrch.nicko.storage.cache.redis;
|
||||
package xyz.atnrch.nicko.storage.redis;
|
||||
|
||||
import xyz.atnrch.nicko.config.Configuration;
|
||||
import xyz.atnrch.nicko.storage.cache.CacheProvider;
|
||||
import xyz.atnrch.nicko.storage.CacheProvider;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
|
@ -40,7 +40,6 @@ public class WrapperPlayerServerPlayerInfo extends AbstractPacket {
|
|||
}
|
||||
|
||||
public void setData(List<PlayerInfoData> value) {
|
||||
//handle.getSets(PlayerInfoData.getConverter()).write(0, value);
|
||||
handle.getPlayerInfoDataLists().write(1, value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,29 @@
|
|||
# Nicko ${project.version} - Config:
|
||||
|
||||
############
|
||||
# LANGUAGE #
|
||||
############
|
||||
|
||||
# Nicko's messages prefix.
|
||||
# Accepted values: any string
|
||||
prefix: "§6Nicko §8§l| §r"
|
||||
|
||||
# Nicko will copy the English locale as "lang.yml"
|
||||
# and will use the translations in that file when "Server Custom"
|
||||
# is selected as the player's locale.
|
||||
# Accepted values: false (Disabled), true (Enabled)
|
||||
customLocale: false
|
||||
|
||||
###########
|
||||
# STORAGE #
|
||||
###########
|
||||
|
||||
# Indicates wherever the data will be stored
|
||||
# locally through a .json file or a (My)SQL database.
|
||||
# Accepted values: false (Disabled), true (Enabled)
|
||||
local: true
|
||||
|
||||
# This configuration section manages SQL.
|
||||
sql:
|
||||
# Indicates wherever the data will be stored locally
|
||||
# inside a .json file or in a SQL database.
|
||||
# Accepted values: false (Disabled), true (Enabled)
|
||||
enabled: false
|
||||
# SQL database's address
|
||||
# Accepted values: valid IP address (e.g. localhost, 127.0.0.1)
|
||||
address: "localhost"
|
||||
|
@ -42,18 +55,4 @@ redis:
|
|||
username: "username"
|
||||
# Redis server's password
|
||||
# Accepted values: any string
|
||||
password: "password"
|
||||
|
||||
###########
|
||||
# DISPLAY #
|
||||
###########
|
||||
|
||||
# Nicko's messages prefix.
|
||||
# Accepted values: any string
|
||||
prefix: "§6Nicko §8§l| §r"
|
||||
|
||||
# Nicko will copy the English locale as "lang.yml"
|
||||
# and will use the translations in that file when "Server Custom"
|
||||
# is selected as the player's locale.
|
||||
# Accepted values: false (Disabled), true (Enabled)
|
||||
customLocale: false
|
||||
password: "password"
|
|
@ -14,10 +14,9 @@ public class NickoPluginTest {
|
|||
@BeforeAll
|
||||
public static void setup() {
|
||||
final Configuration config = new Configuration(
|
||||
DataSourceConfiguration.SQL_EMPTY,
|
||||
new DataSourceConfiguration(true, "127.0.0.1", 3306, "root", "12345"),
|
||||
DataSourceConfiguration.REDIS_EMPTY,
|
||||
"",
|
||||
true,
|
||||
false);
|
||||
MockBukkit.mock();
|
||||
plugin = MockBukkit.load(NickoBukkit.class, config);
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package xyz.atnrch.nicko.test.config;
|
||||
|
||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||
import xyz.atnrch.nicko.NickoBukkit;
|
||||
import xyz.atnrch.nicko.config.Configuration;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import xyz.atnrch.nicko.NickoBukkit;
|
||||
import xyz.atnrch.nicko.config.Configuration;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
public class ConfigurationTest {
|
||||
private static NickoBukkit plugin;
|
||||
|
@ -23,7 +23,8 @@ public class ConfigurationTest {
|
|||
@DisplayName("Read configuration")
|
||||
public void readConfiguration() {
|
||||
final Configuration configuration = plugin.getNickoConfig();
|
||||
assertTrue(configuration.isLocal());
|
||||
assertFalse(configuration.getSqlConfiguration().isEnabled());
|
||||
assertFalse(configuration.getRedisConfiguration().isEnabled());
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
|
|
|
@ -23,10 +23,9 @@ public class BrokenSQLTest {
|
|||
@BeforeAll
|
||||
public static void setup() {
|
||||
final Configuration config = new Configuration(
|
||||
DataSourceConfiguration.SQL_EMPTY,
|
||||
new DataSourceConfiguration(true, "127.0.0.1", 3306, "root", ""),
|
||||
DataSourceConfiguration.REDIS_EMPTY,
|
||||
"",
|
||||
false,
|
||||
false);
|
||||
server = MockBukkit.mock();
|
||||
plugin = MockBukkit.load(NickoBukkit.class, config);
|
||||
|
|
|
@ -25,10 +25,9 @@ public class SQLStorageTest {
|
|||
@BeforeAll
|
||||
public static void setup() {
|
||||
final Configuration config = new Configuration(
|
||||
new DataSourceConfiguration("127.0.0.1", 3306, "root", "12345"),
|
||||
new DataSourceConfiguration(true, "127.0.0.1", 3306, "root", "12345"),
|
||||
DataSourceConfiguration.REDIS_EMPTY,
|
||||
"",
|
||||
false,
|
||||
false);
|
||||
server = MockBukkit.mock();
|
||||
plugin = MockBukkit.load(NickoBukkit.class, config);
|
||||
|
|
|
@ -24,10 +24,9 @@ public class CacheStorageTest {
|
|||
@BeforeAll
|
||||
public static void setup() {
|
||||
final Configuration config = new Configuration(
|
||||
new DataSourceConfiguration("127.0.0.1", 3306, "root", "12345"),
|
||||
new DataSourceConfiguration(false, "127.0.0.1", 3306, "root", "12345"),
|
||||
DataSourceConfiguration.REDIS_EMPTY,
|
||||
"",
|
||||
false,
|
||||
false);
|
||||
server = MockBukkit.mock();
|
||||
plugin = MockBukkit.load(NickoBukkit.class, config);
|
||||
|
@ -39,7 +38,7 @@ public class CacheStorageTest {
|
|||
public void cachePlayerData() {
|
||||
final Optional<NickoProfile> optionalProfile = plugin.getDataStore().getData(player.getUniqueId());
|
||||
assertTrue(optionalProfile.isPresent());
|
||||
//assertTrue(plugin.getDataStore().isCached(player.getUniqueId()));
|
||||
assertTrue(plugin.getDataStore().getCache().isCached(player.getUniqueId()));
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
|
|
Loading…
Reference in a new issue