Search in sources :

Example 51 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project CloudNet by Dytanic.

the class CloudProxy method update.

public void update() {
    ProxyInfo proxyInfo = new ProxyInfo(CloudAPI.getInstance().getServiceId(), CloudAPI.getInstance().getConfig().getString("host"), 0, true, new ArrayList<>(CollectionWrapper.transform(ProxyServer.getInstance().getPlayers(), new Catcher<MultiValue<UUID, String>, ProxiedPlayer>() {

        @Override
        public MultiValue<UUID, String> doCatch(ProxiedPlayer key) {
            return new MultiValue<>(key.getUniqueId(), key.getName());
        }
    })), proxyProcessMeta.getMemory(), ProxyServer.getInstance().getOnlineCount());
    CloudAPI.getInstance().update(proxyInfo);
}
Also used : ProxyInfo(de.dytanic.cloudnet.lib.server.info.ProxyInfo) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) MultiValue(de.dytanic.cloudnet.lib.MultiValue)

Example 52 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project commands by aikar.

the class ACFBungeeListener method onPlayerJoin.

@EventHandler
public void onPlayerJoin(PostLoginEvent loginEvent) {
    ProxiedPlayer player = loginEvent.getPlayer();
    // the client settings are sent after a successful login
    Runnable task = () -> manager.readLocale(player);
    plugin.getProxy().getScheduler().schedule(plugin, task, 1, TimeUnit.SECONDS);
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) EventHandler(net.md_5.bungee.event.EventHandler)

Example 53 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project commands by aikar.

the class ACFBungeeListener method onDisconnect.

@EventHandler
public void onDisconnect(PlayerDisconnectEvent disconnectEvent) {
    // cleanup
    ProxiedPlayer player = disconnectEvent.getPlayer();
    manager.issuersLocale.remove(player.getUniqueId());
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) EventHandler(net.md_5.bungee.event.EventHandler)

Example 54 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project ChangeSkin by games647.

the class InfoCommand method execute.

@Override
public void execute(CommandSender sender, String[] strings) {
    if (!(sender instanceof ProxiedPlayer)) {
        plugin.sendMessage(sender, "no-console");
        return;
    }
    ProxiedPlayer player = (ProxiedPlayer) sender;
    UserPreference preference = plugin.getLoginSession((PendingConnection) player);
    Optional<SkinModel> optSkin = preference.getTargetSkin();
    if (optSkin.isPresent()) {
        String template = plugin.getCore().getMessage("skin-info");
        sender.sendMessage(TextComponent.fromLegacyText(formatter.apply(template, optSkin.get())));
    } else {
        plugin.sendMessage(sender, "skin-not-found");
    }
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) UserPreference(com.github.games647.changeskin.core.model.UserPreference) SkinModel(com.github.games647.changeskin.core.model.skin.SkinModel)

Example 55 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project ChangeSkin by games647.

the class MessageListener method onPermissionSuccess.

private void onPermissionSuccess(PermResultMessage message, ProxiedPlayer invoker) {
    SkinModel targetSkin = message.getSkin();
    UUID receiverUUID = message.getReceiverUUID();
    ProxiedPlayer receiver = ProxyServer.getInstance().getPlayer(receiverUUID);
    if (receiver == null || !receiver.isConnected()) {
        // receiver is not online cancel
        return;
    }
    // add cooldown
    core.getCooldownService().trackPlayer(invoker.getUniqueId());
    // Save the target uuid from the requesting player source
    final UserPreference preferences = core.getStorage().getPreferences(receiver.getUniqueId());
    preferences.setTargetSkin(targetSkin);
    ProxyServer.getInstance().getScheduler().runAsync(plugin, () -> {
        if (core.getStorage().save(targetSkin)) {
            core.getStorage().save(preferences);
        }
    });
    if (core.getConfig().getBoolean("instantSkinChange")) {
        plugin.getApi().applySkin(receiver, targetSkin);
        plugin.sendMessage(invoker, "skin-changed");
    } else {
        plugin.sendMessage(invoker, "skin-changed-no-instant");
    }
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) UserPreference(com.github.games647.changeskin.core.model.UserPreference) UUID(java.util.UUID) SkinModel(com.github.games647.changeskin.core.model.skin.SkinModel)

Aggregations

ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)50 EventHandler (net.md_5.bungee.event.EventHandler)20 TextComponent (net.md_5.bungee.api.chat.TextComponent)17 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)10 Configuration (net.md_5.bungee.config.Configuration)6 YamlConfiguration (net.md_5.bungee.config.YamlConfiguration)6 UserPreference (com.github.games647.changeskin.core.model.UserPreference)5 Message (at.pcgamingfreaks.Bungee.Message.Message)4 User (me.lucko.luckperms.common.model.User)4 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)4 Test (org.junit.Test)4 SkinModel (com.github.games647.changeskin.core.model.skin.SkinModel)3 ByteArrayDataInput (com.google.common.io.ByteArrayDataInput)3 PacketSpyAction (fr.glowstoner.fireapi.bigbrother.spy.packets.PacketSpyAction)3 Tristate (me.lucko.luckperms.api.Tristate)3 Chat (net.md_5.bungee.protocol.packet.Chat)3 ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)2 FirePlayer (fr.glowstoner.fireapi.player.FirePlayer)2 Message (io.github.lxgaming.discordbot.entries.Message)2