Search in sources :

Example 26 with EventHandler

use of net.md_5.bungee.event.EventHandler in project FireAPI by FireBlade-Serv.

the class Events method onLogin.

@EventHandler
public void onLogin(PostLoginEvent e) {
    final ProxiedPlayer pp = e.getPlayer();
    pp.setTabHeader(new TextComponent("§6Fireblade-serv"), new TextComponent("§eplay.fireblade-serv.eu"));
    if (!this.instance.getSQL().hasFireAccount(pp.getName())) {
        this.instance.getSQL().createFireAccount(pp);
    }
    PacketSpyAction ps = new PacketSpyAction(pp.getName(), pp.getAddress().getAddress().getHostAddress(), "Connection sur le proxy principal.", SpyAction.PLAYER_JOIN);
    ps.setDateToNow();
    try {
        this.c.sendPacket(ps);
    } catch (IOException ex) {
        ex.printStackTrace();
    }
    this.stillconnected.add(pp);
    this.instance.getBungeePlugin().getProxy().getScheduler().schedule(this.instance.getBungeePlugin(), new Runnable() {

        @Override
        public void run() {
            if (pp != null) {
                if (pp.isConnected() && stillconnected.contains(pp)) {
                    pp.disconnect(new TextComponent("§cVous mettez trop de temps pour vous connecter !"));
                }
            }
        }
    }, 15L, TimeUnit.SECONDS);
    if (this.instance.getSQL().getCryptPassword(pp.getName()).equals("§default-not-set")) {
        // not registered
        pp.sendMessage(new TextComponent(this.instance.getAuthentification().getRegisterMessage()));
        this.instance.getAuthentification().getRegisterTitle().send(pp);
    } else {
        // registered
        pp.sendMessage(new TextComponent(this.instance.getAuthentification().getLoginMessage()));
        this.instance.getAuthentification().getLoginTitle().send(pp);
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) PacketSpyAction(fr.glowstoner.fireapi.bigbrother.spy.packets.PacketSpyAction) IOException(java.io.IOException) EventHandler(net.md_5.bungee.event.EventHandler)

Example 27 with EventHandler

use of net.md_5.bungee.event.EventHandler 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 28 with EventHandler

use of net.md_5.bungee.event.EventHandler 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 29 with EventHandler

use of net.md_5.bungee.event.EventHandler 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 30 with EventHandler

use of net.md_5.bungee.event.EventHandler 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

EventHandler (net.md_5.bungee.event.EventHandler)37 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)20 TextComponent (net.md_5.bungee.api.chat.TextComponent)7 IOException (java.io.IOException)5 User (me.lucko.luckperms.common.model.User)4 EventHandler (org.bukkit.event.EventHandler)4 UserPreference (com.github.games647.changeskin.core.model.UserPreference)3 ByteArrayDataInput (com.google.common.io.ByteArrayDataInput)3 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)3 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)3 CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)3 PacketSpyAction (fr.glowstoner.fireapi.bigbrother.spy.packets.PacketSpyAction)3 Message (io.github.lxgaming.discordbot.entries.Message)3 Tristate (me.lucko.luckperms.api.Tristate)3 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)3 PendingConnection (net.md_5.bungee.api.connection.PendingConnection)3 Entity (org.bukkit.entity.Entity)3 Player (org.bukkit.entity.Player)3 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)2 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)2