use of org.bukkit.configuration.file.FileConfiguration in project AuthMeReloaded by AuthMe.
the class MessageFilePlaceholderTest method shouldHaveAllPlaceholders.
@Test
public void shouldHaveAllPlaceholders() {
// given
FileConfiguration configuration = YamlConfiguration.loadConfiguration(messagesFile);
List<String> errors = new ArrayList<>();
// when
for (MessageKey key : MessageKey.values()) {
List<String> missingTags = findMissingTags(key, configuration);
if (!missingTags.isEmpty()) {
errors.add("Message key '" + key + "' should have tags: " + String.join(", ", missingTags));
}
}
// then
if (!errors.isEmpty()) {
fail("Errors while validating '" + messagesFilename + "':\n- " + String.join("\n- ", errors));
}
}
use of org.bukkit.configuration.file.FileConfiguration in project AuthMeReloaded by AuthMe.
the class PermissionConsistencyTest method getPermissionsFromPluginYmlFile.
/**
* Returns all permission entries from the plugin.yml file.
*
* @return map with the permission entries by permission node
*/
private static Map<String, PermissionDefinition> getPermissionsFromPluginYmlFile() {
FileConfiguration pluginFile = YamlConfiguration.loadConfiguration(getJarFile("/plugin.yml"));
MemorySection permsList = (MemorySection) pluginFile.get("permissions");
Map<String, PermissionDefinition> permissions = new HashMap<>();
addChildren(permsList, permissions);
return ImmutableMap.copyOf(permissions);
}
use of org.bukkit.configuration.file.FileConfiguration in project AuthMeReloaded by AuthMe.
the class RoyalAuthConverter method execute.
@Override
public void execute(CommandSender sender) {
for (OfflinePlayer player : plugin.getServer().getOfflinePlayers()) {
try {
String name = player.getName().toLowerCase();
File file = new File(makePath(".", "plugins", "RoyalAuth", "userdata", name + ".yml"));
if (dataSource.isAuthAvailable(name) || !file.exists()) {
continue;
}
FileConfiguration configuration = YamlConfiguration.loadConfiguration(file);
PlayerAuth auth = PlayerAuth.builder().name(name).password(configuration.getString(PASSWORD_PATH), null).lastLogin(configuration.getLong(LAST_LOGIN_PATH)).realName(player.getName()).build();
dataSource.saveAuth(auth);
} catch (Exception e) {
ConsoleLogger.logException("Error while trying to import " + player.getName() + " RoyalAuth data", e);
}
}
}
use of org.bukkit.configuration.file.FileConfiguration in project EliteMobs by MagmaGuy.
the class CustomConfigConstructor method reload.
/**
* Reload configuration
*/
public void reload() {
if (!file.exists()) {
try {
file.getParentFile().mkdirs();
file.createNewFile();
} catch (IOException exception) {
exception.printStackTrace();
plugin.getLogger().severe("Error while creating file " + file.getName());
}
}
try {
load(file);
if (defaults != null) {
InputStreamReader reader = new InputStreamReader(plugin.getResource(defaults));
FileConfiguration defaultsConfig = YamlConfiguration.loadConfiguration(reader);
setDefaults(defaultsConfig);
options().copyDefaults(true);
reader.close();
save();
}
} catch (IOException exception) {
exception.printStackTrace();
plugin.getLogger().severe("Error while loading file " + file.getName());
} catch (InvalidConfigurationException exception) {
exception.printStackTrace();
plugin.getLogger().severe("Error while loading file " + file.getName());
}
}
use of org.bukkit.configuration.file.FileConfiguration in project MyPet by xXKeyleXx.
the class WorldListener method on.
@EventHandler
public void on(WorldInitEvent event) {
if (WorldGroup.getGroupByWorld(event.getWorld().getName()) == null) {
WorldGroup defaultGroup = WorldGroup.getGroupByName("default");
if (defaultGroup == null) {
defaultGroup = new WorldGroup("default");
defaultGroup.registerGroup();
}
if (defaultGroup.addWorld(event.getWorld().getName())) {
File groupsFile = new File(MyPetApi.getPlugin().getDataFolder().getPath() + File.separator + "worldgroups.yml");
ConfigurationYAML yamlConfiguration = new ConfigurationYAML(groupsFile);
FileConfiguration config = yamlConfiguration.getConfig();
config.set("Groups.default", defaultGroup.getWorlds());
yamlConfiguration.saveConfig();
MyPetApi.getLogger().info("added " + ChatColor.YELLOW + event.getWorld().getName() + ChatColor.RESET + " to '" + ChatColor.YELLOW + "default" + ChatColor.RESET + "' group.");
} else {
MyPetApi.getLogger().warning("An error occured while adding " + ChatColor.YELLOW + event.getWorld().getName() + ChatColor.RESET + " to '" + ChatColor.YELLOW + "default" + ChatColor.RESET + "' group. Please restart the server.");
}
}
}
Aggregations