Search in sources :

Example 6 with Skin

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());
}
Also used : Player(org.bukkit.entity.Player) UserPreference(com.github.games647.changeskin.core.model.UserPreference) EventHandler(org.bukkit.event.EventHandler)

Example 7 with Skin

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));
}
Also used : SkullCommand(com.github.games647.changeskin.bukkit.command.SkullCommand) UploadCommand(com.github.games647.changeskin.bukkit.command.UploadCommand) InfoCommand(com.github.games647.changeskin.bukkit.command.InfoCommand) SelectCommand(com.github.games647.changeskin.bukkit.command.SelectCommand) InvalidateCommand(com.github.games647.changeskin.bukkit.command.InvalidateCommand) SetCommand(com.github.games647.changeskin.bukkit.command.SetCommand)

Example 8 with Skin

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();
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) SkinSelector(com.github.games647.changeskin.sponge.task.SkinSelector)

Example 9 with Skin

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");
        }
    }
}
Also used : Player(org.bukkit.entity.Player) SkinModel(com.github.games647.changeskin.core.model.skin.SkinModel)

Example 10 with Skin

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

Aggregations

SkinModel (com.github.games647.changeskin.core.model.skin.SkinModel)11 UserPreference (com.github.games647.changeskin.core.model.UserPreference)10 UUID (java.util.UUID)8 Skin (com.github.games647.craftapi.model.skin.Skin)7 SkinProperty (com.github.games647.craftapi.model.skin.SkinProperty)6 SkinPropertyTest (com.github.games647.craftapi.model.skin.SkinPropertyTest)6 Test (org.junit.Test)6 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)5 Texture (com.github.games647.craftapi.model.skin.Texture)3 EventHandler (net.md_5.bungee.event.EventHandler)3 SkinProperty (com.github.games647.changeskin.core.model.skin.SkinProperty)2 TextureModel (com.github.games647.changeskin.core.model.skin.TextureModel)2 TextureType (com.github.games647.changeskin.core.model.skin.TextureType)2 TexturesModel (com.github.games647.changeskin.core.model.skin.TexturesModel)2 IOException (java.io.IOException)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Optional (java.util.Optional)2