use of net.md_5.bungee.config.Configuration in project FireAPI by FireBlade-Serv.
the class FireWL method getIP.
public String getIP(String name) throws IOException {
if (this.containsIP(name)) {
File file = new File(plugin.getDataFolder(), "whitelist.yml");
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
return config.getString("players." + name + ".ip");
}
return null;
}
use of net.md_5.bungee.config.Configuration in project FireAPI by FireBlade-Serv.
the class FireWhiteListCommand method execute.
@Override
public void execute(CommandSender sender, String[] args) {
if (!this.api.getRankSystem().hasRankAndSupOrConsole(sender, Rank.MANAGER_IG)) {
sender.sendMessage(new TextComponent(this.pre + "§cVous n'avez pas la permission d'utiliser cette commande !"));
return;
}
if (args.length == 0) {
sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firewl <add/remove/on/off> (<pseudo>)"));
return;
} else if (args.length == 1) {
if (args[0].equalsIgnoreCase("on")) {
File file = new File(this.api.getBungeePlugin().getDataFolder(), "whitelist.yml");
try {
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
config.set("enable", true);
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
sender.sendMessage(new TextComponent(this.pre + "§aLe plugin est activé !"));
this.api.getWhitelistSystem().setEnable(true);
} catch (IOException e) {
sender.sendMessage(new TextComponent(this.pre + "§cUne erreur interne au plugin est survenue !"));
}
} else if (args[0].equalsIgnoreCase("off")) {
File file = new File(this.api.getBungeePlugin().getDataFolder(), "whitelist.yml");
try {
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
config.set("enable", false);
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
sender.sendMessage(new TextComponent(this.pre + "§aLe plugin est désactivé !"));
this.api.getWhitelistSystem().setEnable(false);
} catch (IOException e) {
sender.sendMessage(new TextComponent(this.pre + "§cUne erreur interne au plugin est survenue !"));
}
} else {
sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firewl <add/remove/on/off> (<pseudo>)"));
return;
}
} else if (args.length == 2) {
if (this.api.getWhitelistSystem().isEnable() == false) {
sender.sendMessage(new TextComponent(this.pre + "§cLe plugin est désactivé !"));
return;
}
if (args[0].equalsIgnoreCase("add")) {
try {
File file = new File(this.api.getBungeePlugin().getDataFolder(), "whitelist.yml");
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
if (config.getBoolean("players." + args[1] + ".accepted") == true) {
sender.sendMessage(new TextComponent(this.pre + "§cLe joueur " + args[1] + " est déjà dans la whitelist !"));
return;
}
config.set("players." + args[1] + ".accepted", true);
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
sender.sendMessage(new TextComponent(this.pre + "§aVous avez ajouté le joueur " + args[1] + " à la whitelist !"));
return;
} catch (IOException e) {
sender.sendMessage(new TextComponent(this.pre + "§cUne erreur interne au plugin est survenue !"));
}
} else if (args[0].equalsIgnoreCase("remove")) {
try {
File file = new File(this.api.getBungeePlugin().getDataFolder(), "whitelist.yml");
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
if (config.getBoolean("players." + args[1] + ".accepted") == false) {
sender.sendMessage(new TextComponent(this.pre + "§cLe joueur " + args[1] + " n'existe pas !"));
return;
}
config.set("players." + args[1] + ".accepted", false);
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
sender.sendMessage(new TextComponent(this.pre + "§aVous avez retiré le joueur " + args[1] + " de la WhiteList !"));
} catch (IOException e) {
sender.sendMessage(new TextComponent(this.pre + "§cUne erreur interne au plugin est survenue !"));
}
} else {
sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firewl <add/remove/on/off> (<pseudo>)"));
return;
}
} else {
sender.sendMessage(new TextComponent(this.pre + "§cUsage : /firewl <add/remove/on/off> (<pseudo>)"));
return;
}
}
use of net.md_5.bungee.config.Configuration in project FireAPI by FireBlade-Serv.
the class FireFriends method loadConfiguration.
public void loadConfiguration() throws IOException {
File file = new File(this.instance.getDataFolder(), "friends.yml");
this.file = file;
if (!file.exists()) {
file.createNewFile();
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
config.set("enable", true);
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, this.file);
this.enable = true;
} else {
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
this.enable = config.getBoolean("enable");
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, this.file);
}
}
use of net.md_5.bungee.config.Configuration in project ViaCheckConnection by x9nico.
the class Bungee method join.
@SuppressWarnings({ "unchecked" })
@EventHandler
public void join(ServerConnectedEvent e) throws IOException {
ProxiedPlayer p = e.getPlayer();
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
if (Bungee.isProtocolSupport()) {
if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_8.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_8").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_9").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9_1.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_9_1").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9_2.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_9_2").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9_3.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_9_3").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_10.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_10").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_11.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_11").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_11_1.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_11_1").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_12.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_12").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.unknown.getId()) {
p.sendMessage(new TextComponent(config.getString("unknown_version").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_7_1.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_7_1").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_7_6.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_7_6").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_12_1.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_12_1").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_12_2.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_12_2").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_13.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_13").replace("&", "§")));
}
} else {
if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_8.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_8").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_9").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9_1.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_9_1").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9_2.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_9_2").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_9_3.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_9_3").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_10.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_10").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_11.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_11").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_11_1.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_11_1").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_12.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_12").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.unknown.getId()) {
p.sendMessage(new TextComponent(config.getString("unknown_version").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_12_1.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_12_1").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_12_2.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_12_2").replace("&", "§")));
} else if (Via.getAPI().getPlayerVersion(p) == ProtocolVersion.v1_13.getId()) {
p.sendMessage(new TextComponent(config.getString("v1_13").replace("&", "§")));
}
}
}
use of net.md_5.bungee.config.Configuration in project ViaCheckConnection by x9nico.
the class Bungee method onEnable.
@Override
public void onEnable() {
getLogger().info("You are using the plugin on a BungeeCord proxy. Don't forget to remove it from your Spigot servers.");
getLogger().info("Plugin version: " + getDescription().getVersion());
getProxy().getPluginManager().registerListener(this, this);
// Creates config.
if (!getDataFolder().exists()) {
getDataFolder().mkdir();
}
File configFile = new File(getDataFolder(), "config.yml");
if (!configFile.exists()) {
try {
configFile.createNewFile();
try (InputStream is = getResourceAsStream("config.yml");
OutputStream os = new FileOutputStream(configFile)) {
ByteStreams.copy(is, os);
}
} catch (IOException e) {
throw new RuntimeException("Unable to create configuration file.", e);
}
}
// Loads config.
try {
ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
} catch (IOException e2) {
throw new RuntimeException("Unable to load configuration file.", e2);
}
new Metrics(this);
}
Aggregations