Search in sources :

Example 1 with Profile

use of com.github.games647.craftapi.model.Profile in project CraftAPI by games647.

the class MemoryCacheTest method maxSizeProfile.

@Test
public void maxSizeProfile() throws Exception {
    assertThat(cache.getCachedProfiles().size(), is(0));
    cache.add(new Profile(UUID.randomUUID(), "1"));
    cache.add(new Profile(UUID.randomUUID(), "2"));
    assertThat(cache.getCachedProfiles().size(), is(1));
}
Also used : Profile(com.github.games647.craftapi.model.Profile) SkinPropertyTest(com.github.games647.craftapi.model.skin.SkinPropertyTest) Test(org.junit.Test)

Example 2 with Profile

use of com.github.games647.craftapi.model.Profile in project CraftAPI by games647.

the class MemoryCacheTest method addProfile.

@Test
public void addProfile() throws Exception {
    Profile profile = new Profile(UUID.randomUUID(), "abc");
    assertThat(cache.getById(profile.getId()).isPresent(), is(false));
    cache.add(profile);
    assertThat(cache.getById(profile.getId()).get(), is(profile));
}
Also used : Profile(com.github.games647.craftapi.model.Profile) SkinPropertyTest(com.github.games647.craftapi.model.skin.SkinPropertyTest) Test(org.junit.Test)

Example 3 with Profile

use of com.github.games647.craftapi.model.Profile in project CraftAPI by games647.

the class MemoryCacheTest method clear.

@Test
public void clear() throws Exception {
    Profile profile = new Profile(UUID.randomUUID(), "123ABC_abc");
    cache.add(profile);
    SkinProperty property = new SkinProperty(SkinPropertyTest.STEVE_VALUE, SkinPropertyTest.STEVE_SIGNATURE);
    cache.addSkin(profile.getId(), property);
    cache.clear();
    assertThat(cache.getByName(profile.getName()).isPresent(), is(false));
    assertThat(cache.getById(profile.getId()).isPresent(), is(false));
    assertThat(cache.getSkin(profile.getId()).isPresent(), is(false));
}
Also used : SkinProperty(com.github.games647.craftapi.model.skin.SkinProperty) Profile(com.github.games647.craftapi.model.Profile) SkinPropertyTest(com.github.games647.craftapi.model.skin.SkinPropertyTest) Test(org.junit.Test)

Example 4 with Profile

use of com.github.games647.craftapi.model.Profile in project ChangeSkin by games647.

the class SharedUploader method run.

@Override
public void run() {
    GameProfile profile = owner.getProfile();
    UUID id = profile.getId();
    String oldSkinUrl = core.getSkinApi().downloadSkin(id).map(skinModel -> skinModel.getTextures().get(TextureType.SKIN).getUrl()).orElse("");
    sendMessageInvoker("skin-change-queued");
    scheduleChangeTask(oldSkinUrl);
}
Also used : ChangeSkinCore(com.github.games647.changeskin.core.ChangeSkinCore) GameProfile(com.github.games647.changeskin.core.model.GameProfile) Account(com.github.games647.changeskin.core.model.auth.Account) UUID(java.util.UUID) TextureType(com.github.games647.changeskin.core.model.skin.TextureType) GameProfile(com.github.games647.changeskin.core.model.GameProfile) UUID(java.util.UUID)

Example 5 with Profile

use of com.github.games647.craftapi.model.Profile in project ChangeSkin by games647.

the class LoginListener method onPlayerPreLogin.

@Listener
public void onPlayerPreLogin(ClientConnectionEvent.Auth preLoginEvent) {
    SkinStorage storage = core.getStorage();
    GameProfile profile = preLoginEvent.getProfile();
    UUID playerUUID = profile.getUniqueId();
    UserPreference preferences = storage.getPreferences(playerUUID);
    Optional<SkinModel> optSkin = preferences.getTargetSkin();
    if (optSkin.isPresent()) {
        SkinModel targetSkin = optSkin.get();
        if (!preferences.isKeepSkin()) {
            targetSkin = core.checkAutoUpdate(targetSkin);
        }
        plugin.getApi().applyProperties(profile, targetSkin);
        save(preferences);
    } else {
        String playerName = profile.getName().get();
        if (!core.getConfig().getBoolean("restoreSkins") || !refetchSkin(playerName, preferences)) {
            setDefaultSkin(preferences, profile);
        }
    }
}
Also used : GameProfile(org.spongepowered.api.profile.GameProfile) UserPreference(com.github.games647.changeskin.core.model.UserPreference) UUID(java.util.UUID) SkinStorage(com.github.games647.changeskin.core.SkinStorage) SkinModel(com.github.games647.changeskin.core.model.skin.SkinModel) Listener(org.spongepowered.api.event.Listener) SharedListener(com.github.games647.changeskin.core.shared.SharedListener)

Aggregations

Profile (com.github.games647.craftapi.model.Profile)8 StoredProfile (com.github.games647.fastlogin.core.StoredProfile)7 SkinPropertyTest (com.github.games647.craftapi.model.skin.SkinPropertyTest)5 BukkitLoginSession (com.github.games647.fastlogin.bukkit.BukkitLoginSession)5 Test (org.junit.Test)5 BukkitFastLoginPremiumToggleEvent (com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPremiumToggleEvent)4 UUID (java.util.UUID)3 SkinModel (com.github.games647.changeskin.core.model.skin.SkinModel)2 SkinProperty (com.github.games647.craftapi.model.skin.SkinProperty)2 RateLimitException (com.github.games647.craftapi.resolver.RateLimitException)2 BukkitFastLoginPreLoginEvent (com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPreLoginEvent)2 BungeeLoginSession (com.github.games647.fastlogin.bungee.BungeeLoginSession)2 IOException (java.io.IOException)2 ChangeSkinCore (com.github.games647.changeskin.core.ChangeSkinCore)1 SkinStorage (com.github.games647.changeskin.core.SkinStorage)1 GameProfile (com.github.games647.changeskin.core.model.GameProfile)1 UserPreference (com.github.games647.changeskin.core.model.UserPreference)1 Account (com.github.games647.changeskin.core.model.auth.Account)1 TextureType (com.github.games647.changeskin.core.model.skin.TextureType)1 SharedListener (com.github.games647.changeskin.core.shared.SharedListener)1