mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Cleanup formatting.
This commit is contained in:
parent
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,9 +28,9 @@ 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,14 +44,15 @@ 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");
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,5 +98,4 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
|||||||
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,25 +32,25 @@ 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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,8 +64,8 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
|||||||
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;
|
||||||
|
|
||||||
@ -110,11 +110,11 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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");
|
||||||
|
@ -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;
|
||||||
|
|
||||||
@ -38,16 +38,16 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
|||||||
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() {
|
||||||
@ -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];
|
||||||
@ -144,7 +143,7 @@ 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;
|
||||||
|
|
||||||
@ -31,10 +31,10 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,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,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;
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
|||||||
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,
|
||||||
@ -87,13 +87,13 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -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;
|
||||||
|
@ -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;
|
||||||
|
|
||||||
@ -82,5 +82,4 @@ public class PermissionsResolverServerListener extends ServerListener {
|
|||||||
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;
|
||||||
|
|
||||||
@ -29,18 +29,18 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user