use of net.md_5.bungee.api.connection.ProxiedPlayer in project DiscordBot by LXGaming.
the class DiscordBotCommand method execute.
@Override
public void execute(CommandSender sender, String[] args) {
if (args.length == 0) {
sender.sendMessage(new ComponentBuilder("===== ").color(ChatColor.GOLD).append("DiscordBot - Bungeecord Edition").color(ChatColor.GREEN).append(" =====").color(ChatColor.GOLD).create());
sender.sendMessage(new ComponentBuilder("Version - ").color(ChatColor.GOLD).append(DiscordBotCore.getInstance().getConfiguration().getDiscordBotVersion()).color(ChatColor.AQUA).create());
sender.sendMessage(new ComponentBuilder("JDA - ").color(ChatColor.GOLD).append(DiscordBotCore.getInstance().getConfiguration().getJDAVersion()).color(ChatColor.AQUA).create());
sender.sendMessage(new ComponentBuilder("Author - ").color(ChatColor.GOLD).append("LX_Gaming").color(ChatColor.AQUA).create());
return;
}
if (args.length == 1 && args[0].equalsIgnoreCase("reload") && sender.hasPermission("DiscordBot.Reload")) {
DiscordBot.getInstance().reloadDiscordBot();
sender.sendMessage(new ComponentBuilder("DiscordBot reloaded.").color(ChatColor.GREEN).create());
return;
}
if (!(sender instanceof ProxiedPlayer)) {
sender.sendMessage(new ComponentBuilder("Command cannot be run from Console").color(ChatColor.RED).create());
return;
}
ProxiedPlayer proxiedPlayer = (ProxiedPlayer) sender;
if (args.length == 1 && (args[0].equalsIgnoreCase("toggle") || args[0].equalsIgnoreCase("t")) && proxiedPlayer.hasPermission("DiscordBot.Toggle")) {
DiscordBotCore.getInstance().getDatabaseManager().togglePlayerDatabase(proxiedPlayer.getUniqueId());
}
}
use of net.md_5.bungee.api.connection.ProxiedPlayer in project DiscordBot by LXGaming.
the class DiscordChatCommand method execute.
@Override
public void execute(CommandSender sender, String[] args) {
StringBuilder stringBuilder = new StringBuilder();
for (String arg : args) {
stringBuilder.append(arg + " ");
}
if (stringBuilder.toString().trim().length() == 0) {
sender.sendMessage(new ComponentBuilder("Message cannot be blank!").color(ChatColor.RED).create());
return;
}
Message message = new Message().setChannel(DiscordBotCore.getInstance().getConfiguration().getChannels().get(this.name).getChannel()).setFormat(DiscordBotCore.getInstance().getConfiguration().getChannelFormat().get(this.name)).setName(sender.getName()).setNick("").setServer("Unknown").setMessage(stringBuilder.toString().trim()).setDiscord(true).setMinecraft(true).setConsole(true).setRedis(true);
if (sender instanceof ProxiedPlayer) {
ProxiedPlayer player = (ProxiedPlayer) sender;
if (DiscordBotCore.getInstance().getDatabaseManager().checkDatabase(player.getUniqueId())) {
player.sendMessage(new ComponentBuilder("DiscordChat disabled. '/DiscordBot Toggle' to enable").color(ChatColor.RED).create());
return;
}
message.setName(player.getName()).setNick(player.getDisplayName());
if (player.getServer() != null && player.getServer().getInfo() != null) {
message.setServer(player.getServer().getInfo().getName());
}
}
DiscordBotCore.getInstance().getMessageSender().sendMessage(message);
}
use of net.md_5.bungee.api.connection.ProxiedPlayer in project DiscordBot by LXGaming.
the class DiscordBotListener method onMessageMinecraft.
@Override
public void onMessageMinecraft(Message message) {
if (message.sendRedis() && DiscordBot.getInstance().getRedisBungee() != null) {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("message", message.getMessage());
jsonObject.addProperty("permission", message.getData().get("Permission"));
DiscordBot.getInstance().getRedisBungee().sendChannelMessage("DiscordBot", new Gson().toJson(jsonObject));
}
for (Iterator<ProxiedPlayer> iterator = ProxyServer.getInstance().getPlayers().iterator(); iterator.hasNext(); ) {
ProxiedPlayer proxiedPlayer = iterator.next();
if (DiscordBotCore.getInstance().getDatabaseManager().checkDatabase(proxiedPlayer.getUniqueId())) {
return;
}
if (message.getData().get("Permission").equals("*") || proxiedPlayer.hasPermission(message.getData().get("Permission"))) {
proxiedPlayer.sendMessage(new ComponentBuilder(message.getMessage()).create());
}
}
return;
}
use of net.md_5.bungee.api.connection.ProxiedPlayer 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.api.connection.ProxiedPlayer 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());
}
Aggregations