use of net.md_5.bungee.config.Configuration in project DiscordBot by LXGaming.
the class Config method saveFile.
public void saveFile(String name, Configuration config) {
try {
File file = new File(DiscordBot.getInstance().getDataFolder(), name);
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
} catch (IOException | NullPointerException | SecurityException ex) {
DiscordBot.getInstance().getLogger().severe("Exception saving " + name);
ex.printStackTrace();
}
}
use of net.md_5.bungee.config.Configuration 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.config.Configuration in project FireAPI by FireBlade-Serv.
the class FireFriends method getOnlineFriends.
public List<ProxiedPlayer> getOnlineFriends(String pp) throws IOException {
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
List<ProxiedPlayer> connected = new ArrayList<>();
List<String> list = config.getStringList("data." + pp);
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 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.config.Configuration 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();
}
}
}
Aggregations