1.6.2 in github (the previous commit is 1.6.1)

This commit is contained in:
Michel Roux 2012-04-29 02:22:45 +02:00
parent 0cc3fd6ada
commit 9edaca011d
56 changed files with 150 additions and 44 deletions

View File

@ -1,2 +0,0 @@
Manifest-Version: 1.0

1
config.yml Executable file → Normal file
View File

@ -1,4 +1,5 @@
debug: false debug: false
default: default
db: db:
type: file type: file
database: minecraft database: minecraft

33
net/crystalyx/bukkit/simplyperms/SimplyAPI.java Executable file → Normal file
View File

@ -108,7 +108,7 @@ public class SimplyAPI implements PermsConfig {
} }
public List<String> getGroupWorlds(String group) { public List<String> getGroupWorlds(String group) {
if (group.isEmpty()) group = "default"; if (group.isEmpty()) group = getDefaultGroup();
if (plugin.getNode("groups/" + group + "/worlds") != null) { if (plugin.getNode("groups/" + group + "/worlds") != null) {
return new ArrayList<String>(plugin.getNode("groups/" + group + "/worlds").getKeys(false)); return new ArrayList<String>(plugin.getNode("groups/" + group + "/worlds").getKeys(false));
} }
@ -118,31 +118,31 @@ public class SimplyAPI implements PermsConfig {
} }
public List<String> getGroupInheritance(String group) { public List<String> getGroupInheritance(String group) {
if (group.isEmpty()) group = "default"; if (group.isEmpty()) group = getDefaultGroup();
return plugin.getConfig().getStringList("groups/" + group + "/inheritance"); return plugin.getConfig().getStringList("groups/" + group + "/inheritance");
} }
public void addGroupInheritance(String group, String inherit) { public void addGroupInheritance(String group, String inherit) {
if (group.isEmpty()) group = "default"; if (group.isEmpty()) group = getDefaultGroup();
List<String> inheritances = getGroupInheritance(group); List<String> inheritances = getGroupInheritance(group);
if (!inheritances.contains(inherit)) inheritances.add(inherit); if (!inheritances.contains(inherit)) inheritances.add(inherit);
plugin.getConfig().set("groups/" + group + "/inheritance", inheritances); plugin.getConfig().set("groups/" + group + "/inheritance", inheritances);
} }
public void removeGroupInheritance(String group, String inherit) { public void removeGroupInheritance(String group, String inherit) {
if (group.isEmpty()) group = "default"; if (group.isEmpty()) group = getDefaultGroup();
List<String> inheritances = getGroupInheritance(group); List<String> inheritances = getGroupInheritance(group);
inheritances.remove(inherit); inheritances.remove(inherit);
plugin.getConfig().set("groups/" + group + "/inheritance", inheritances); plugin.getConfig().set("groups/" + group + "/inheritance", inheritances);
} }
public void removeGroupInheritances(String group) { public void removeGroupInheritances(String group) {
if (group.isEmpty()) group = "default"; if (group.isEmpty()) group = getDefaultGroup();
plugin.getConfig().set("groups/" + group + "/inheritance", null); plugin.getConfig().set("groups/" + group + "/inheritance", null);
} }
public Map<String, Boolean> getGroupPermissions(String group, String world) { public Map<String, Boolean> getGroupPermissions(String group, String world) {
if (group.isEmpty()) group = "default"; if (group.isEmpty()) group = getDefaultGroup();
Map<String, Boolean> finalPerms = new HashMap<String, Boolean>(); Map<String, Boolean> finalPerms = new HashMap<String, Boolean>();
String permNode = (!world.isEmpty()) ? "groups/" + group + "/worlds/" + world : "groups/" + group + "/permissions"; String permNode = (!world.isEmpty()) ? "groups/" + group + "/worlds/" + world : "groups/" + group + "/permissions";
if (plugin.getNode(permNode) != null) { if (plugin.getNode(permNode) != null) {
@ -158,7 +158,7 @@ public class SimplyAPI implements PermsConfig {
} }
public void addGroupPermission(String group, String world, String permission, boolean value) { public void addGroupPermission(String group, String world, String permission, boolean value) {
if (group.isEmpty()) group = "default"; if (group.isEmpty()) group = getDefaultGroup();
Map<String, Boolean> permissions = getGroupPermissions(group, world); Map<String, Boolean> permissions = getGroupPermissions(group, world);
if (permissions.containsKey(permission)) permissions.remove(permission); if (permissions.containsKey(permission)) permissions.remove(permission);
permissions.put(permission, value); permissions.put(permission, value);
@ -175,7 +175,7 @@ public class SimplyAPI implements PermsConfig {
} }
public void removeGroupPermission(String group, String world, String permission) { public void removeGroupPermission(String group, String world, String permission) {
if (group.isEmpty()) group = "default"; if (group.isEmpty()) group = getDefaultGroup();
Map<String, Boolean> permissions = getGroupPermissions(group, world); Map<String, Boolean> permissions = getGroupPermissions(group, world);
permissions.remove(permission); permissions.remove(permission);
if (!world.isEmpty()) { if (!world.isEmpty()) {
@ -191,15 +191,11 @@ public class SimplyAPI implements PermsConfig {
} }
public void removeGroupPermissions(String group) { public void removeGroupPermissions(String group) {
if (group.isEmpty()) group = "default"; if (group.isEmpty()) group = getDefaultGroup();
plugin.getConfig().set("groups/" + group + "/permissions", null); plugin.getConfig().set("groups/" + group + "/permissions", null);
} }
public void removeGroup(String group) { public void removeGroup(String group) {
if (group.isEmpty() || group.equals("default")) {
plugin.debug("You can't delete default group !");
return;
}
plugin.getConfig().set("groups/" + group, null); plugin.getConfig().set("groups/" + group, null);
} }
@ -224,12 +220,21 @@ public class SimplyAPI implements PermsConfig {
plugin.getConfig().set("messages", messages); plugin.getConfig().set("messages", messages);
} }
public String getDefaultGroup() {
return plugin.getConfig().getString("default", "default");
}
public void setDefaultGroup(String group) {
if (group.isEmpty()) group = "default";
plugin.getConfig().set("default", group);
}
public void refreshPermissions() { public void refreshPermissions() {
plugin.refreshPermissions(); plugin.refreshPermissions();
} }
protected List<String> getKeys(YamlConfiguration config, String node) { protected List<String> getKeys(YamlConfiguration config, String node) {
if (config.getConfigurationSection(node) != null) { if (config.isConfigurationSection(node)) {
return new ArrayList<String>(config.getConfigurationSection(node).getKeys(false)); return new ArrayList<String>(config.getConfigurationSection(node).getKeys(false));
} }
else { else {

View File

@ -4,12 +4,14 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List;
import java.util.Map; import java.util.Map;
import net.crystalyx.bukkit.simplyperms.imports.ImportDB; import net.crystalyx.bukkit.simplyperms.imports.ImportDB;
import net.crystalyx.bukkit.simplyperms.imports.ImportFile; import net.crystalyx.bukkit.simplyperms.imports.ImportFile;
import net.crystalyx.bukkit.simplyperms.imports.ImportManager; import net.crystalyx.bukkit.simplyperms.imports.ImportManager;
import net.crystalyx.bukkit.simplyperms.imports.ImportPermBukkit; import net.crystalyx.bukkit.simplyperms.imports.ImportPermBukkit;
import net.crystalyx.bukkit.simplyperms.imports.ImportPermEx;
import net.crystalyx.bukkit.simplyperms.imports.ImportPrivileges; import net.crystalyx.bukkit.simplyperms.imports.ImportPrivileges;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -168,6 +170,8 @@ public class SimplyCommands implements CommandExecutor {
manager = new ImportPermBukkit(plugin); manager = new ImportPermBukkit(plugin);
} else if (pluginName.equals("privileges")) { } else if (pluginName.equals("privileges")) {
manager = new ImportPrivileges(plugin); manager = new ImportPrivileges(plugin);
} else if (pluginName.equals("permissionsex")) {
manager = new ImportPermEx(plugin);
} else if (pluginName.equals("file")) { } else if (pluginName.equals("file")) {
manager = new ImportFile(plugin); manager = new ImportFile(plugin);
} else if (plugin.getConfig().getString("db/type") != null } else if (plugin.getConfig().getString("db/type") != null
@ -227,7 +231,7 @@ public class SimplyCommands implements CommandExecutor {
sender.sendMessage(ChatColor.GREEN + "Users in " + ChatColor.WHITE + group + ChatColor.GREEN + " (" + ChatColor.WHITE + count + ChatColor.GREEN + "): " + ChatColor.WHITE + text); sender.sendMessage(ChatColor.GREEN + "Users in " + ChatColor.WHITE + group + ChatColor.GREEN + " (" + ChatColor.WHITE + count + ChatColor.GREEN + "): " + ChatColor.WHITE + text);
return true; return true;
} else if (subcommand.equals("setperm")) { } else if (subcommand.equals("setperm")) {
if (!checkPerm(sender, "group.setperm")) return true; if (split.length >= 4 && !checkPerm(sender, "group.setperm", Arrays.asList(split[3].split(",")))) return true;
if (split.length != 4 && split.length != 5) return usage(sender, command, "group setperm"); if (split.length != 4 && split.length != 5) return usage(sender, command, "group setperm");
String group = split[2]; String group = split[2];
String perm = split[3]; String perm = split[3];
@ -254,7 +258,7 @@ public class SimplyCommands implements CommandExecutor {
sender.sendMessage(ChatColor.GREEN + "Group " + ChatColor.WHITE + group + ChatColor.GREEN + " now has " + ChatColor.WHITE + perm + ChatColor.GREEN + " = " + ChatColor.WHITE + value + ChatColor.GREEN + "."); sender.sendMessage(ChatColor.GREEN + "Group " + ChatColor.WHITE + group + ChatColor.GREEN + " now has " + ChatColor.WHITE + perm + ChatColor.GREEN + " = " + ChatColor.WHITE + value + ChatColor.GREEN + ".");
return true; return true;
} else if (subcommand.equals("unsetperm")) { } else if (subcommand.equals("unsetperm")) {
if (!checkPerm(sender, "group.unsetperm")) return true; if (split.length >= 4 && !checkPerm(sender, "group.unsetperm", Arrays.asList(split[3].split(",")))) return true;
if (split.length != 4) return usage(sender, command, "group unsetperm"); if (split.length != 4) return usage(sender, command, "group unsetperm");
String group = split[2].toLowerCase(); String group = split[2].toLowerCase();
String perm = split[3]; String perm = split[3];
@ -312,7 +316,7 @@ public class SimplyCommands implements CommandExecutor {
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is in groups (" + ChatColor.WHITE + count + ChatColor.GREEN + "): " + ChatColor.WHITE + text); sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is in groups (" + ChatColor.WHITE + count + ChatColor.GREEN + "): " + ChatColor.WHITE + text);
return true; return true;
} else if (subcommand.equals("setgroup")) { } else if (subcommand.equals("setgroup")) {
if (!checkPerm(sender, "player.setgroup")) return true; if (split.length == 4 && !checkPerm(sender, "player.setgroup", Arrays.asList(split[3].split(",")))) return true;
if (split.length != 4) return usage(sender, command, "player setgroup"); if (split.length != 4) return usage(sender, command, "player setgroup");
String player = split[2].toLowerCase(); String player = split[2].toLowerCase();
String[] groups = split[3].split(","); String[] groups = split[3].split(",");
@ -327,7 +331,7 @@ public class SimplyCommands implements CommandExecutor {
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is now in " + ChatColor.WHITE + split[3] + ChatColor.GREEN + "."); sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is now in " + ChatColor.WHITE + split[3] + ChatColor.GREEN + ".");
return true; return true;
} else if (subcommand.equals("addgroup")) { } else if (subcommand.equals("addgroup")) {
if (!checkPerm(sender, "player.addgroup")) return true; if (split.length == 4 && !checkPerm(sender, "player.addgroup", Arrays.asList(split[3]))) return true;
if (split.length != 4) return usage(sender, command, "player addgroup"); if (split.length != 4) return usage(sender, command, "player addgroup");
String player = split[2].toLowerCase(); String player = split[2].toLowerCase();
String group = split[3]; String group = split[3];
@ -343,7 +347,7 @@ public class SimplyCommands implements CommandExecutor {
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is now in " + ChatColor.WHITE + group + ChatColor.GREEN + "."); sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is now in " + ChatColor.WHITE + group + ChatColor.GREEN + ".");
return true; return true;
} else if (subcommand.equals("removegroup")) { } else if (subcommand.equals("removegroup")) {
if (!checkPerm(sender, "player.removegroup")) return true; if (split.length == 4 && !checkPerm(sender, "player.removegroup", Arrays.asList(split[3]))) return true;
if (split.length != 4) return usage(sender, command, "player removegroup"); if (split.length != 4) return usage(sender, command, "player removegroup");
String player = split[2].toLowerCase(); String player = split[2].toLowerCase();
String group = split[3]; String group = split[3];
@ -374,7 +378,7 @@ public class SimplyCommands implements CommandExecutor {
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is no longer in config file."); sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is no longer in config file.");
return true; return true;
} else if (subcommand.equals("setperm")) { } else if (subcommand.equals("setperm")) {
if (!checkPerm(sender, "player.setperm")) return true; if (split.length >= 4 && !checkPerm(sender, "player.setperm", Arrays.asList(split[3].split(",")))) return true;
if (split.length != 4 && split.length != 5) return usage(sender, command, "player setperm"); if (split.length != 4 && split.length != 5) return usage(sender, command, "player setperm");
String player = split[2].toLowerCase(); String player = split[2].toLowerCase();
String perm = split[3]; String perm = split[3];
@ -392,7 +396,7 @@ public class SimplyCommands implements CommandExecutor {
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " now has " + ChatColor.WHITE + perm + ChatColor.GREEN + " = " + ChatColor.WHITE + value + ChatColor.GREEN + "."); sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " now has " + ChatColor.WHITE + perm + ChatColor.GREEN + " = " + ChatColor.WHITE + value + ChatColor.GREEN + ".");
return true; return true;
} else if (subcommand.equals("unsetperm")) { } else if (subcommand.equals("unsetperm")) {
if (!checkPerm(sender, "player.unsetperm")) return true; if (split.length >= 4 && !checkPerm(sender, "player.unsetperm", Arrays.asList(split[3].split(",")))) return true;
if (split.length != 4) return usage(sender, command, "player unsetperm"); if (split.length != 4) return usage(sender, command, "player unsetperm");
String player = split[2].toLowerCase(); String player = split[2].toLowerCase();
String perm = split[3]; String perm = split[3];
@ -428,6 +432,27 @@ public class SimplyCommands implements CommandExecutor {
return ok; return ok;
} }
private boolean checkPerm(CommandSender sender, String node, List<String> subnodes) {
boolean ok = sender.hasPermission("permissions." + node);
if (!ok) {
for (String subnode : subnodes) {
String testnode = "";
for (String sub : subnode.split(".")) {
testnode += sub;
if (sender.hasPermission("permissions." + node + "." + testnode)) {
ok = true;
break;
}
}
if (ok) break;
}
}
if (!ok) {
sender.sendMessage(ChatColor.RED + "You do not have permissions to do that.");
}
return ok;
}
private boolean usage(CommandSender sender, Command command) { private boolean usage(CommandSender sender, Command command) {
sender.sendMessage(ChatColor.RED + "[====" + ChatColor.GREEN + " /permissons " + ChatColor.RED + "====]"); sender.sendMessage(ChatColor.RED + "[====" + ChatColor.GREEN + " /permissons " + ChatColor.RED + "====]");
for (String line : command.getUsage().split("\\n")) { for (String line : command.getUsage().split("\\n")) {

View File

@ -16,6 +16,7 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment; import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -32,13 +33,27 @@ public class SimplyPlugin extends JavaPlugin {
// -- Basic stuff // -- Basic stuff
@Override @Override
public void onEnable() { public void onEnable() {
// Unregister existing PermissionsBukkit nodes
if (getServer().getPluginManager().isPluginEnabled("PermissionsBukkit")) {
for (Permission perm : getServer().getPluginManager().getPlugin("PermissionsBukkit").getDescription().getPermissions()) {
getServer().getPluginManager().removePermission(perm);
}
}
// Disable others permissions plugin
for (String permPlugin : getDescription().getSoftDepend()) {
if (getServer().getPluginManager().isPluginEnabled(permPlugin)) {
getServer().getPluginManager().disablePlugin(getServer().getPluginManager().getPlugin(permPlugin));
}
}
// Take care of configuration // Take care of configuration
configFile = new File(getDataFolder(), "config.yml"); configFile = new File(getDataFolder(), "config.yml");
if (!configFile.exists()) { if (!configFile.exists()) {
saveDefaultConfig(); saveDefaultConfig();
} }
reloadConfig(); reloadConfig();
// Register stuff // Register stuff
getCommand("permissions").setExecutor(commandExecutor); getCommand("permissions").setExecutor(commandExecutor);
getServer().getPluginManager().registerEvents(playerListener, this); getServer().getPluginManager().registerEvents(playerListener, this);
@ -146,7 +161,7 @@ public class SimplyPlugin extends JavaPlugin {
} }
} }
protected ConfigurationSection getNode(String node) { public ConfigurationSection getNode(String node) {
for (String entry : getConfig().getKeys(true)) { for (String entry : getConfig().getKeys(true)) {
if (node.equalsIgnoreCase(entry) && getConfig().isConfigurationSection(entry)) { if (node.equalsIgnoreCase(entry) && getConfig().isConfigurationSection(entry)) {
return getConfig().getConfigurationSection(entry); return getConfig().getConfigurationSection(entry);
@ -213,13 +228,14 @@ public class SimplyPlugin extends JavaPlugin {
// -- Private stuff // -- Private stuff
private Map<String, Boolean> calculatePlayerPermissions(String player, String world) { private Map<String, Boolean> calculatePlayerPermissions(String player, String world) {
String default_group = getConfig().getString("default", "default");
if (!config.isPlayerInDB(player)) { if (!config.isPlayerInDB(player)) {
return calculateGroupPermissions("default", world); return calculateGroupPermissions(default_group, world);
} }
Map<String, Boolean> perms = new HashMap<String, Boolean>(); Map<String, Boolean> perms = new HashMap<String, Boolean>();
List<String> groups = config.getPlayerGroups(player); List<String> groups = config.getPlayerGroups(player);
if (groups.isEmpty()) groups.add("default"); if (groups.isEmpty()) groups.add(default_group);
for (Entry<String, Boolean> entry : config.getPlayerPermissions(player).entrySet()) { for (Entry<String, Boolean> entry : config.getPlayerPermissions(player).entrySet()) {
perms.put(entry.getKey(), entry.getValue()); perms.put(entry.getKey(), entry.getValue());

0
net/crystalyx/bukkit/simplyperms/imports/ImportDB.java Executable file → Normal file
View File

View File

View File

View File

View File

@ -0,0 +1,62 @@
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 ImportPermEx extends SimplyAPI implements ImportManager {
private SimplyPlugin plugin;
private YamlConfiguration permEx;
public ImportPermEx(SimplyPlugin plugin) {
super(plugin);
this.plugin = plugin;
this.permEx = new YamlConfiguration();
}
@Override
public void run() throws Exception {
try {
permEx.load("plugins/PermissionsEx/config.yml");
plugin.getConfig().set("debug", permEx.getBoolean("permissions.debug"));
permEx.load("plugins/PermissionsEx/" + permEx.getString("permissions.backends.file.file"));
for (String player : getKeys(permEx, "users")) {
for (String group : permEx.getStringList("users." + player + ".group")) {
addPlayerGroup(player, group);
}
for (String perm : permEx.getStringList("users." + player + ".permissions")) {
addPlayerPermission(player, perm.replace("-", ""), !perm.startsWith("-"));
}
for (String world : getKeys(permEx, "users." + player + ".permissions.worlds")) {
for (String worldperm : permEx.getStringList("users." + player + ".permissions.worlds." + world)) {
addPlayerPermission(player, world, worldperm.replace("-", ""), !worldperm.startsWith("-"));
}
}
}
for (String group : getKeys(permEx, "groups")) {
for (String perm : permEx.getStringList("groups." + group + ".permissions")) {
addGroupPermission(group, perm.replace("-", ""), !perm.startsWith("-"));
}
for (String world : getKeys(permEx, "groups." + group + ".permissions.worlds")) {
for (String worldperm : permEx.getStringList("groups." + group + ".permissions.worlds." + world)) {
addGroupPermission(group, world, worldperm.replace("-", ""), !worldperm.startsWith("-"));
}
}
for (String inherit : permEx.getStringList("groups." + group + ".inheritance")) {
addGroupInheritance(group, inherit);
}
}
} catch (Exception e) {
throw e;
}
}
}

View File

@ -20,7 +20,7 @@ public class ImportPrivileges extends SimplyAPI implements ImportManager {
public void run() throws Exception { public void run() throws Exception {
try { try {
privileges.load("plugins/Privileges/config.yml"); privileges.load("plugins/Privileges/config.yml");
String defaultGroup = privileges.getString("default_group"); setDefaultGroup(privileges.getString("default_group"));
plugin.getConfig().set("debug", privileges.getBoolean("debug")); plugin.getConfig().set("debug", privileges.getBoolean("debug"));
privileges.load("plugins/Privileges/users.yml"); privileges.load("plugins/Privileges/users.yml");
@ -28,32 +28,30 @@ public class ImportPrivileges extends SimplyAPI implements ImportManager {
addPlayerGroup(player, privileges.getString("users." + player + ".group")); addPlayerGroup(player, privileges.getString("users." + player + ".group"));
for (String permission : privileges.getStringList("users." + player + ".permissions")) { for (String permission : privileges.getStringList("users." + player + ".permissions")) {
addPlayerPermission(player, permission, !permission.contains("-")); addPlayerPermission(player, permission.replace("-", ""), !permission.startsWith("-"));
} }
for (String world : getKeys(privileges, "users." + player + ".worlds")) { for (String world : getKeys(privileges, "users." + player + ".worlds")) {
for (String worldpermission : privileges.getStringList("users." + player + ".worlds." + world)) { for (String worldpermission : privileges.getStringList("users." + player + ".worlds." + world)) {
addPlayerPermission(player, world, worldpermission, !worldpermission.contains("-")); addPlayerPermission(player, world, worldpermission.replace("-", ""), !worldpermission.startsWith("-"));
} }
} }
} }
privileges.load("plugins/Privileges/groups.yml"); privileges.load("plugins/Privileges/groups.yml");
for (String group : getKeys(privileges, "groups")) { for (String group : getKeys(privileges, "groups")) {
String simplyGroup = (group.equals(defaultGroup)) ? "default" : group;
for (String permission : privileges.getStringList("groups." + group + ".permissions")) { for (String permission : privileges.getStringList("groups." + group + ".permissions")) {
addGroupPermission(simplyGroup, permission, !permission.contains("-")); addGroupPermission(group, permission.replace("-", ""), !permission.startsWith("-"));
} }
for (String world : getKeys(privileges, "groups." + group + ".worlds")) { for (String world : getKeys(privileges, "groups." + group + ".worlds")) {
for (String worldpermission : privileges.getStringList("groups." + group + ".worlds." + world)) { for (String worldpermission : privileges.getStringList("groups." + group + ".worlds." + world)) {
addGroupPermission(simplyGroup, world, worldpermission, !worldpermission.contains("-")); addGroupPermission(group, world, worldpermission.replace("-", ""), !worldpermission.startsWith("-"));
} }
} }
for (String inherit : privileges.getStringList("groups." + group + ".inheritance")) { for (String inherit : privileges.getStringList("groups." + group + ".inheritance")) {
addGroupInheritance(simplyGroup, inherit); addGroupInheritance(group, inherit);
} }
} }
} catch (Exception e) { } catch (Exception e) {

View File

@ -35,7 +35,7 @@ public class ConfigFile implements PermsConfig {
@Override @Override
public void addPlayerGroup(String player, String group) { public void addPlayerGroup(String player, String group) {
if (group.isEmpty() || group.equals("default")) return; if (group.isEmpty()) return;
List<String> groups = getPlayerGroups(player); List<String> groups = getPlayerGroups(player);
if (!groups.contains(group)) groups.add(group); if (!groups.contains(group)) groups.add(group);
plugin.getConfig().set("users/" + player + "/groups", groups); plugin.getConfig().set("users/" + player + "/groups", groups);
@ -108,8 +108,8 @@ public class ConfigFile implements PermsConfig {
public Map<String, Boolean> getPlayerPermissions(String player, String world) { public Map<String, Boolean> getPlayerPermissions(String player, String world) {
Map<String, Boolean> finalPerms = new HashMap<String, Boolean>(); Map<String, Boolean> finalPerms = new HashMap<String, Boolean>();
String permNode = (!world.isEmpty()) ? "users/" + player + "/worlds/" + world : "users/" + player + "/permissions"; String permNode = (!world.isEmpty()) ? "users/" + player + "/worlds/" + world : "users/" + player + "/permissions";
if (plugin.getConfig().getConfigurationSection(permNode) != null) { if (plugin.getNode(permNode) != null) {
for (Entry<String, Object> permPlayer : plugin.getConfig().getConfigurationSection(permNode).getValues(false).entrySet()) { for (Entry<String, Object> permPlayer : plugin.getNode(permNode).getValues(false).entrySet()) {
finalPerms.put(permPlayer.getKey(), (Boolean) permPlayer.getValue()); finalPerms.put(permPlayer.getKey(), (Boolean) permPlayer.getValue());
} }
} }
@ -118,13 +118,13 @@ public class ConfigFile implements PermsConfig {
@Override @Override
public boolean isPlayerInDB(String player) { public boolean isPlayerInDB(String player) {
return plugin.getConfig().getConfigurationSection("users/" + player) != null; return plugin.getNode("users/" + player) != null;
} }
@Override @Override
public List<String> getPlayerWorlds(String player) { public List<String> getPlayerWorlds(String player) {
if (plugin.getConfig().getConfigurationSection("users/" + player + "/worlds") != null) { if (plugin.getNode("users/" + player + "/worlds") != null) {
return new ArrayList<String>(plugin.getConfig().getConfigurationSection("users/" + player + "/worlds").getKeys(false)); return new ArrayList<String>(plugin.getNode("users/" + player + "/worlds").getKeys(false));
} }
else { else {
return new ArrayList<String>(); return new ArrayList<String>();
@ -133,8 +133,8 @@ public class ConfigFile implements PermsConfig {
@Override @Override
public List<String> getAllPlayers() { public List<String> getAllPlayers() {
if (plugin.getConfig().getConfigurationSection("users") != null) { if (plugin.getNode("users") != null) {
return new ArrayList<String>(plugin.getConfig().getConfigurationSection("users").getKeys(false)); return new ArrayList<String>(plugin.getNode("users").getKeys(false));
} }
else { else {
return new ArrayList<String>(); return new ArrayList<String>();

0
net/crystalyx/bukkit/simplyperms/preventions/Bow.java Executable file → Normal file
View File

View File

0
net/crystalyx/bukkit/simplyperms/preventions/Chat.java Executable file → Normal file
View File

View File

View File

View File

View File

0
net/crystalyx/bukkit/simplyperms/preventions/Item.java Executable file → Normal file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

3
plugin.yml Executable file → Normal file
View File

@ -2,7 +2,8 @@ name: SimplyPerms
main: net.crystalyx.bukkit.simplyperms.SimplyPlugin main: net.crystalyx.bukkit.simplyperms.SimplyPlugin
author: Xefir Destiny author: Xefir Destiny
website: http://www.crystalyx.net/ website: http://www.crystalyx.net/
version: 1.6.1 version: 1.6.2
softdepend: [ PermissionsBukkit, Privileges, GroupManager, PermissionsEx, bPermissions, zPermissions ]
commands: commands:
permissions: permissions:
aliases: [ perms, perm, p ] aliases: [ perms, perm, p ]