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");
|
2012-04-29 00:22:45 +00:00
|
|
|
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")) {
|
2012-04-29 00:22:45 +00:00
|
|
|
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)) {
|
2012-04-29 00:22:45 +00:00
|
|
|
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")) {
|
2012-04-29 00:22:45 +00:00
|
|
|
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)) {
|
2012-04-29 00:22:45 +00:00
|
|
|
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")) {
|
2012-04-29 00:22:45 +00:00
|
|
|
addGroupInheritance(group, inherit);
|
2012-04-29 00:11:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|