use of net.md_5.bungee.config.Configuration in project FireAPI by FireBlade-Serv.
the class FireWL method containsIP.
public boolean containsIP(String name) throws IOException {
if (this.exists(name)) {
File file = new File(plugin.getDataFolder(), "whitelist.yml");
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
return config.contains("players." + name + ".ip");
}
return false;
}
use of net.md_5.bungee.config.Configuration in project FireAPI by FireBlade-Serv.
the class FireWL method loadConfiguration.
public void loadConfiguration() {
try {
if (!plugin.getDataFolder().exists()) {
plugin.getDataFolder().mkdirs();
}
File file = new File(plugin.getDataFolder(), "whitelist.yml");
if (!file.exists()) {
file.createNewFile();
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
config.set("enable", true);
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
if (config.getBoolean("enable") == true) {
enable = true;
} else if (config.getBoolean("enable") == false) {
enable = false;
}
} else {
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, file);
if (config.getBoolean("enable") == true) {
enable = true;
} else if (config.getBoolean("enable") == false) {
enable = false;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of net.md_5.bungee.config.Configuration in project LuckPerms by lucko.
the class BungeeConfigAdapter method getMap.
@Override
public Map<String, String> getMap(String path, Map<String, String> def) {
Map<String, String> map = new HashMap<>();
Configuration section = this.configuration.getSection(path);
if (section == null) {
return def;
}
for (String key : section.getKeys()) {
map.put(key, section.get(key).toString());
}
return map;
}
use of net.md_5.bungee.config.Configuration in project DragonProxy by DragonetMC.
the class Config method save.
/**
* Save the configuration to file
*
* @param fileConfiguration
*/
public void save(String fileConfiguration) {
try {
File ConfigurationFile = new File(this.plugin.getDataFolder(), fileConfiguration);
if (!ConfigurationFile.exists())
this.copyDefault(fileConfiguration);
ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, ConfigurationFile);
this.plugin.getLogger().info("Config saved!");
} catch (IOException ex) {
plugin.getLogger().log(Level.SEVERE, null, ex);
}
}
use of net.md_5.bungee.config.Configuration in project ChangeSkin by games647.
the class ChangeSkinCore method load.
public void load(boolean database) {
saveDefaultFile("messages.yml");
saveDefaultFile("config.yml");
try {
config = loadFile("config.yml");
int rateLimit = config.getInt("mojang-request-limit");
cooldownService = new CooldownService(Duration.ofSeconds(config.getInt("cooldown")));
autoUpdateDiff = Duration.ofMinutes(config.getInt("auto-skin-update"));
List<HostAndPort> proxies = config.getStringList("proxies").stream().map(HostAndPort::fromString).collect(toList());
skinApi = new MojangSkinApi(plugin.getLog(), rateLimit, proxies);
if (database) {
if (!setupDatabase(config.getSection("storage"))) {
return;
}
loadDefaultSkins(config.getStringList("default-skins"));
loadAccounts(config.getStringList("upload-accounts"));
}
Configuration messages = loadFile("messages.yml");
messages.getKeys().stream().filter(key -> messages.get(key) != null).collect(toMap(identity(), messages::get)).forEach((key, message) -> {
String colored = CommonUtil.translateColorCodes((String) message);
if (!colored.isEmpty()) {
localeMessages.put(key, colored.replace("/newline", "\n"));
}
});
} catch (IOException ioEx) {
plugin.getLog().info("Failed to load yaml file", ioEx);
}
}
Aggregations