Search in sources :

Example 1 with NameResolver

use of com.github.games647.changeskin.sponge.task.NameResolver 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)

Aggregations

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