Search in sources :

Example 6 with PacketSpyAction

use of fr.glowstoner.fireapi.bigbrother.spy.packets.PacketSpyAction in project FireAPI by FireBlade-Serv.

the class Events method onChat.

@EventHandler(priority = EventPriority.LOWEST)
public void onChat(ChatEvent e) {
    ProxiedPlayer pp = (ProxiedPlayer) e.getSender();
    if (pp.getServer().getInfo().equals(this.instance.getBungeePlugin().getProxy().getServerInfo("login"))) {
        List<String> success = Arrays.asList("/login", "/register");
        if (!success.contains(e.getMessage().split(" ")[0])) {
            e.setCancelled(true);
        }
        if (e.isCommand()) {
            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);
            }
        } else {
            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);
            }
        }
    } else {
        try {
            PacketSpyAction ps = new PacketSpyAction(pp.getName(), pp.getAddress().getAddress().getHostAddress(), e.getMessage(), SpyAction.PLAYER_CHAT);
            ps.setDateToNow();
            this.c.sendPacket(ps);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        if (e.getMessage().startsWith(":")) {
            if (this.instance.getRankSystem().hasRankAndSup(pp.getName(), Rank.GUIDE)) {
                if (this.scc.getPlayers().containsKey(pp)) {
                    if (this.scc.getPlayers().get(pp)) {
                        this.scc.send(pp, e.getMessage().substring(1));
                        e.setCancelled(true);
                    }
                }
            }
        }
    }
}
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 7 with PacketSpyAction

use of fr.glowstoner.fireapi.bigbrother.spy.packets.PacketSpyAction 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)

Aggregations

PacketSpyAction (fr.glowstoner.fireapi.bigbrother.spy.packets.PacketSpyAction)7 IOException (java.io.IOException)7 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)3 EventHandler (net.md_5.bungee.event.EventHandler)3 PacketBigBrotherAC (fr.glowstoner.fireapi.bigbrother.ac.packet.PacketBigBrotherAC)2 TextComponent (net.md_5.bungee.api.chat.TextComponent)2 EventHandler (org.bukkit.event.EventHandler)2 ConnectionHandler (fr.glowstoner.connectionsapi.network.ConnectionHandler)1 PacketPing (fr.glowstoner.connectionsapi.network.packets.PacketPing)1 PacketText (fr.glowstoner.connectionsapi.network.packets.PacketText)1 PacketCommand (fr.glowstoner.connectionsapi.network.packets.command.PacketCommand)1 PacketLogin (fr.glowstoner.connectionsapi.network.packets.login.PacketLogin)1 PacketVersion (fr.glowstoner.fireapi.bigbrother.console.packets.PacketVersion)1 PacketPlayerPing (fr.glowstoner.fireapi.bigbrother.console.packets.ping.PacketPlayerPing)1 BigBrotherSpyHistory (fr.glowstoner.fireapi.bigbrother.spy.BigBrotherSpyHistory)1 PacketSpyHistoryGetter (fr.glowstoner.fireapi.bigbrother.spy.packets.PacketSpyHistoryGetter)1 PacketFriends (fr.glowstoner.fireapi.bungeecord.friends.packets.PacketFriends)1 FriendsActionTransmetterGUI (fr.glowstoner.fireapi.bungeecord.friends.packets.action.FriendsActionTransmetterGUI)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1