use of com.github.games647.changeskin.core.model.UserPreference in project ChangeSkin by games647.
the class LoginListener method onPlayerLogin.
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerLogin(PlayerLoginEvent loginEvent) {
if (loginEvent.getResult() != PlayerLoginEvent.Result.ALLOWED) {
// in this event isCancelled option in the annotation doesn't work
return;
}
Player player = loginEvent.getPlayer();
// updates to the chosen one
UserPreference preferences = plugin.getLoginSession(player.getUniqueId());
if (preferences != null) {
preferences.getTargetSkin().ifPresent(skin -> plugin.getApi().applySkin(player, skin));
}
plugin.endSession(player.getUniqueId());
}
use of com.github.games647.changeskin.core.model.UserPreference in project ChangeSkin by games647.
the class InfoCommand method execute.
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
if (!(src instanceof Player)) {
plugin.sendMessage(src, "no-console");
return CommandResult.empty();
}
UUID uniqueId = ((Player) src).getUniqueId();
Task.builder().async().execute(() -> {
UserPreference preferences = plugin.getCore().getStorage().getPreferences(uniqueId);
Task.builder().execute(() -> sendSkinDetails(uniqueId, preferences)).submit(plugin);
}).submit(plugin);
return null;
}
use of com.github.games647.changeskin.core.model.UserPreference in project ChangeSkin by games647.
the class SkinApplier method run.
@Override
public void run() {
if (!isConnected()) {
return;
}
// uuid was successful resolved, we could now make a cooldown check
if (invoker instanceof Player) {
UUID uniqueId = ((Player) invoker).getUniqueId();
core.getCooldownService().trackPlayer(uniqueId);
}
if (core.getStorage() != null) {
UserPreference preferences = core.getStorage().getPreferences(receiver.getUniqueId());
save(preferences);
}
applySkin();
}
use of com.github.games647.changeskin.core.model.UserPreference in project ChangeSkin by games647.
the class ConnectListener method onPlayerLogin.
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerLogin(PostLoginEvent postLoginEvent) {
ProxiedPlayer player = postLoginEvent.getPlayer();
UserPreference preferences = plugin.getLoginSession(player.getPendingConnection());
if (preferences == null || isBlacklistEnabled()) {
return;
}
if (!preferences.getTargetSkin().isPresent()) {
getRandomSkin().ifPresent(preferences::setTargetSkin);
}
preferences.getTargetSkin().ifPresent(skin -> plugin.getApi().applySkin(player, skin));
}
use of com.github.games647.changeskin.core.model.UserPreference in project ChangeSkin by games647.
the class ConnectListener method onDisconnect.
@EventHandler
public void onDisconnect(PlayerDisconnectEvent disconnectEvent) {
PendingConnection pendingConnection = disconnectEvent.getPlayer().getPendingConnection();
UserPreference preference = plugin.endSession(pendingConnection);
if (preference != null) {
save(preference);
}
}
Aggregations