Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-05 19:10:07 +01:00
Cleanup formatting.
Dieser Commit ist enthalten in:
Ursprung
4f80e78a7e
Commit
2d7c462477
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.bukkit.migration;
|
package com.sk89q.bukkit.migration;
|
||||||
|
|
||||||
@ -28,10 +28,10 @@ import org.bukkit.util.config.Configuration;
|
|||||||
|
|
||||||
public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||||
private Configuration config;
|
private Configuration config;
|
||||||
private Map<String,Set<String>> userPermissionsCache;
|
private Map<String, Set<String>> userPermissionsCache;
|
||||||
private Set<String> defaultPermissionsCache;
|
private Set<String> defaultPermissionsCache;
|
||||||
private Map<String,Set<String>> userGroups;
|
private Map<String, Set<String>> userGroups;
|
||||||
|
|
||||||
public ConfigurationPermissionsResolver(Configuration config) {
|
public ConfigurationPermissionsResolver(Configuration config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
@ -44,50 +44,51 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
|||||||
config.setProperty("permissions.groups.admins.permissions", new String[]{"*"});
|
config.setProperty("permissions.groups.admins.permissions", new String[]{"*"});
|
||||||
config.setProperty("permissions.users.sk89q.permissions", new String[]{"worldedit.*"});
|
config.setProperty("permissions.users.sk89q.permissions", new String[]{"worldedit.*"});
|
||||||
config.setProperty("permissions.users.sk89q.groups", new String[]{"admins"});
|
config.setProperty("permissions.users.sk89q.groups", new String[]{"admins"});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
userGroups = new HashMap<String,Set<String>>();
|
userGroups = new HashMap<String, Set<String>>();
|
||||||
userPermissionsCache = new HashMap<String,Set<String>>();
|
userPermissionsCache = new HashMap<String, Set<String>>();
|
||||||
defaultPermissionsCache = new HashSet<String>();
|
defaultPermissionsCache = new HashSet<String>();
|
||||||
|
|
||||||
Map<String,Set<String>> userGroupPermissions = new HashMap<String,Set<String>>();
|
Map<String, Set<String>> userGroupPermissions = new HashMap<String, Set<String>>();
|
||||||
|
|
||||||
List<String> groupKeys = config.getKeys("permissions.groups");
|
List<String> groupKeys = config.getKeys("permissions.groups");
|
||||||
|
|
||||||
if (groupKeys != null) {
|
if (groupKeys != null) {
|
||||||
for (String key : groupKeys) {
|
for (String key : groupKeys) {
|
||||||
List<String> permissions =
|
List<String> permissions =
|
||||||
config.getStringList("permissions.groups." + key + ".permissions", null);
|
config.getStringList("permissions.groups." + key + ".permissions", null);
|
||||||
|
|
||||||
if (permissions.size() > 0) {
|
if (permissions.size() > 0) {
|
||||||
Set<String> groupPerms = new HashSet<String>(permissions);
|
Set<String> groupPerms = new HashSet<String>(permissions);
|
||||||
userGroupPermissions.put(key, groupPerms);
|
userGroupPermissions.put(key, groupPerms);
|
||||||
|
|
||||||
if (key.equals("default")) {
|
if (key.equals("default")) {
|
||||||
defaultPermissionsCache.addAll(permissions);
|
defaultPermissionsCache.addAll(permissions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> userKeys = config.getKeys("permissions.users");
|
List<String> userKeys = config.getKeys("permissions.users");
|
||||||
|
|
||||||
if (userKeys != null) {
|
if (userKeys != null) {
|
||||||
for (String key : userKeys) {
|
for (String key : userKeys) {
|
||||||
Set<String> permsCache = new HashSet<String>();
|
Set<String> permsCache = new HashSet<String>();
|
||||||
|
|
||||||
List<String> permissions =
|
List<String> permissions =
|
||||||
config.getStringList("permissions.users." + key + ".permissions", null);
|
config.getStringList("permissions.users." + key + ".permissions", null);
|
||||||
|
|
||||||
if (permissions.size() > 0) {
|
if (permissions.size() > 0) {
|
||||||
permsCache.addAll(permissions);
|
permsCache.addAll(permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> groups =
|
List<String> groups =
|
||||||
config.getStringList("permissions.users." + key + ".groups", null);
|
config.getStringList("permissions.users." + key + ".groups", null);
|
||||||
groups.add("default");
|
groups.add("default");
|
||||||
|
|
||||||
if (groups.size() > 0) {
|
if (groups.size() > 0) {
|
||||||
for (String group : groups) {
|
for (String group : groups) {
|
||||||
Set<String> groupPerms = userGroupPermissions.get(group);
|
Set<String> groupPerms = userGroupPermissions.get(group);
|
||||||
@ -102,7 +103,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(String player, String permission) {
|
public boolean hasPermission(String player, String permission) {
|
||||||
int dotPos = permission.lastIndexOf(".");
|
int dotPos = permission.lastIndexOf(".");
|
||||||
if (dotPos > -1) {
|
if (dotPos > -1) {
|
||||||
@ -110,19 +111,19 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> perms = userPermissionsCache.get(player.toLowerCase());
|
Set<String> perms = userPermissionsCache.get(player.toLowerCase());
|
||||||
if (perms == null) {
|
if (perms == null) {
|
||||||
return defaultPermissionsCache.contains(permission)
|
return defaultPermissionsCache.contains(permission)
|
||||||
|| defaultPermissionsCache.contains("*");
|
|| defaultPermissionsCache.contains("*");
|
||||||
}
|
}
|
||||||
|
|
||||||
return perms.contains("*") || perms.contains(permission);
|
return perms.contains("*") || perms.contains(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(String worldName, String player, String permission) {
|
public boolean hasPermission(String worldName, String player, String permission) {
|
||||||
return hasPermission(player, "worlds." + worldName + "." + permission)
|
return hasPermission(player, "worlds." + worldName + "." + permission)
|
||||||
|| hasPermission(player, permission);
|
|| hasPermission(player, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inGroup(String player, String group) {
|
public boolean inGroup(String player, String group) {
|
||||||
@ -130,21 +131,21 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
|||||||
if (groups == null) {
|
if (groups == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups.contains(group);
|
return groups.contains(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getGroups(String player) {
|
public String[] getGroups(String player) {
|
||||||
Set<String> groups = userGroups.get(player.toLowerCase());
|
Set<String> groups = userGroups.get(player.toLowerCase());
|
||||||
if (groups == null) {
|
if (groups == null) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups.toArray(new String[groups.size()]);
|
return groups.toArray(new String[groups.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDetectionMessage() {
|
public String getDetectionMessage() {
|
||||||
return "No known permissions plugin detected. Using configuration file for permissions.";
|
return "No known permissions plugin detected. Using configuration file for permissions.";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.bukkit.migration;
|
package com.sk89q.bukkit.migration;
|
||||||
|
|
||||||
@ -35,15 +35,15 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
|||||||
public DinnerPermsResolver(Server server) {
|
public DinnerPermsResolver(Server server) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PermissionsResolver factory(Server server, Configuration config) {
|
public static PermissionsResolver factory(Server server, Configuration config) {
|
||||||
if(!config.getBoolean("dinnerperms", true)){
|
if (!config.getBoolean("dinnerperms", true)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DinnerPermsResolver(server);
|
return new DinnerPermsResolver(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
// Permissions are already loaded
|
// Permissions are already loaded
|
||||||
}
|
}
|
||||||
@ -97,6 +97,5 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
|||||||
public String getDetectionMessage() {
|
public String getDetectionMessage() {
|
||||||
return "Using the Bukkit Permissions API.";
|
return "Using the Bukkit Permissions API.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.bukkit.migration;
|
package com.sk89q.bukkit.migration;
|
||||||
|
|
||||||
@ -32,40 +32,40 @@ import org.bukkit.Server;
|
|||||||
import org.bukkit.util.config.Configuration;
|
import org.bukkit.util.config.Configuration;
|
||||||
|
|
||||||
public class FlatFilePermissionsResolver implements PermissionsResolver {
|
public class FlatFilePermissionsResolver implements PermissionsResolver {
|
||||||
private Map<String,Set<String>> userPermissionsCache;
|
private Map<String, Set<String>> userPermissionsCache;
|
||||||
private Set<String> defaultPermissionsCache;
|
private Set<String> defaultPermissionsCache;
|
||||||
private Map<String,Set<String>> userGroups;
|
private Map<String, Set<String>> userGroups;
|
||||||
|
|
||||||
protected File groupFile;
|
protected File groupFile;
|
||||||
protected File userFile;
|
protected File userFile;
|
||||||
|
|
||||||
public static PermissionsResolver factory(Server server, Configuration config){
|
public static PermissionsResolver factory(Server server, Configuration config) {
|
||||||
File groups = new File("perms_groups.txt");
|
File groups = new File("perms_groups.txt");
|
||||||
File users = new File("perms_users.txt");
|
File users = new File("perms_users.txt");
|
||||||
|
|
||||||
if(!groups.exists() || !users.exists()){
|
if (!groups.exists() || !users.exists()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FlatFilePermissionsResolver(groups, users);
|
return new FlatFilePermissionsResolver(groups, users);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlatFilePermissionsResolver(){
|
public FlatFilePermissionsResolver() {
|
||||||
this(new File("perms_groups.txt"), new File("perms_users.txt"));
|
this(new File("perms_groups.txt"), new File("perms_users.txt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlatFilePermissionsResolver(File groupFile, File userFile) {
|
public FlatFilePermissionsResolver(File groupFile, File userFile) {
|
||||||
this.groupFile = groupFile;
|
this.groupFile = groupFile;
|
||||||
this.userFile = userFile;
|
this.userFile = userFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static boolean filesExists() {
|
public static boolean filesExists() {
|
||||||
return (new File("perms_groups.txt")).exists() && (new File("perms_users.txt")).exists();
|
return (new File("perms_groups.txt")).exists() && (new File("perms_users.txt")).exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String,Set<String>> loadGroupPermissions() {
|
public Map<String, Set<String>> loadGroupPermissions() {
|
||||||
Map<String,Set<String>> userGroupPermissions = new HashMap<String,Set<String>>();
|
Map<String, Set<String>> userGroupPermissions = new HashMap<String, Set<String>>();
|
||||||
|
|
||||||
FileReader input = null;
|
FileReader input = null;
|
||||||
|
|
||||||
@ -83,11 +83,11 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
|||||||
} else if (line.charAt(0) == ';' || line.charAt(0) == '#') {
|
} else if (line.charAt(0) == ';' || line.charAt(0) == '#') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] parts = line.split(":");
|
String[] parts = line.split(":");
|
||||||
|
|
||||||
String key = parts[0];
|
String key = parts[0];
|
||||||
|
|
||||||
if (parts.length > 1) {
|
if (parts.length > 1) {
|
||||||
String[] perms = parts[1].split(",");
|
String[] perms = parts[1].split(",");
|
||||||
|
|
||||||
@ -105,17 +105,17 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
|||||||
} catch (IOException e2) {
|
} catch (IOException e2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return userGroupPermissions;
|
return userGroupPermissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
userGroups = new HashMap<String,Set<String>>();
|
userGroups = new HashMap<String, Set<String>>();
|
||||||
userPermissionsCache = new HashMap<String,Set<String>>();
|
userPermissionsCache = new HashMap<String, Set<String>>();
|
||||||
defaultPermissionsCache = new HashSet<String>();
|
defaultPermissionsCache = new HashSet<String>();
|
||||||
|
|
||||||
Map<String,Set<String>> userGroupPermissions = loadGroupPermissions();
|
Map<String, Set<String>> userGroupPermissions = loadGroupPermissions();
|
||||||
|
|
||||||
if (userGroupPermissions.containsKey("default")) {
|
if (userGroupPermissions.containsKey("default")) {
|
||||||
defaultPermissionsCache = userGroupPermissions.get("default");
|
defaultPermissionsCache = userGroupPermissions.get("default");
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
|||||||
String line;
|
String line;
|
||||||
while ((line = buff.readLine()) != null) {
|
while ((line = buff.readLine()) != null) {
|
||||||
Set<String> permsCache = new HashSet<String>();
|
Set<String> permsCache = new HashSet<String>();
|
||||||
|
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
|
|
||||||
// Blank line
|
// Blank line
|
||||||
@ -138,11 +138,11 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
|||||||
} else if (line.charAt(0) == ';' || line.charAt(0) == '#') {
|
} else if (line.charAt(0) == ';' || line.charAt(0) == '#') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] parts = line.split(":");
|
String[] parts = line.split(":");
|
||||||
|
|
||||||
String key = parts[0];
|
String key = parts[0];
|
||||||
|
|
||||||
if (parts.length > 1) {
|
if (parts.length > 1) {
|
||||||
String[] groups = (parts[1] + ",default").split(",");
|
String[] groups = (parts[1] + ",default").split(",");
|
||||||
String[] perms = parts.length > 2 ? parts[2].split(",") : new String[0];
|
String[] perms = parts.length > 2 ? parts[2].split(",") : new String[0];
|
||||||
@ -171,7 +171,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(String player, String permission) {
|
public boolean hasPermission(String player, String permission) {
|
||||||
int dotPos = permission.lastIndexOf(".");
|
int dotPos = permission.lastIndexOf(".");
|
||||||
if (dotPos > -1) {
|
if (dotPos > -1) {
|
||||||
@ -179,19 +179,19 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> perms = userPermissionsCache.get(player.toLowerCase());
|
Set<String> perms = userPermissionsCache.get(player.toLowerCase());
|
||||||
if (perms == null) {
|
if (perms == null) {
|
||||||
return defaultPermissionsCache.contains(permission)
|
return defaultPermissionsCache.contains(permission)
|
||||||
|| defaultPermissionsCache.contains("*");
|
|| defaultPermissionsCache.contains("*");
|
||||||
}
|
}
|
||||||
|
|
||||||
return perms.contains("*") || perms.contains(permission);
|
return perms.contains("*") || perms.contains(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(String worldName, String player, String permission) {
|
public boolean hasPermission(String worldName, String player, String permission) {
|
||||||
return hasPermission(player, "worlds." + worldName + "." + permission)
|
return hasPermission(player, "worlds." + worldName + "." + permission)
|
||||||
|| hasPermission(player, permission);
|
|| hasPermission(player, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inGroup(String player, String group) {
|
public boolean inGroup(String player, String group) {
|
||||||
@ -199,21 +199,21 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
|||||||
if (groups == null) {
|
if (groups == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups.contains(group);
|
return groups.contains(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getGroups(String player) {
|
public String[] getGroups(String player) {
|
||||||
Set<String> groups = userGroups.get(player.toLowerCase());
|
Set<String> groups = userGroups.get(player.toLowerCase());
|
||||||
if (groups == null) {
|
if (groups == null) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups.toArray(new String[groups.size()]);
|
return groups.toArray(new String[groups.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDetectionMessage() {
|
public String getDetectionMessage() {
|
||||||
return "perms_groups.txt and perms_users.txt detected! Using flat file permissions.";
|
return "perms_groups.txt and perms_users.txt detected! Using flat file permissions.";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.bukkit.migration;
|
package com.sk89q.bukkit.migration;
|
||||||
|
|
||||||
@ -31,29 +31,29 @@ import org.bukkit.util.config.Configuration;
|
|||||||
public class NijiPermissionsResolver implements PermissionsResolver {
|
public class NijiPermissionsResolver implements PermissionsResolver {
|
||||||
private Server server;
|
private Server server;
|
||||||
private Permissions api;
|
private Permissions api;
|
||||||
|
|
||||||
public static PermissionsResolver factory(Server server, Configuration config) {
|
public static PermissionsResolver factory(Server server, Configuration config) {
|
||||||
PluginManager pluginManager = server.getPluginManager();
|
PluginManager pluginManager = server.getPluginManager();
|
||||||
|
|
||||||
Plugin plugin = pluginManager.getPlugin("Permissions");
|
Plugin plugin = pluginManager.getPlugin("Permissions");
|
||||||
|
|
||||||
// Check if plugin is loaded and have Permissions interface
|
// Check if plugin is loaded and have Permissions interface
|
||||||
if(plugin == null || !(plugin instanceof Permissions)){
|
if (plugin == null || !(plugin instanceof Permissions)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for fake permissions
|
// Check for fake permissions
|
||||||
if(config.getBoolean("ignore-nijiperms-bridges", true) && isFakeNijiPerms(plugin)){
|
if (config.getBoolean("ignore-nijiperms-bridges", true) && isFakeNijiPerms(plugin)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new NijiPermissionsResolver(server, (Permissions)plugin);
|
return new NijiPermissionsResolver(server, (Permissions) plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NijiPermissionsResolver(Server server, Permissions plugin) {
|
public NijiPermissionsResolver(Server server, Permissions plugin) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.api = plugin;
|
this.api = plugin;
|
||||||
@ -88,7 +88,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "static-access" })
|
@SuppressWarnings("static-access")
|
||||||
public boolean inGroup(String name, String group) {
|
public boolean inGroup(String name, String group) {
|
||||||
try {
|
try {
|
||||||
Player player = server.getPlayer(name);
|
Player player = server.getPlayer(name);
|
||||||
@ -104,7 +104,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "static-access" })
|
@SuppressWarnings("static-access")
|
||||||
public String[] getGroups(String name) {
|
public String[] getGroups(String name) {
|
||||||
try {
|
try {
|
||||||
Player player = server.getPlayer(name);
|
Player player = server.getPlayer(name);
|
||||||
@ -114,8 +114,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
|||||||
groups = api.getHandler().getGroups(player.getWorld().getName(), player.getName());
|
groups = api.getHandler().getGroups(player.getWorld().getName(), player.getName());
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
String group = api.Security.getGroup(player.getWorld().getName(), player.getName());
|
String group = api.Security.getGroup(player.getWorld().getName(), player.getName());
|
||||||
if (group != null)
|
if (group != null) groups = new String[] { group };
|
||||||
groups = new String[] {group};
|
|
||||||
}
|
}
|
||||||
if (groups == null) {
|
if (groups == null) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
@ -127,7 +126,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
|||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PluginAccessException extends Exception {
|
public static class PluginAccessException extends Exception {
|
||||||
private static final long serialVersionUID = 7044832912491608706L;
|
private static final long serialVersionUID = 7044832912491608706L;
|
||||||
}
|
}
|
||||||
@ -143,10 +142,10 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
|||||||
}
|
}
|
||||||
return permsCommand.getPlugin().getDescription().getName().equals("Permissions");
|
return permsCommand.getPlugin().getDescription().getName().equals("Permissions");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFakeNijiPerms(Plugin plugin){
|
public static boolean isFakeNijiPerms(Plugin plugin) {
|
||||||
PluginCommand permsCommand = Bukkit.getServer().getPluginCommand("permissions");
|
PluginCommand permsCommand = Bukkit.getServer().getPluginCommand("permissions");
|
||||||
|
|
||||||
return !(permsCommand.getPlugin().equals(plugin));
|
return !(permsCommand.getPlugin().equals(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.bukkit.migration;
|
package com.sk89q.bukkit.migration;
|
||||||
|
|
||||||
@ -30,17 +30,17 @@ import org.bukkit.util.config.Configuration;
|
|||||||
public class PermissionsExResolver implements PermissionsResolver {
|
public class PermissionsExResolver implements PermissionsResolver {
|
||||||
private final PermissionManager manager;
|
private final PermissionManager manager;
|
||||||
private final Server server;
|
private final Server server;
|
||||||
|
|
||||||
public static PermissionsResolver factory(Server server, Configuration config){
|
public static PermissionsResolver factory(Server server, Configuration config) {
|
||||||
PermissionManager manager = server.getServicesManager().load(PermissionManager.class);
|
PermissionManager manager = server.getServicesManager().load(PermissionManager.class);
|
||||||
|
|
||||||
if(manager == null){
|
if (manager == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PermissionsExResolver(server, manager);
|
return new PermissionsExResolver(server, manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PermissionsExResolver(Server server, PermissionManager manager) {
|
public PermissionsExResolver(Server server, PermissionManager manager) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.bukkit.migration;
|
package com.sk89q.bukkit.migration;
|
||||||
|
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.bukkit.migration;
|
package com.sk89q.bukkit.migration;
|
||||||
|
|
||||||
public interface PermissionsResolver extends PermissionsProvider {
|
public interface PermissionsResolver extends PermissionsProvider {
|
||||||
public void load();
|
public void load();
|
||||||
|
|
||||||
public String getDetectionMessage();
|
public String getDetectionMessage();
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.bukkit.migration;
|
package com.sk89q.bukkit.migration;
|
||||||
|
|
||||||
@ -58,8 +58,8 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
|||||||
private Configuration config;
|
private Configuration config;
|
||||||
private String name;
|
private String name;
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[]{
|
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[] {
|
||||||
PluginPermissionsResolver.class,
|
PluginPermissionsResolver.class,
|
||||||
PermissionsExResolver.class,
|
PermissionsExResolver.class,
|
||||||
NijiPermissionsResolver.class,
|
NijiPermissionsResolver.class,
|
||||||
@ -81,19 +81,19 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.listener = new PermissionsResolverServerListener(this, plugin);
|
this.listener = new PermissionsResolverServerListener(this, plugin);
|
||||||
|
|
||||||
loadConfig(new File("wepif.yml"));
|
loadConfig(new File("wepif.yml"));
|
||||||
findResolver();
|
findResolver();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void findResolver() {
|
public void findResolver() {
|
||||||
for (Class resolverClass : availableResolvers){
|
for (Class resolverClass : availableResolvers) {
|
||||||
try {
|
try {
|
||||||
Method factoryMethod = resolverClass.getMethod("factory", Server.class, Configuration.class);
|
Method factoryMethod = resolverClass.getMethod("factory", Server.class, Configuration.class);
|
||||||
|
|
||||||
this.permissionResolver = (PermissionsResolver)factoryMethod.invoke(null, this.server, this.config);
|
this.permissionResolver = (PermissionsResolver) factoryMethod.invoke(null, this.server, this.config);
|
||||||
|
|
||||||
if(this.permissionResolver != null){
|
if (this.permissionResolver != null) {
|
||||||
logger.info(name + ": " + this.permissionResolver.getDetectionMessage());
|
logger.info(name + ": " + this.permissionResolver.getDetectionMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -105,12 +105,12 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
|||||||
permissionResolver = new ConfigurationPermissionsResolver(config);
|
permissionResolver = new ConfigurationPermissionsResolver(config);
|
||||||
logger.info(name + ": No known permissions plugin detected. Using configuration file for permissions.");
|
logger.info(name + ": No known permissions plugin detected. Using configuration file for permissions.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPluginPermissionsResolver(Plugin plugin) {
|
public void setPluginPermissionsResolver(Plugin plugin) {
|
||||||
if (!(plugin instanceof PermissionsProvider)) {
|
if (!(plugin instanceof PermissionsProvider)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
permissionResolver = new PluginPermissionsResolver((PermissionsProvider) plugin, plugin);
|
permissionResolver = new PluginPermissionsResolver((PermissionsProvider) plugin, plugin);
|
||||||
logger.info(name + ": Using plugin '" + plugin.getDescription().getName() + "' for permissions.");
|
logger.info(name + ": Using plugin '" + plugin.getDescription().getName() + "' for permissions.");
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
|||||||
config = new Configuration(file);
|
config = new Configuration(file);
|
||||||
config.load();
|
config.load();
|
||||||
List<String> keys = config.getKeys();
|
List<String> keys = config.getKeys();
|
||||||
config.setHeader(CONFIG_HEADER);
|
config.setHeader(CONFIG_HEADER);
|
||||||
if (!keys.contains("dinnerperms")) {
|
if (!keys.contains("dinnerperms")) {
|
||||||
config.setProperty("dinnerperms", config.getBoolean("dinner-perms", true));
|
config.setProperty("dinnerperms", config.getBoolean("dinner-perms", true));
|
||||||
isUpdated = true;
|
isUpdated = true;
|
||||||
@ -156,7 +156,6 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
|||||||
config.setProperty("ignore-nijiperms-bridges", true);
|
config.setProperty("ignore-nijiperms-bridges", true);
|
||||||
isUpdated = true;
|
isUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keys.contains("dinner-perms")) {
|
if (keys.contains("dinner-perms")) {
|
||||||
config.removeProperty("dinner-perms");
|
config.removeProperty("dinner-perms");
|
||||||
isUpdated = true;
|
isUpdated = true;
|
||||||
@ -179,13 +178,13 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
|||||||
void setServerListener(PermissionsResolverServerListener listener) {
|
void setServerListener(PermissionsResolverServerListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MissingPluginException extends Exception {
|
public static class MissingPluginException extends Exception {
|
||||||
private static final long serialVersionUID = 7044832912491608706L;
|
private static final long serialVersionUID = 7044832912491608706L;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDetectionMessage() {
|
public String getDetectionMessage() {
|
||||||
return "Using WEPIF for permissions";
|
return "Using WEPIF for permissions";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.bukkit.migration;
|
package com.sk89q.bukkit.migration;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ public class PermissionsResolverServerListener extends ServerListener {
|
|||||||
register(plugin);
|
register(plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a plugin is enabled
|
* Called when a plugin is enabled
|
||||||
*
|
*
|
||||||
@ -67,13 +67,13 @@ public class PermissionsResolverServerListener extends ServerListener {
|
|||||||
public void onPluginDisable(PluginDisableEvent event) {
|
public void onPluginDisable(PluginDisableEvent event) {
|
||||||
Plugin plugin = event.getPlugin();
|
Plugin plugin = event.getPlugin();
|
||||||
String name = plugin.getDescription().getName();
|
String name = plugin.getDescription().getName();
|
||||||
|
|
||||||
if (plugin instanceof PermissionsProvider || "Permissions".equals(name) || "PermissionsEx".equals(name)) {
|
if (plugin instanceof PermissionsProvider || "Permissions".equals(name) || "PermissionsEx".equals(name)) {
|
||||||
manager.findResolver();
|
manager.findResolver();
|
||||||
manager.load();
|
manager.load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(Plugin plugin) {
|
public void register(Plugin plugin) {
|
||||||
plugin.getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_ENABLE,
|
plugin.getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_ENABLE,
|
||||||
this, Priority.Normal, plugin);
|
this, Priority.Normal, plugin);
|
||||||
@ -81,6 +81,5 @@ public class PermissionsResolverServerListener extends ServerListener {
|
|||||||
this, Priority.Normal, plugin);
|
this, Priority.Normal, plugin);
|
||||||
manager.setServerListener(this);
|
manager.setServerListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.bukkit.migration;
|
package com.sk89q.bukkit.migration;
|
||||||
|
|
||||||
@ -25,31 +25,31 @@ import org.bukkit.plugin.RegisteredServiceProvider;
|
|||||||
import org.bukkit.util.config.Configuration;
|
import org.bukkit.util.config.Configuration;
|
||||||
|
|
||||||
public class PluginPermissionsResolver implements PermissionsResolver {
|
public class PluginPermissionsResolver implements PermissionsResolver {
|
||||||
|
|
||||||
protected PermissionsProvider resolver;
|
protected PermissionsProvider resolver;
|
||||||
protected Plugin plugin;
|
protected Plugin plugin;
|
||||||
|
|
||||||
public static PermissionsResolver factory(Server server, Configuration config){
|
public static PermissionsResolver factory(Server server, Configuration config) {
|
||||||
// Looking for service
|
// Looking for service
|
||||||
RegisteredServiceProvider<PermissionsProvider> serviceProvider = server.getServicesManager().getRegistration(PermissionsProvider.class);
|
RegisteredServiceProvider<PermissionsProvider> serviceProvider = server.getServicesManager().getRegistration(PermissionsProvider.class);
|
||||||
|
|
||||||
if(serviceProvider != null){
|
if (serviceProvider != null) {
|
||||||
return new PluginPermissionsResolver(serviceProvider.getProvider(), serviceProvider.getPlugin());
|
return new PluginPermissionsResolver(serviceProvider.getProvider(), serviceProvider.getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Looking for plugin
|
// Looking for plugin
|
||||||
for (Plugin plugin : server.getPluginManager().getPlugins()) {
|
for (Plugin plugin : server.getPluginManager().getPlugins()) {
|
||||||
if(plugin instanceof PermissionsProvider){
|
if (plugin instanceof PermissionsProvider) {
|
||||||
return new PluginPermissionsResolver((PermissionsProvider)plugin, plugin);
|
return new PluginPermissionsResolver((PermissionsProvider) plugin, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginPermissionsResolver(PermissionsProvider resolver, Plugin permissionsPlugin) {
|
public PluginPermissionsResolver(PermissionsProvider resolver, Plugin permissionsPlugin) {
|
||||||
this.resolver = resolver;
|
this.resolver = resolver;
|
||||||
this.plugin = permissionsPlugin;
|
this.plugin = permissionsPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
@ -74,5 +74,5 @@ public class PluginPermissionsResolver implements PermissionsResolver {
|
|||||||
public String getDetectionMessage() {
|
public String getDetectionMessage() {
|
||||||
return "Using plugin '" + this.plugin.getDescription().getName() + "' for permissions.";
|
return "Using plugin '" + this.plugin.getDescription().getName() + "' for permissions.";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren