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));
}
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));
}
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));
}
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);
}
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);
}
}
}
Aggregations