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;
}
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);
}
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());
}
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);
}
}
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);
}
}
}
}
}
}
Aggregations