Search in sources :

Example 1 with SkinInvalidator

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

the class InvalidateCommand method execute.

@Override
public CommandResult execute(CommandSource src, CommandContext args) {
    if (!(src instanceof Player)) {
        plugin.sendMessage(src, "no-console");
        return CommandResult.empty();
    }
    Player receiver = (Player) src;
    Task.builder().async().execute(new SkinInvalidator(plugin, receiver)).submit(plugin);
    return CommandResult.success();
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) SkinInvalidator(com.github.games647.changeskin.sponge.task.SkinInvalidator)

Example 2 with SkinInvalidator

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

the class InvalidateCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (plugin.isBungeeCord()) {
        onBungeeCord(sender, command.getName(), args);
        return true;
    }
    if (args.length > 0) {
        Player targetPlayer = Bukkit.getPlayerExact(args[0]);
        if (targetPlayer == null) {
            plugin.sendMessage(sender, "not-online");
            return true;
        }
        String permPrefix = plugin.getName().toLowerCase() + ".command.skinupdate.other.";
        if (!sender.hasPermission(permPrefix + targetPlayer.getUniqueId()) && !sender.hasPermission(permPrefix + '*')) {
            plugin.sendMessage(sender, "no-permission-other");
            return true;
        }
        Runnable skinInvalidate = new SkinInvalidator(plugin, sender, targetPlayer);
        Bukkit.getScheduler().runTaskAsynchronously(plugin, skinInvalidate);
        return true;
    }
    if (!(sender instanceof Player)) {
        plugin.sendMessage(sender, "no-console");
        return true;
    }
    Player receiver = (Player) sender;
    Bukkit.getScheduler().runTaskAsynchronously(plugin, new SkinInvalidator(plugin, sender, receiver));
    return true;
}
Also used : Player(org.bukkit.entity.Player) SkinInvalidator(com.github.games647.changeskin.bukkit.task.SkinInvalidator)

Example 3 with SkinInvalidator

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

the class InvalidateCommand method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    boolean isOp = sender.getGroups().contains(plugin.getName() + "-OP");
    if (sender instanceof ProxiedPlayer) {
        sender.removeGroups(plugin.getName() + "-OP");
    }
    if (args.length > 0) {
        ProxiedPlayer targetPlayer = ProxyServer.getInstance().getPlayer(args[0]);
        if (targetPlayer == null) {
            plugin.sendMessage(sender, "not-online");
            return;
        }
        String permPrefix = plugin.getName().toLowerCase() + ".command.skinupdate.other.";
        if (!sender.hasPermission(permPrefix + targetPlayer.getUniqueId()) && !sender.hasPermission(permPrefix + '*')) {
            plugin.sendMessage(sender, "no-permission-other");
            return;
        }
        Runnable skinInvalidate = new SkinInvalidator(plugin, sender, targetPlayer, isOp);
        ProxyServer.getInstance().getScheduler().runAsync(plugin, skinInvalidate);
        return;
    }
    if (!(sender instanceof ProxiedPlayer)) {
        plugin.sendMessage(sender, "no-console");
        return;
    }
    ProxiedPlayer receiver = (ProxiedPlayer) sender;
    Runnable skinInvalidate = new SkinInvalidator(plugin, sender, receiver, isOp);
    ProxyServer.getInstance().getScheduler().runAsync(plugin, skinInvalidate);
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) SkinInvalidator(com.github.games647.changeskin.bungee.task.SkinInvalidator)

Aggregations

SkinInvalidator (com.github.games647.changeskin.bukkit.task.SkinInvalidator)1 SkinInvalidator (com.github.games647.changeskin.bungee.task.SkinInvalidator)1 SkinInvalidator (com.github.games647.changeskin.sponge.task.SkinInvalidator)1 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)1 Player (org.bukkit.entity.Player)1 Player (org.spongepowered.api.entity.living.player.Player)1