Search in sources :

Example 1 with SkinDownloader

use of com.github.games647.changeskin.sponge.task.SkinDownloader in project ChangeSkin by games647.

the class SetCommand method execute.

@Override
public CommandResult execute(CommandSource src, CommandContext args) {
    if (!(src instanceof Player)) {
        plugin.sendMessage(src, "no-console");
        return CommandResult.empty();
    }
    UUID uniqueId = ((Player) src).getUniqueId();
    if (core.getCooldownService().isTracked(uniqueId)) {
        plugin.sendMessage(src, "cooldown");
        return CommandResult.empty();
    }
    Player receiver = (Player) src;
    String targetSkin = args.<String>getOne("skin").get();
    boolean keepSkin = args.hasAny("keep");
    if ("reset".equals(targetSkin)) {
        targetSkin = receiver.getUniqueId().toString();
    }
    if (targetSkin.length() > 16) {
        UUID targetUUID = UUID.fromString(targetSkin);
        if (core.getConfig().getBoolean("skinPermission") && !plugin.hasSkinPermission(src, targetUUID, true)) {
            return CommandResult.empty();
        }
        plugin.sendMessage(src, "skin-change-queue");
        Runnable skinDownloader = new SkinDownloader(plugin, src, receiver, targetUUID, keepSkin);
        Task.builder().async().execute(skinDownloader).submit(plugin);
        return CommandResult.success();
    }
    Runnable nameResolver = new NameResolver(plugin, src, targetSkin, receiver, keepSkin);
    Task.builder().async().execute(nameResolver).submit(plugin);
    return CommandResult.success();
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) SkinDownloader(com.github.games647.changeskin.sponge.task.SkinDownloader) UUID(java.util.UUID) NameResolver(com.github.games647.changeskin.sponge.task.NameResolver)

Example 2 with SkinDownloader

use of com.github.games647.changeskin.sponge.task.SkinDownloader in project ChangeSkin by games647.

the class SetCommand method setSkinUUID.

private void setSkinUUID(CommandSender sender, Player receiverPayer, String targetUUID, boolean keepSkin) {
    try {
        UUID uuid = UUID.fromString(targetUUID);
        if (plugin.getConfig().getBoolean("skinPermission") && !plugin.hasSkinPermission(sender, uuid, true)) {
            return;
        }
        plugin.sendMessage(sender, "skin-change-queue");
        Runnable skinDownloader = new SkinDownloader(plugin, sender, receiverPayer, uuid, keepSkin);
        Bukkit.getScheduler().runTaskAsynchronously(plugin, skinDownloader);
    } catch (IllegalArgumentException illegalArgumentException) {
        plugin.sendMessage(sender, "invalid-uuid");
    }
}
Also used : SkinDownloader(com.github.games647.changeskin.bukkit.task.SkinDownloader) UUID(java.util.UUID)

Example 3 with SkinDownloader

use of com.github.games647.changeskin.sponge.task.SkinDownloader in project ChangeSkin by games647.

the class SetCommand method setSkinUUID.

private void setSkinUUID(CommandSender sender, ProxiedPlayer receiverPayer, String targetUUID, boolean bukkitOp, boolean keepSkin) {
    try {
        UUID uuid = UUID.fromString(targetUUID);
        if (plugin.getCore().getConfig().getBoolean("skinPermission") && !plugin.hasSkinPermission(sender, uuid, true)) {
            return;
        }
        plugin.sendMessage(sender, "skin-change-queue");
        Runnable skinDownloader = new SkinDownloader(plugin, sender, receiverPayer, uuid, bukkitOp, keepSkin);
        ProxyServer.getInstance().getScheduler().runAsync(plugin, skinDownloader);
    } catch (IllegalArgumentException illegalArgumentException) {
        plugin.sendMessage(sender, "invalid-uuid");
    }
}
Also used : SkinDownloader(com.github.games647.changeskin.bungee.task.SkinDownloader) UUID(java.util.UUID)

Aggregations

UUID (java.util.UUID)3 SkinDownloader (com.github.games647.changeskin.bukkit.task.SkinDownloader)1 SkinDownloader (com.github.games647.changeskin.bungee.task.SkinDownloader)1 NameResolver (com.github.games647.changeskin.sponge.task.NameResolver)1 SkinDownloader (com.github.games647.changeskin.sponge.task.SkinDownloader)1 Player (org.spongepowered.api.entity.living.player.Player)1