feat: streamline profile class
This commit is contained in:
parent
b81eac497a
commit
618af08024
11 changed files with 75 additions and 86 deletions
|
@ -11,7 +11,6 @@ import xyz.atnrch.nicko.appearance.AppearanceManager;
|
|||
import xyz.atnrch.nicko.i18n.I18N;
|
||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
import xyz.atnrch.nicko.mojang.MojangUtils;
|
||||
import xyz.atnrch.nicko.profile.AppearanceData;
|
||||
import xyz.atnrch.nicko.profile.NickoProfile;
|
||||
import xyz.atnrch.nicko.storage.PlayerDataStore;
|
||||
|
||||
|
@ -22,7 +21,6 @@ import java.util.Optional;
|
|||
public class AnvilManager {
|
||||
private final Player player;
|
||||
private final AppearanceManager appearanceManager;
|
||||
private final AppearanceData appearanceData;
|
||||
private final PlayerDataStore dataStore = NickoBukkit.getInstance().getDataStore();
|
||||
private final NickoProfile profile;
|
||||
|
||||
|
@ -31,8 +29,7 @@ public class AnvilManager {
|
|||
|
||||
final Optional<NickoProfile> optionalProfile = dataStore.getData(player.getUniqueId());
|
||||
this.profile = optionalProfile.orElse(NickoProfile.EMPTY_PROFILE.clone());
|
||||
this.appearanceManager = optionalProfile.map(NickoProfile::getAppearanceManager).orElse(null);
|
||||
this.appearanceData = optionalProfile.map(NickoProfile::getAppearanceData).orElse(null);
|
||||
this.appearanceManager = new AppearanceManager(player);
|
||||
}
|
||||
|
||||
public void openNameThenSkinAnvil() {
|
||||
|
@ -57,7 +54,7 @@ public class AnvilManager {
|
|||
if (MojangUtils.isUsernameInvalid(snapshot.getText())) {
|
||||
return Collections.singletonList(AnvilGUI.ResponseAction.replaceInputText("Invalid username!"));
|
||||
} else {
|
||||
appearanceData.setName(snapshot.getText());
|
||||
profile.setName(snapshot.getText());
|
||||
dataStore.updateCache(player.getUniqueId(), profile);
|
||||
openSkinAnvil();
|
||||
return Collections.singletonList(AnvilGUI.ResponseAction.close());
|
||||
|
@ -78,7 +75,7 @@ public class AnvilManager {
|
|||
if (MojangUtils.isUsernameInvalid(snapshot.getText())) {
|
||||
return Collections.singletonList(AnvilGUI.ResponseAction.replaceInputText("Invalid username!"));
|
||||
} else {
|
||||
appearanceData.setName(snapshot.getText());
|
||||
profile.setName(snapshot.getText());
|
||||
dataStore.updateCache(player.getUniqueId(), profile);
|
||||
final ActionResult actionResult = appearanceManager.updatePlayer(false, false);
|
||||
return sendResultAndClose(actionResult);
|
||||
|
@ -99,7 +96,7 @@ public class AnvilManager {
|
|||
if (MojangUtils.isUsernameInvalid(snapshot.getText())) {
|
||||
return Collections.singletonList(AnvilGUI.ResponseAction.replaceInputText("Invalid username!"));
|
||||
} else {
|
||||
appearanceData.setSkin(snapshot.getText());
|
||||
profile.setSkin(snapshot.getText());
|
||||
dataStore.updateCache(player.getUniqueId(), profile);
|
||||
final ActionResult actionResult = appearanceManager.updatePlayer(true, false);
|
||||
return sendResultAndClose(actionResult);
|
||||
|
|
|
@ -13,7 +13,6 @@ import xyz.atnrch.nicko.NickoBukkit;
|
|||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
import xyz.atnrch.nicko.mojang.MojangAPI;
|
||||
import xyz.atnrch.nicko.mojang.MojangSkin;
|
||||
import xyz.atnrch.nicko.profile.AppearanceData;
|
||||
import xyz.atnrch.nicko.profile.NickoProfile;
|
||||
import xyz.atnrch.nicko.storage.PlayerDataStore;
|
||||
import xyz.atnrch.nicko.storage.name.PlayerNameStore;
|
||||
|
@ -31,7 +30,6 @@ public class AppearanceManager {
|
|||
private final PlayerNameStore nameStore = instance.getNameStore();
|
||||
|
||||
private final NickoProfile profile;
|
||||
private final AppearanceData appearanceData;
|
||||
private final Player player;
|
||||
private final UUID uuid;
|
||||
|
||||
|
@ -40,31 +38,27 @@ public class AppearanceManager {
|
|||
this.player = player;
|
||||
|
||||
final Optional<NickoProfile> optionalProfile = dataStore.getData(player.getUniqueId());
|
||||
this.profile = optionalProfile.orElse(NickoProfile.EMPTY_PROFILE.clone());
|
||||
if (!optionalProfile.isPresent()) {
|
||||
this.profile = NickoProfile.EMPTY_PROFILE.clone();
|
||||
this.appearanceData = profile.getAppearanceData();
|
||||
instance.getLogger().warning("Unable to appearance data for: " + player.getUniqueId() + ".");
|
||||
} else {
|
||||
this.profile = optionalProfile.get();
|
||||
this.appearanceData = profile.getAppearanceData();
|
||||
}
|
||||
}
|
||||
|
||||
public ActionResult reset() {
|
||||
final String defaultName = nameStore.getStoredName(player);
|
||||
appearanceData.setName(defaultName);
|
||||
appearanceData.setSkin(defaultName);
|
||||
profile.setName(defaultName);
|
||||
profile.setSkin(defaultName);
|
||||
final ActionResult actionResult = updatePlayer(true, true);
|
||||
if (!actionResult.isError()) {
|
||||
appearanceData.setSkin(null);
|
||||
appearanceData.setName(null);
|
||||
profile.setSkin(null);
|
||||
profile.setName(null);
|
||||
dataStore.getCache().cache(uuid, profile);
|
||||
}
|
||||
return actionResult;
|
||||
}
|
||||
|
||||
public ActionResult updatePlayer(boolean skinChange, boolean reset) {
|
||||
final String displayName = appearanceData.getName() == null ? player.getName() : appearanceData.getName();
|
||||
final String displayName = profile.getName() == null ? player.getName() : profile.getName();
|
||||
final WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(player).withName(displayName);
|
||||
final ActionResult result = updateGameProfileSkin(gameProfile, skinChange, reset);
|
||||
if (!result.isError()) {
|
||||
|
@ -91,13 +85,13 @@ public class AppearanceManager {
|
|||
|
||||
|
||||
private ActionResult updateGameProfileSkin(WrappedGameProfile gameProfile, boolean skinChange, boolean reset) {
|
||||
final boolean changeOnlyName = appearanceData.getSkin() != null && !appearanceData.getSkin().equalsIgnoreCase(player.getName());
|
||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
||||
|
||||
if (skinChange || changeOnlyName) {
|
||||
Optional<MojangSkin> skin;
|
||||
try {
|
||||
final MojangAPI mojangAPI = NickoBukkit.getInstance().getMojangAPI();
|
||||
final Optional<String> uuid = mojangAPI.getUUID(appearanceData.getSkin());
|
||||
final Optional<String> uuid = mojangAPI.getUUID(profile.getSkin());
|
||||
if (uuid.isPresent()) {
|
||||
skin = reset ? mojangAPI.getSkinWithoutCaching(uuid.get()) : mojangAPI.getSkin(uuid.get());
|
||||
if (skin.isPresent()) {
|
||||
|
|
|
@ -57,10 +57,9 @@ public class NickoDebugCmd {
|
|||
if (optionalProfile.isPresent()) {
|
||||
final NickoProfile profile = optionalProfile.get();
|
||||
final PlayerDataStore dataStore = NickoBukkit.getInstance().getDataStore();
|
||||
final AppearanceData appearanceData = profile.getAppearanceData();
|
||||
final AppearanceManager appearanceManager = profile.getAppearanceManager();
|
||||
appearanceData.setName(name);
|
||||
appearanceData.setSkin(skin);
|
||||
final AppearanceManager appearanceManager = new AppearanceManager(target);
|
||||
profile.setName(name);
|
||||
profile.setSkin(skin);
|
||||
dataStore.updateCache(target.getUniqueId(), profile);
|
||||
final ActionResult result = appearanceManager.updatePlayer(true, false);
|
||||
if (!result.isError()) {
|
||||
|
@ -71,7 +70,5 @@ public class NickoDebugCmd {
|
|||
target.sendMessage(prefix + "§cWhoops. Something happened: " + i18n.translatePrefixless(result.getErrorKey()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ public class PlayerJoinListener implements Listener {
|
|||
Bukkit.getScheduler().runTaskLater(instance, () -> {
|
||||
final Optional<NickoProfile> optionalProfile = dataStore.getData(player.getUniqueId());
|
||||
|
||||
optionalProfile.map(NickoProfile::getAppearanceData).ifPresent(appearanceData -> {
|
||||
final AppearanceManager appearanceManager = new AppearanceManager(player);
|
||||
if (!appearanceData.isEmpty()) {
|
||||
final boolean needsASkinChange = appearanceData.getSkin() != null && !appearanceData.getSkin().equals(player.getName());
|
||||
optionalProfile.ifPresent(profile -> {
|
||||
if (profile.hasData()) {
|
||||
final AppearanceManager appearanceManager = new AppearanceManager(player);
|
||||
final boolean needsASkinChange = profile.getSkin() != null && !profile.getSkin().equals(player.getName());
|
||||
final ActionResult actionResult = appearanceManager.updatePlayer(needsASkinChange, false);
|
||||
if (!actionResult.isError()) {
|
||||
player.sendMessage(i18n.translate(I18NDict.Event.Appearance.Restore.OK));
|
||||
|
|
|
@ -4,8 +4,6 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.atnrch.nicko.NickoBukkit;
|
||||
import xyz.atnrch.nicko.mojang.MojangAPI;
|
||||
import xyz.atnrch.nicko.profile.AppearanceData;
|
||||
import xyz.atnrch.nicko.profile.NickoProfile;
|
||||
import xyz.atnrch.nicko.storage.PlayerDataStore;
|
||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||
|
@ -16,8 +14,6 @@ import java.util.Optional;
|
|||
import java.util.UUID;
|
||||
|
||||
public class PlayerInformationItem extends AsyncItem {
|
||||
private final MojangAPI mojangAPI = NickoBukkit.getInstance().getMojangAPI();
|
||||
|
||||
public PlayerInformationItem(UUID uuid) {
|
||||
super(new ItemBuilder(Material.PAINTING).setDisplayName("§7§oLoading..."), () -> {
|
||||
final Player player = Bukkit.getPlayer(uuid);
|
||||
|
@ -26,12 +22,11 @@ public class PlayerInformationItem extends AsyncItem {
|
|||
final Optional<NickoProfile> optionalProfile = dataStore.getData(uuid);
|
||||
|
||||
optionalProfile.ifPresent(profile -> {
|
||||
final AppearanceData appearanceData = profile.getAppearanceData();
|
||||
if (!appearanceData.isEmpty()) {
|
||||
if (!profile.hasData()) {
|
||||
skull.addLoreLines(
|
||||
"§cNicked: §a✔",
|
||||
"§cName: §6" + appearanceData.getName(),
|
||||
"§cSkin: §6" + appearanceData.getSkin()
|
||||
"§cName: §6" + profile.getName(),
|
||||
"§cSkin: §6" + profile.getSkin()
|
||||
);
|
||||
} else {
|
||||
skull.addLoreLines(
|
||||
|
|
|
@ -3,6 +3,7 @@ package xyz.atnrch.nicko.gui.items.home;
|
|||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import xyz.atnrch.nicko.appearance.AppearanceManager;
|
||||
import xyz.atnrch.nicko.i18n.I18N;
|
||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
import xyz.atnrch.nicko.profile.NickoProfile;
|
||||
|
@ -28,13 +29,15 @@ public class ResetItem extends SuppliedItem {
|
|||
final Optional<NickoProfile> optionalProfile = NickoProfile.get(player);
|
||||
final AtomicBoolean result = new AtomicBoolean(false);
|
||||
optionalProfile.ifPresent(profile -> {
|
||||
if (profile.getAppearanceData().isEmpty()) {
|
||||
if (!profile.hasData()) {
|
||||
player.sendMessage(i18n.translate(I18NDict.Event.Appearance.Remove.MISSING));
|
||||
event.getEvent().getView().close();
|
||||
result.set(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!profile.getAppearanceManager().reset().isError()) {
|
||||
final AppearanceManager appearanceManager = new AppearanceManager(player);
|
||||
if (!appearanceManager.reset().isError()) {
|
||||
player.sendMessage(i18n.translate(I18NDict.Event.Appearance.Remove.OK));
|
||||
result.set(false);
|
||||
} else {
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import xyz.atnrch.nicko.NickoBukkit;
|
||||
import xyz.atnrch.nicko.profile.AppearanceData;
|
||||
import xyz.atnrch.nicko.profile.NickoProfile;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -52,10 +51,9 @@ public class NickoExpansion extends PlaceholderExpansion {
|
|||
final Optional<NickoProfile> optionalProfile = instance.getDataStore().getData(player.getUniqueId());
|
||||
if (optionalProfile.isPresent()) {
|
||||
final NickoProfile profile = optionalProfile.get();
|
||||
final AppearanceData appearanceData = profile.getAppearanceData();
|
||||
if (!appearanceData.isEmpty()) {
|
||||
name = appearanceData.getName();
|
||||
skin = appearanceData.getSkin();
|
||||
if (!profile.hasData()) {
|
||||
name = profile.getName();
|
||||
skin = profile.getSkin();
|
||||
}
|
||||
locale = profile.getLocale().getName();
|
||||
bungeecord = profile.isBungeecordTransfer();
|
||||
|
|
|
@ -3,7 +3,6 @@ package xyz.atnrch.nicko.profile;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.atnrch.nicko.NickoBukkit;
|
||||
import xyz.atnrch.nicko.appearance.AppearanceManager;
|
||||
import xyz.atnrch.nicko.i18n.Locale;
|
||||
import xyz.atnrch.nicko.storage.PlayerDataStore;
|
||||
|
||||
|
@ -12,29 +11,34 @@ import java.util.UUID;
|
|||
|
||||
public class NickoProfile implements Cloneable {
|
||||
public static final PlayerDataStore dataStore = NickoBukkit.getInstance().getDataStore();
|
||||
public static final NickoProfile EMPTY_PROFILE = new NickoProfile(new AppearanceData(null, null), Locale.ENGLISH, true);
|
||||
public static final NickoProfile EMPTY_PROFILE = new NickoProfile(null, null, Locale.ENGLISH, true);
|
||||
|
||||
private final AppearanceData appearanceData;
|
||||
private final Player player;
|
||||
private transient final Player player;
|
||||
|
||||
private String name;
|
||||
private String skin;
|
||||
private Locale locale;
|
||||
private boolean bungeecordTransfer;
|
||||
|
||||
public NickoProfile(AppearanceData appearanceData, Locale locale, boolean bungeecordTransfer) {
|
||||
this.appearanceData = appearanceData;
|
||||
public NickoProfile(String name, String skin, Locale locale, boolean bungeecordTransfer) {
|
||||
this.name = name;
|
||||
this.skin = skin;
|
||||
this.locale = locale;
|
||||
this.bungeecordTransfer = bungeecordTransfer;
|
||||
this.player = null;
|
||||
}
|
||||
|
||||
public NickoProfile(Player player, AppearanceData appearanceData, Locale locale, boolean bungeecordTransfer) {
|
||||
public NickoProfile(Player player, String name, String skin, Locale locale, boolean bungeecordTransfer) {
|
||||
this.player = player;
|
||||
this.appearanceData = appearanceData;
|
||||
this.name = name;
|
||||
this.skin = skin;
|
||||
this.locale = locale;
|
||||
this.bungeecordTransfer = bungeecordTransfer;
|
||||
}
|
||||
|
||||
public NickoProfile(UUID uuid, AppearanceData appearanceData, Locale locale, boolean bungeecordTransfer) {
|
||||
this.appearanceData = appearanceData;
|
||||
public NickoProfile(UUID uuid, String name, String skin, Locale locale, boolean bungeecordTransfer) {
|
||||
this.name = name;
|
||||
this.skin = skin;
|
||||
this.locale = locale;
|
||||
this.bungeecordTransfer = bungeecordTransfer;
|
||||
this.player = Bukkit.getPlayer(uuid);
|
||||
|
@ -48,13 +52,24 @@ public class NickoProfile implements Cloneable {
|
|||
return dataStore.getData(uuid);
|
||||
}
|
||||
|
||||
public AppearanceManager getAppearanceManager() {
|
||||
if (player == null) return null;
|
||||
return new AppearanceManager(player);
|
||||
public boolean hasData() {
|
||||
return name != null || skin != null;
|
||||
}
|
||||
|
||||
public AppearanceData getAppearanceData() {
|
||||
return appearanceData;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSkin() {
|
||||
return skin;
|
||||
}
|
||||
|
||||
public void setSkin(String skin) {
|
||||
this.skin = skin;
|
||||
}
|
||||
|
||||
public Locale getLocale() {
|
||||
|
@ -65,7 +80,6 @@ public class NickoProfile implements Cloneable {
|
|||
this.locale = locale;
|
||||
}
|
||||
|
||||
|
||||
public boolean isBungeecordTransfer() {
|
||||
return bungeecordTransfer;
|
||||
}
|
||||
|
@ -77,8 +91,8 @@ public class NickoProfile implements Cloneable {
|
|||
@Override
|
||||
public String toString() {
|
||||
return "NickoProfile{" +
|
||||
"name='" + appearanceData.getName() + '\'' +
|
||||
", skin='" + appearanceData.getSkin() + '\'' +
|
||||
"name='" + name + '\'' +
|
||||
", skin='" + skin + '\'' +
|
||||
", locale=" + locale +
|
||||
", bungeecordTransfer=" + bungeecordTransfer +
|
||||
'}';
|
||||
|
|
|
@ -4,7 +4,6 @@ import xyz.atnrch.nicko.appearance.ActionResult;
|
|||
import xyz.atnrch.nicko.config.Configuration;
|
||||
import xyz.atnrch.nicko.i18n.I18NDict;
|
||||
import xyz.atnrch.nicko.i18n.Locale;
|
||||
import xyz.atnrch.nicko.profile.AppearanceData;
|
||||
import xyz.atnrch.nicko.profile.NickoProfile;
|
||||
import xyz.atnrch.nicko.storage.Storage;
|
||||
|
||||
|
@ -93,7 +92,7 @@ public class SQLStorage extends Storage {
|
|||
bungeecord = resultSet.getBoolean("bungeecord");
|
||||
}
|
||||
|
||||
final NickoProfile profile = new NickoProfile(new AppearanceData(name, skin), Locale.fromCode(locale), bungeecord);
|
||||
final NickoProfile profile = new NickoProfile(name, skin, Locale.fromCode(locale), bungeecord);
|
||||
return Optional.of(profile);
|
||||
} catch (SQLException e) {
|
||||
logger.warning("Couldn't fetch profile: " + e.getMessage());
|
||||
|
@ -121,10 +120,9 @@ public class SQLStorage extends Storage {
|
|||
private PreparedStatement getInsertStatement(Connection connection, UUID uuid, NickoProfile profile) throws SQLException {
|
||||
final String sql = "INSERT IGNORE INTO nicko.DATA (`uuid`, `name`, `skin`, `locale`, `bungeecord`) VALUES (?, ?, ?, ?, ?)";
|
||||
final PreparedStatement statement = connection.prepareStatement(sql);
|
||||
final AppearanceData appearanceData = profile.getAppearanceData();
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, appearanceData.getName() == null ? null : appearanceData.getName());
|
||||
statement.setString(3, appearanceData.getSkin() == null ? null : appearanceData.getSkin());
|
||||
statement.setString(2, profile.getName() == null ? null : profile.getName());
|
||||
statement.setString(3, profile.getSkin() == null ? null : profile.getSkin());
|
||||
statement.setString(4, profile.getLocale().getCode());
|
||||
statement.setBoolean(5, profile.isBungeecordTransfer());
|
||||
return statement;
|
||||
|
@ -133,9 +131,8 @@ public class SQLStorage extends Storage {
|
|||
private PreparedStatement getUpdateStatement(Connection connection, UUID uuid, NickoProfile profile) throws SQLException {
|
||||
final String sql = "UPDATE nicko.DATA SET name = ?, skin = ?, locale = ?, bungeecord = ? WHERE uuid = ?";
|
||||
final PreparedStatement statement = connection.prepareStatement(sql);
|
||||
final AppearanceData appearanceData = profile.getAppearanceData();
|
||||
statement.setString(1, appearanceData.getName() == null ? null : appearanceData.getName());
|
||||
statement.setString(2, appearanceData.getSkin() == null ? null : appearanceData.getSkin());
|
||||
statement.setString(1, profile.getName() == null ? null : profile.getName());
|
||||
statement.setString(2, profile.getSkin() == null ? null : profile.getSkin());
|
||||
statement.setString(3, profile.getLocale().getCode());
|
||||
statement.setBoolean(4, profile.isBungeecordTransfer());
|
||||
statement.setString(5, uuid.toString());
|
||||
|
|
|
@ -7,7 +7,6 @@ import xyz.atnrch.nicko.appearance.ActionResult;
|
|||
import xyz.atnrch.nicko.config.Configuration;
|
||||
import xyz.atnrch.nicko.config.DataSourceConfiguration;
|
||||
import xyz.atnrch.nicko.i18n.Locale;
|
||||
import xyz.atnrch.nicko.profile.AppearanceData;
|
||||
import xyz.atnrch.nicko.profile.NickoProfile;
|
||||
import xyz.atnrch.nicko.storage.PlayerDataStore;
|
||||
|
||||
|
@ -59,14 +58,13 @@ public class SQLStorageTest {
|
|||
assertTrue(optionalProfile.isPresent());
|
||||
|
||||
final NickoProfile profile = optionalProfile.get();
|
||||
final AppearanceData appearanceData = profile.getAppearanceData();
|
||||
assertNull(appearanceData.getName());
|
||||
assertNull(appearanceData.getSkin());
|
||||
assertNull(profile.getName());
|
||||
assertNull(profile.getSkin());
|
||||
assertEquals(profile.getLocale(), Locale.ENGLISH);
|
||||
assertTrue(profile.isBungeecordTransfer());
|
||||
|
||||
appearanceData.setName("Notch");
|
||||
appearanceData.setSkin("Notch");
|
||||
profile.setName("Notch");
|
||||
profile.setSkin("Notch");
|
||||
profile.setLocale(Locale.FRENCH);
|
||||
profile.setBungeecordTransfer(false);
|
||||
|
||||
|
@ -82,9 +80,8 @@ public class SQLStorageTest {
|
|||
assertTrue(optionalProfile.isPresent());
|
||||
|
||||
final NickoProfile updatedProfile = optionalProfile.get();
|
||||
final AppearanceData appearanceData = updatedProfile.getAppearanceData();
|
||||
assertEquals(appearanceData.getName(), "Notch");
|
||||
assertEquals(appearanceData.getSkin(), "Notch");
|
||||
assertEquals(updatedProfile.getName(), "Notch");
|
||||
assertEquals(updatedProfile.getSkin(), "Notch");
|
||||
assertEquals(updatedProfile.getLocale(), Locale.FRENCH);
|
||||
assertFalse(updatedProfile.isBungeecordTransfer());
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import xyz.atnrch.nicko.NickoBukkit;
|
|||
import xyz.atnrch.nicko.appearance.ActionResult;
|
||||
import xyz.atnrch.nicko.config.Configuration;
|
||||
import xyz.atnrch.nicko.config.DataSourceConfiguration;
|
||||
import xyz.atnrch.nicko.profile.AppearanceData;
|
||||
import xyz.atnrch.nicko.profile.NickoProfile;
|
||||
import xyz.atnrch.nicko.storage.PlayerDataStore;
|
||||
|
||||
|
@ -51,15 +50,13 @@ public class RedisCacheTest {
|
|||
|
||||
final NickoProfile profile = optionalProfile.get();
|
||||
final PlayerDataStore dataStore = plugin.getDataStore();
|
||||
final AppearanceData appearanceData = profile.getAppearanceData();
|
||||
appearanceData.setName("Notch");
|
||||
profile.setName("Notch");
|
||||
dataStore.updateCache(player.getUniqueId(), profile);
|
||||
|
||||
final Optional<NickoProfile> retrieve = dataStore.getCache().retrieve(player.getUniqueId());
|
||||
assertTrue(retrieve.isPresent());
|
||||
final NickoProfile retrieved = retrieve.get();
|
||||
final AppearanceData retrievedAppearanceData = retrieved.getAppearanceData();
|
||||
assertEquals(retrievedAppearanceData.getName(), "Notch");
|
||||
assertEquals(retrieved.getName(), "Notch");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in a new issue