use of com.github.games647.craftapi.model.skin.Skin 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.craftapi.model.skin.Skin in project ChangeSkin by games647.
the class ChangeSkinBukkit method registerCommands.
private void registerCommands() {
getCommand("setskin").setExecutor(new SetCommand(this));
getCommand("skinupdate").setExecutor(new InvalidateCommand(this));
getCommand("skinselect").setExecutor(new SelectCommand(this));
getCommand("skinupload").setExecutor(new UploadCommand(this));
getCommand("skinskull").setExecutor(new SkullCommand(this));
getCommand("skin-info").setExecutor(new InfoCommand(this));
}
use of com.github.games647.craftapi.model.skin.Skin in project ChangeSkin by games647.
the class SelectCommand method execute.
@Override
public CommandResult execute(CommandSource src, CommandContext args) {
if (!(src instanceof Player)) {
plugin.sendMessage(src, "no-console");
return CommandResult.empty();
}
String skinName = args.<String>getOne("skinName").get().toLowerCase().replace("skin-", "");
try {
int targetId = Integer.parseInt(skinName);
Player receiver = (Player) src;
Task.builder().async().execute(new SkinSelector(plugin, receiver, targetId)).submit(plugin);
} catch (NumberFormatException numberFormatException) {
plugin.sendMessage(src, "invalid-skin-name");
}
return CommandResult.success();
}
use of com.github.games647.craftapi.model.skin.Skin in project ChangeSkin by games647.
the class InfoCommand method sendSkinDetails.
private void sendSkinDetails(UUID uuid, UserPreference preference) {
Player player = Bukkit.getPlayer(uuid);
if (player != null) {
Optional<SkinModel> optSkin = preference.getTargetSkin();
if (optSkin.isPresent()) {
String template = plugin.getCore().getMessage("skin-info");
player.sendMessage(formatter.apply(template, optSkin.get()));
} else {
plugin.sendMessage(player, "skin-not-found");
}
}
}
use of com.github.games647.craftapi.model.skin.Skin 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);
}
Aggregations