use of net.md_5.bungee.config.Configuration 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));
}
}
}
use of net.md_5.bungee.config.Configuration in project FireAPI by FireBlade-Serv.
the class FireFriends method getOnlineFriends.
public List<ProxiedPlayer> getOnlineFriends(ProxiedPlayer pp) throws IOException {
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
List<ProxiedPlayer> connected = new ArrayList<>();
List<String> list = config.getStringList("data." + pp.getName());
for (String names : list) {
try {
ProxiedPlayer player = this.instance.getProxy().getPlayer(names);
if (player != null) {
connected.add(player);
}
} catch (Exception e) {
continue;
}
}
return connected;
}
use of net.md_5.bungee.config.Configuration in project FireAPI by FireBlade-Serv.
the class FireFriends method sendGeneratedList.
public void sendGeneratedList(ProxiedPlayer pp) throws IOException {
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
if (hasFriends(pp)) {
if (getOnlineFriends(pp).size() == 0) {
pp.sendMessage(new TextComponent(this.pre + "Vous n'avez §caucun§r ami connecté sur le serveur"));
} else if (getOnlineFriends(pp).size() == 1) {
pp.sendMessage(new TextComponent(this.pre + "Vous avez §eun§r ami connecté sur le serveur"));
} else {
pp.sendMessage(new TextComponent(this.pre + "Vous avez §e" + getOnlineFriends(pp).size() + "§r amis connectés sur le serveur"));
}
} else {
pp.sendMessage(new TextComponent(this.pre + "§cVous n'avez pas d'amis :("));
return;
}
List<String> list = config.getStringList("data." + pp.getName());
for (ProxiedPlayer connected : getOnlineFriends(pp)) {
pp.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) {
pp.sendMessage(new TextComponent(this.pre + "§8" + names + "§r est actuellement §chors-ligne"));
}
}
use of net.md_5.bungee.config.Configuration in project FireAPI by FireBlade-Serv.
the class FireAuth method loadConfiguration.
public void loadConfiguration() throws IOException {
File file = new File(this.main.getDataFolder(), "auth.yml");
this.file = file;
if (!file.exists()) {
file.createNewFile();
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
config.set("crypt-pass-key", "stalineestsympa");
this.key = config.getString("crypt-pass-key");
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, this.file);
} else {
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
this.key = config.getString("crypt-pass-key");
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, this.file);
}
}
use of net.md_5.bungee.config.Configuration in project FireAPI by FireBlade-Serv.
the class FireWL method setDefault.
public void setDefault(String name, String ip) throws IOException {
File file = new File(plugin.getDataFolder(), "whitelist.yml");
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
if (config.getBoolean("players." + name + ".accepted") == true && config.contains("players." + name + ".ip")) {
return;
}
if (config.getBoolean("players." + name + ".accepted") == true && !config.contains("players." + name + ".ip")) {
config.set("players." + name + ".ip", ip);
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
return;
}
config.set("players." + name + ".accepted", false);
config.set("players." + name + ".ip", ip);
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
}
Aggregations