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