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