Search in sources :

Example 21 with EventHandler

use of net.md_5.bungee.event.EventHandler in project DiscordBot by LXGaming.

the class PlayerListener method onPlayerChat.

@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerChat(ChatEvent event) {
    if (event.isCommand() || event.getSender() == null) {
        return;
    }
    if (event.isCancelled() && !DiscordBotCore.getInstance().getConfiguration().isForceChat()) {
        return;
    }
    ProxiedPlayer proxiedPlayer = (ProxiedPlayer) event.getSender();
    String permission = DiscordBotCore.getInstance().getConfiguration().getChannels().get("Global").getPermission();
    boolean hasPermission = false;
    if (permission == null || permission.trim().equals("") || permission.trim().equals("null")) {
        hasPermission = false;
    } else if (permission.equals("*") || proxiedPlayer.hasPermission(permission)) {
        hasPermission = true;
    }
    if (!DiscordBotCore.getInstance().getConfiguration().isPlayerChat() || !hasPermission || DiscordBotCore.getInstance().getDatabaseManager().checkDatabase(proxiedPlayer.getUniqueId())) {
        return;
    }
    Message message = new Message().setChannel(DiscordBotCore.getInstance().getConfiguration().getChannels().get("Global").getChannel()).setFormat(DiscordBotCore.getInstance().getConfiguration().getChannelFormat().get("Global")).setName(proxiedPlayer.getName()).setNick(proxiedPlayer.getDisplayName()).setServer("Unknown").setMessage(event.getMessage()).setDiscord(true).setMinecraft(false).setConsole(false).setRedis(false);
    if (proxiedPlayer.getServer() != null && proxiedPlayer.getServer().getInfo() != null) {
        message.setServer(proxiedPlayer.getServer().getInfo().getName());
    }
    DiscordBotCore.getInstance().getMessageSender().sendMessage(message);
    return;
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) Message(io.github.lxgaming.discordbot.entries.Message) EventHandler(net.md_5.bungee.event.EventHandler)

Example 22 with EventHandler

use of net.md_5.bungee.event.EventHandler in project Network-depr by Mas281.

the class PingListener method onPing.

@EventHandler
public void onPing(ProxyPingEvent event) {
    ServerPing ping = event.getResponse();
    ping.getVersion().setName(PROTOCOL_NAME);
}
Also used : ServerPing(net.md_5.bungee.api.ServerPing) EventHandler(net.md_5.bungee.event.EventHandler)

Example 23 with EventHandler

use of net.md_5.bungee.event.EventHandler in project Network-depr by Mas281.

the class ServerListener method onProxyLeave.

@EventHandler
public void onProxyLeave(PlayerDisconnectEvent event) {
    ProxiedPlayer player = event.getPlayer();
    ServerInfo info = player.getServer().getInfo();
    UtilServer.sendData(info, "ServerUpdates", "ProxyLeave", player.getName());
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) ServerInfo(net.md_5.bungee.api.config.ServerInfo) EventHandler(net.md_5.bungee.event.EventHandler)

Example 24 with EventHandler

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

the class Events method onConnection.

@EventHandler
public void onConnection(PreLoginEvent e) {
    String name = e.getConnection().getName();
    String ip = e.getConnection().getAddress().getAddress().getHostAddress();
    this.instance.getBungeePlugin().getLogger().info("Tentative de connection de " + name + " avec l'adresse IP : " + ip + ".");
    try {
        this.instance.getWhitelistSystem().setDefault(name, ip);
        this.instance.getWhitelistSystem().loadConfiguration();
    } catch (IOException e2) {
        this.instance.getChatUtils().sendMessageToGroup(this.instance.getWhitelistSystem().getPrefix() + "§c Une erreur critique est survenue ! {name = " + name + ", " + e2.getMessage() + "}", VersionType.BUNGEECORD_VERSION, Rank.MODÉRATEUR);
        e.setCancelReason(new TextComponent("§cUne erreur critique est survenue ! Veuillez contacter Glowstoner ! (SpamBot ?)"));
        e.setCancelled(true);
        return;
    }
    if (this.instance.getWhitelistSystem().isEnable() == false) {
        return;
    }
    File file = new File(this.instance.getBungeePlugin().getDataFolder(), "whitelist.yml");
    Configuration config;
    try {
        config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
        boolean accepted = config.getBoolean("players." + name + ".accepted");
        if (config.getString("players." + name + ".ip").equals(ip) && accepted == true) {
            return;
        }
        e.setCancelReason(new TextComponent("§cLe serveur est en maintenance !\n§9Discord : https://discordapp.com/invite/H7acUcX"));
        e.setCancelled(true);
    } catch (IOException e1) {
        this.instance.getChatUtils().sendMessageToGroup(this.instance.getWhitelistSystem().getPrefix() + "§c Une erreur critique est survenue ! {name = " + name + ", " + e1.getMessage() + "}", VersionType.BUNGEECORD_VERSION, Rank.MODÉRATEUR);
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) Configuration(net.md_5.bungee.config.Configuration) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) IOException(java.io.IOException) File(java.io.File) EventHandler(net.md_5.bungee.event.EventHandler)

Example 25 with EventHandler

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

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