Search in sources :

Example 41 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project FireAPI by FireBlade-Serv.

the class StaffChatCommand method send.

public void send(ProxiedPlayer p, String message) {
    String pname = this.api.getChatUtils().getStringRank(p.getName()) + " " + this.api.getChatUtils().getRankColor(p.getName()) + p.getName();
    Iterator<ProxiedPlayer> it = this.players.keySet().iterator();
    while (it.hasNext()) {
        ProxiedPlayer next = it.next();
        if (this.players.get(next)) {
            next.sendMessage(new TextComponent(this.pre + pname + "§r§o : " + message));
        }
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer)

Example 42 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project LuckPerms by lucko.

the class BungeeConnectionListener method onPlayerPostLogin.

@EventHandler
public void onPlayerPostLogin(PostLoginEvent e) {
    final ProxiedPlayer player = e.getPlayer();
    final User user = this.plugin.getUserManager().getIfLoaded(e.getPlayer().getUniqueId());
    if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
        this.plugin.getLogger().info("Processing post-login for " + player.getUniqueId() + " - " + player.getName());
    }
    if (user == null) {
        if (this.plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) {
            // disconnect the user
            this.plugin.getLogger().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded - cancelling login.");
            e.getPlayer().disconnect(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
        } else {
            // just send a message
            this.plugin.getBootstrap().getProxy().getScheduler().schedule(this.plugin.getBootstrap(), () -> {
                if (!player.isConnected()) {
                    return;
                }
                player.sendMessage(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
            }, 1, TimeUnit.SECONDS);
        }
    }
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) User(me.lucko.luckperms.common.model.User) EventHandler(net.md_5.bungee.event.EventHandler)

Example 43 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project LuckPerms by lucko.

the class BungeeConnectionListener method onPlayerQuit.

// Wait until the last priority to unload, so plugins can still perform permission checks on this event
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerQuit(PlayerDisconnectEvent e) {
    ProxiedPlayer player = e.getPlayer();
    // Register with the housekeeper, so the User's instance will stick
    // around for a bit after they disconnect
    this.plugin.getUserManager().getHouseKeeper().registerUsage(player.getUniqueId());
    // force a clear of transient nodes
    this.plugin.getBootstrap().getScheduler().doAsync(() -> {
        User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());
        if (user != null) {
            user.clearTransientNodes();
        }
    });
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) User(me.lucko.luckperms.common.model.User) EventHandler(net.md_5.bungee.event.EventHandler)

Example 44 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project LuckPerms by lucko.

the class BungeePermissionCheckListener method onOtherPermissionCheck.

@EventHandler(priority = EventPriority.HIGHEST)
public void onOtherPermissionCheck(PermissionCheckEvent e) {
    if (e.getSender() instanceof ProxiedPlayer) {
        return;
    }
    Objects.requireNonNull(e.getPermission(), "permission");
    Objects.requireNonNull(e.getSender(), "sender");
    String permission = e.getPermission();
    Tristate result = Tristate.fromBoolean(e.hasPermission());
    String name = "internal/" + e.getSender().getName();
    this.plugin.getVerboseHandler().offerCheckData(CheckOrigin.PLATFORM_PERMISSION_CHECK, name, ContextSet.empty(), permission, result);
    this.plugin.getPermissionVault().offer(permission);
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) Tristate(me.lucko.luckperms.api.Tristate) EventHandler(net.md_5.bungee.event.EventHandler)

Example 45 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project LuckPerms by lucko.

the class BungeePermissionCheckListener method onPlayerTristateCheck.

@EventHandler
public void onPlayerTristateCheck(TristateCheckEvent e) {
    if (!(e.getSender() instanceof ProxiedPlayer)) {
        return;
    }
    Objects.requireNonNull(e.getPermission(), "permission");
    Objects.requireNonNull(e.getSender(), "sender");
    ProxiedPlayer player = ((ProxiedPlayer) e.getSender());
    User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());
    if (user == null) {
        e.setResult(Tristate.UNDEFINED);
        return;
    }
    Contexts contexts = this.plugin.getContextManager().getApplicableContexts(player);
    Tristate result = user.getCachedData().getPermissionData(contexts).getPermissionValue(e.getPermission(), CheckOrigin.PLATFORM_LOOKUP_CHECK);
    if (result == Tristate.UNDEFINED && this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
        // just use the result provided by the proxy when the event was created
        return;
    }
    e.setResult(result);
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) User(me.lucko.luckperms.common.model.User) Tristate(me.lucko.luckperms.api.Tristate) Contexts(me.lucko.luckperms.api.Contexts) EventHandler(net.md_5.bungee.event.EventHandler)

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