SimplyPerms/net/crystalyx/bukkit/simplyperms/imports/ImportPrivileges.java

63 lines
2.2 KiB
Java
Raw Normal View History

2012-04-29 00:11:39 +00:00
package net.crystalyx.bukkit.simplyperms.imports;
import org.bukkit.configuration.file.YamlConfiguration;
import net.crystalyx.bukkit.simplyperms.SimplyAPI;
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
public class ImportPrivileges extends SimplyAPI implements ImportManager {
private SimplyPlugin plugin;
private YamlConfiguration privileges;
public ImportPrivileges(SimplyPlugin plugin) {
super(plugin);
this.plugin = plugin;
this.privileges = new YamlConfiguration();
}
@Override
public void run() throws Exception {
try {
privileges.load("plugins/Privileges/config.yml");
setDefaultGroup(privileges.getString("default_group"));
2012-04-29 00:11:39 +00:00
plugin.getConfig().set("debug", privileges.getBoolean("debug"));
privileges.load("plugins/Privileges/users.yml");
for (String player : getKeys(privileges, "users")) {
addPlayerGroup(player, privileges.getString("users." + player + ".group"));
for (String permission : privileges.getStringList("users." + player + ".permissions")) {
addPlayerPermission(player, permission.replace("-", ""), !permission.startsWith("-"));
2012-04-29 00:11:39 +00:00
}
2012-04-29 00:55:03 +00:00
2012-04-29 00:11:39 +00:00
for (String world : getKeys(privileges, "users." + player + ".worlds")) {
for (String worldpermission : privileges.getStringList("users." + player + ".worlds." + world)) {
addPlayerPermission(player, world, worldpermission.replace("-", ""), !worldpermission.startsWith("-"));
2012-04-29 00:11:39 +00:00
}
}
}
privileges.load("plugins/Privileges/groups.yml");
for (String group : getKeys(privileges, "groups")) {
for (String permission : privileges.getStringList("groups." + group + ".permissions")) {
addGroupPermission(group, permission.replace("-", ""), !permission.startsWith("-"));
2012-04-29 00:11:39 +00:00
}
2012-04-29 00:55:03 +00:00
2012-04-29 00:11:39 +00:00
for (String world : getKeys(privileges, "groups." + group + ".worlds")) {
for (String worldpermission : privileges.getStringList("groups." + group + ".worlds." + world)) {
addGroupPermission(group, world, worldpermission.replace("-", ""), !worldpermission.startsWith("-"));
2012-04-29 00:11:39 +00:00
}
}
2012-04-29 00:55:03 +00:00
2012-04-29 00:11:39 +00:00
for (String inherit : privileges.getStringList("groups." + group + ".inheritance")) {
addGroupInheritance(group, inherit);
2012-04-29 00:11:39 +00:00
}
}
} catch (Exception e) {
throw e;
}
}
}