Search in sources :

Example 31 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project FireAPI by FireBlade-Serv.

the class FireFriends method sendRequest.

public void sendRequest(ProxiedPlayer sender, ProxiedPlayer receiver) {
    if (this.cant.containsKey(sender)) {
        if (this.cant.get(sender).equals(receiver)) {
            sender.sendMessage(new TextComponent(this.pre + "§cAttendez un peu avant d'envoyer une nouvelle §cdemande d'amis à §c" + receiver.getName() + "!"));
            return;
        }
    }
    this.outdated.put(receiver, sender);
    this.cant.put(sender, receiver);
    sendFriendsMessageResquest(receiver, sender.getName());
    this.instance.getProxy().getScheduler().schedule(this.instance, new Runnable() {

        @Override
        public void run() {
            cant.remove(sender);
            outdated.remove(receiver);
        }
    }, 5L, TimeUnit.MINUTES);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent)

Example 32 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project FireAPI by FireBlade-Serv.

the class FireFriends method sendGeneratedListOther.

public void sendGeneratedListOther(CommandSender sender, String name) throws IOException {
    Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
    if (!this.instance.getSQL().hasFireAccount(name)) {
        sender.sendMessage(new TextComponent(this.pre + "§cErreur ce joueur n'existe pas !"));
        return;
    }
    if (hasFriends(name)) {
        if (getOnlineFriends(name).size() == 0) {
            sender.sendMessage(new TextComponent(this.pre + name + " n'a §caucun§r ami connecté sur le serveur"));
        } else if (getOnlineFriends(name).size() == 1) {
            sender.sendMessage(new TextComponent(this.pre + name + " a §eun§r ami connecté sur le serveur"));
        } else {
            sender.sendMessage(new TextComponent(this.pre + name + " a §e" + getOnlineFriends(name).size() + "§r amis connectés sur le serveur"));
        }
    } else {
        sender.sendMessage(new TextComponent(this.pre + "§c" + name + " n'a pas d'amis :("));
        return;
    }
    List<String> list = config.getStringList("data." + name);
    for (ProxiedPlayer connected : getOnlineFriends(name)) {
        sender.sendMessage(new TextComponent(this.pre + "§a" + connected.getName() + "§r est actuellement sur le §e" + connected.getServer().getInfo().getName()));
        list.remove(connected.getName());
    }
    for (String names : list) {
        sender.sendMessage(new TextComponent(this.pre + "§8" + names + "§r est actuellement §chors-ligne"));
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration)

Example 33 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project FireAPI by FireBlade-Serv.

the class FireFriends method sendFriendsMessageResquest.

public void sendFriendsMessageResquest(ProxiedPlayer pp, String name) {
    TextComponent accept = new TextComponent("§a§l✔ Accepter§r ");
    accept.setClickEvent(new ClickEvent(net.md_5.bungee.api.chat.ClickEvent.Action.RUN_COMMAND, "/amis accept " + name));
    accept.setHoverEvent(new HoverEvent(net.md_5.bungee.api.chat.HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aCliquez ici pour accepter sa demande").create()));
    TextComponent base = new TextComponent(this.pre + "§e" + name + "§r vous demande en ami ! ");
    base.addExtra(accept);
    pp.sendMessage(base);
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) HoverEvent(net.md_5.bungee.api.chat.HoverEvent) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Example 34 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project FireAPI by FireBlade-Serv.

the class FireFriends method addFriend.

public void addFriend(ProxiedPlayer p1, ProxiedPlayer p2) {
    if (this.enable) {
        try {
            Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
            if (!config.contains("data." + p1.getName())) {
                List<String> list = new ArrayList<>();
                list.add(p2.getName());
                config.set("data." + p1.getName(), list);
            } else {
                List<String> list = config.getStringList("data." + p1.getName());
                list.add(p2.getName());
                config.set("data." + p1.getName(), list);
            }
            if (!config.contains("data." + p2.getName())) {
                List<String> list = new ArrayList<>();
                list.add(p1.getName());
                config.set("data." + p2.getName(), list);
            } else {
                List<String> list = config.getStringList("data." + p2.getName());
                list.add(p1.getName());
                config.set("data." + p2.getName(), list);
            }
            ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, this.file);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) ArrayList(java.util.ArrayList) IOException(java.io.IOException) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration)

Example 35 with ProxiedPlayer

use of net.md_5.bungee.api.connection.ProxiedPlayer in project FireAPI by FireBlade-Serv.

the class FireFriends method removeFriend.

public void removeFriend(ProxiedPlayer p1, String p2) throws IOException {
    if (this.enable) {
        Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
        if (config.contains("data." + p1.getName()) && config.contains("data." + p2)) {
            List<String> list = config.getStringList("data." + p1.getName());
            if (list.contains(p2)) {
                list.remove(p2);
            }
            if (list.size() == 0) {
                config.set("data." + p1.getName(), null);
            } else {
                config.set("data." + p1.getName(), list);
            }
            List<String> list2 = config.getStringList("data." + p2);
            if (list2.contains(p1.getName())) {
                list2.remove(p1.getName());
            }
            if (list2.size() == 0) {
                config.set("data." + p2, null);
            } else {
                config.set("data." + p2, list2);
            }
            ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, this.file);
            p1.sendMessage(new TextComponent(this.pre + "§aVous n'êtes plus ami avec " + p2));
        } else {
            p1.sendMessage(new TextComponent(this.pre + "§cErreur, vous n'êtes pas ami avec " + p2));
        }
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) YamlConfiguration(net.md_5.bungee.config.YamlConfiguration)

Aggregations

ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)50 EventHandler (net.md_5.bungee.event.EventHandler)20 TextComponent (net.md_5.bungee.api.chat.TextComponent)17 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)10 Configuration (net.md_5.bungee.config.Configuration)6 YamlConfiguration (net.md_5.bungee.config.YamlConfiguration)6 UserPreference (com.github.games647.changeskin.core.model.UserPreference)5 Message (at.pcgamingfreaks.Bungee.Message.Message)4 User (me.lucko.luckperms.common.model.User)4 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)4 Test (org.junit.Test)4 SkinModel (com.github.games647.changeskin.core.model.skin.SkinModel)3 ByteArrayDataInput (com.google.common.io.ByteArrayDataInput)3 PacketSpyAction (fr.glowstoner.fireapi.bigbrother.spy.packets.PacketSpyAction)3 Tristate (me.lucko.luckperms.api.Tristate)3 Chat (net.md_5.bungee.protocol.packet.Chat)3 ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)2 FirePlayer (fr.glowstoner.fireapi.player.FirePlayer)2 Message (io.github.lxgaming.discordbot.entries.Message)2