Search in sources :

Example 1 with ChannelMessage

use of com.github.games647.changeskin.core.message.ChannelMessage in project ChangeSkin by games647.

the class SkinApplier method run.

@Override
public void run() {
    if (!isConnected()) {
        return;
    }
    UUID receiverUUID = receiver.getUniqueId();
    if (invoker instanceof ProxiedPlayer) {
        if (targetSkin != null && core.getConfig().getBoolean("bukkit-permissions")) {
            Server server = ((ProxiedPlayer) invoker).getServer();
            boolean skinPerm = core.getConfig().getBoolean("skinPermission");
            ChannelMessage message = new CheckPermMessage(targetSkin, receiverUUID, skinPerm, bukkitOp);
            plugin.sendPluginMessage(server, message);
            return;
        }
        // uuid was successful resolved, we could now make a cooldown check
        core.getCooldownService().trackPlayer(((ProxiedPlayer) invoker).getUniqueId());
    }
    // check if that specific player is online
    UserPreference preferences = plugin.getLoginSession(receiver.getPendingConnection());
    if (preferences == null) {
        preferences = plugin.getStorage().getPreferences(receiverUUID);
    }
    save(preferences);
    applySkin();
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) Server(net.md_5.bungee.api.connection.Server) CheckPermMessage(com.github.games647.changeskin.core.message.CheckPermMessage) UserPreference(com.github.games647.changeskin.core.model.UserPreference) UUID(java.util.UUID) ChannelMessage(com.github.games647.changeskin.core.message.ChannelMessage)

Example 2 with ChannelMessage

use of com.github.games647.changeskin.core.message.ChannelMessage in project ChangeSkin by games647.

the class AbstractForwardCommand method onBungeeCord.

protected void onBungeeCord(CommandSender sender, String commandName, String... args) {
    Player proxy;
    boolean isPlayer = sender instanceof Player;
    if (isPlayer) {
        proxy = (Player) sender;
    } else {
        Optional<? extends Player> optPlayer = Bukkit.getOnlinePlayers().stream().findAny();
        if (!optPlayer.isPresent()) {
            sender.sendMessage(ChatColor.DARK_RED + "No player is online to forward this message to Bungee");
            return;
        }
        proxy = optPlayer.get();
    }
    ChannelMessage message = new ForwardMessage(commandName, Joiner.on(' ').join(args), isPlayer, sender.isOp());
    plugin.sendPluginMessage(proxy, message);
}
Also used : Player(org.bukkit.entity.Player) ForwardMessage(com.github.games647.changeskin.core.message.ForwardMessage) ChannelMessage(com.github.games647.changeskin.core.message.ChannelMessage)

Aggregations

ChannelMessage (com.github.games647.changeskin.core.message.ChannelMessage)2 CheckPermMessage (com.github.games647.changeskin.core.message.CheckPermMessage)1 ForwardMessage (com.github.games647.changeskin.core.message.ForwardMessage)1 UserPreference (com.github.games647.changeskin.core.model.UserPreference)1 UUID (java.util.UUID)1 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)1 Server (net.md_5.bungee.api.connection.Server)1 Player (org.bukkit.entity.Player)1