Search in sources :

Example 11 with EventHandler

use of net.md_5.bungee.event.EventHandler in project LuckPerms by lucko.

the class BungeePermissionCheckListener method onOtherTristateCheck.

@EventHandler(priority = EventPriority.HIGHEST)
public void onOtherTristateCheck(TristateCheckEvent e) {
    if (e.getSender() instanceof ProxiedPlayer) {
        return;
    }
    Objects.requireNonNull(e.getPermission(), "permission");
    Objects.requireNonNull(e.getSender(), "sender");
    String permission = e.getPermission();
    Tristate result = e.getResult();
    String name = "internal/" + e.getSender().getName();
    this.plugin.getVerboseHandler().offerCheckData(CheckOrigin.PLATFORM_LOOKUP_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 12 with EventHandler

use of net.md_5.bungee.event.EventHandler in project Parties by AlessioDP.

the class BungeeListener method onConnect.

@EventHandler
public void onConnect(ServerConnectEvent event) {
    /*
		 * Connect chain starts here,
		 * this method will sent a PartiesPacket to the player server
		 */
    if (event.isCancelled())
        return;
    ProxiedPlayer proxyPlayer = event.getPlayer();
    // Return if its not a player
    if (proxyPlayer.getServer() == null)
        return;
    // Return if the player is already in the server
    if (proxyPlayer.getServer().getInfo().equals(event.getTarget()))
        return;
    // Return if the server is not into the follow list
    if (!listContains(ConfigMain.follow_listserver, proxyPlayer.getServer().getInfo().getName()))
        return;
    /*
		 * 
		 */
    try {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        DataOutputStream out = new DataOutputStream(stream);
        // Initialize packet
        Packet packet = new Packet(plugin.getDescription().getVersion(), event.getTarget().getName(), ConfigMain.follow_neededrank, ConfigMain.follow_minimumrank);
        // Write to the DataOutputStream the data
        packet.write(out);
        if (proxyPlayer.getServer() != null) {
            PartiesBungee.debugLog("Parties packet sent to " + proxyPlayer.getServer().getInfo().getName());
            proxyPlayer.getServer().sendData(partiesChannel, stream.toByteArray());
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) Packet(com.alessiodp.parties.bungeecord.utils.Packet) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) EventHandler(net.md_5.bungee.event.EventHandler)

Example 13 with EventHandler

use of net.md_5.bungee.event.EventHandler in project DragonProxy by DragonetMC.

the class DPAddonBungee method onServerConnected.

@EventHandler
public void onServerConnected(ServerConnectedEvent event) {
    if (!bedrockPlayers.contains(event.getPlayer().getUniqueId()))
        return;
    // forward the DragonProxy Notification message!
    getProxy().getScheduler().schedule(this, () -> {
        BinaryStream bis = new BinaryStream();
        bis.putString("Notification");
        event.getPlayer().sendData("DragonProxy", bis.getBuffer());
    }, 2000L, TimeUnit.MILLISECONDS);
}
Also used : BinaryStream(org.dragonet.common.utilities.BinaryStream) EventHandler(net.md_5.bungee.event.EventHandler)

Example 14 with EventHandler

use of net.md_5.bungee.event.EventHandler in project DragonProxy by DragonetMC.

the class DPAddonBungee method onServerSwitch.

@EventHandler
public void onServerSwitch(ServerSwitchEvent event) {
    if (!bedrockPlayers.contains(event.getPlayer().getUniqueId()))
        return;
    // We don't know that another server supports forwarding or not so we disable forwarding for now!
    BinaryStream bis = new BinaryStream();
    bis.putString("PacketFoward");
    bis.putBoolean(false);
    event.getPlayer().sendData("DragonProxy", bis.getBuffer());
}
Also used : BinaryStream(org.dragonet.common.utilities.BinaryStream) EventHandler(net.md_5.bungee.event.EventHandler)

Example 15 with EventHandler

use of net.md_5.bungee.event.EventHandler in project DragonProxy by DragonetMC.

the class DPAddonBungee method onPlayerPreLogin.

@EventHandler(priority = EventPriority.LOW)
public void onPlayerPreLogin(PreLoginEvent event) {
    if (ProxyServer.getInstance().getConfig().isOnlineMode()) {
        event.registerIntent(this);
        ProxyServer.getInstance().getScheduler().runAsync(this, new Runnable() {

            @Override
            public void run() {
                String extraDataInHandshake = ((InitialHandler) event.getConnection()).getExtraDataInHandshake();
                List<String> bypassIPs = config.getConfiguration().getStringList("auth_bypass_ip");
                if (!bypassIPs.isEmpty() && bypassIPs.contains(event.getConnection().getAddress().getHostString())) {
                    // check if IP
                    String[] xboxliveProfileParts = extraDataInHandshake.split("\0");
                    if (xboxliveProfileParts.length == 2) {
                        LoginChainDecoder decoder = new LoginChainDecoder(xboxliveProfileParts[1].getBytes(), null);
                        try {
                            // verify login chain, extract players UUID and name
                            decoder.decode();
                        } catch (NullPointerException ex) {
                        }
                        if (decoder.isLoginVerified()) {
                            ReflectedClass initialHandler = new ReflectedClass(event.getConnection());
                            initialHandler.setField("name", decoder.username);
                            initialHandler.setField("uniqueId", decoder.clientUniqueId);
                            event.getConnection().setOnlineMode(false);
                            getLogger().info("Bedrock player " + decoder.username + " uuid : " + decoder.clientUniqueId + " injected in InitialHandler !");
                            bedrockPlayers.add(event.getConnection().getUniqueId());
                        } else {
                            getLogger().info("Bedrock player Fail to verify XBox Identity " + decoder.username);
                            event.getConnection().disconnect(TextComponent.fromLegacyText("Fail to verify XBox Identity, please login to XboxLive and retry."));
                        }
                    }
                }
                event.completeIntent(instance);
            }
        });
    }
}
Also used : LoginChainDecoder(org.dragonet.common.utilities.LoginChainDecoder) ReflectedClass(org.dragonet.common.utilities.ReflectedClass) List(java.util.List) 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