Cleanup formatting.

This commit is contained in:
Wizjany 2011-09-27 03:32:46 -04:00
parent 4f80e78a7e
commit 2d7c462477
10 changed files with 141 additions and 144 deletions

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
package com.sk89q.bukkit.migration;
@ -28,9 +28,9 @@ import org.bukkit.util.config.Configuration;
public class ConfigurationPermissionsResolver implements PermissionsResolver {
private Configuration config;
private Map<String,Set<String>> userPermissionsCache;
private Map<String, Set<String>> userPermissionsCache;
private Set<String> defaultPermissionsCache;
private Map<String,Set<String>> userGroups;
private Map<String, Set<String>> userGroups;
public ConfigurationPermissionsResolver(Configuration config) {
this.config = config;
@ -44,14 +44,15 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
config.setProperty("permissions.groups.admins.permissions", new String[]{"*"});
config.setProperty("permissions.users.sk89q.permissions", new String[]{"worldedit.*"});
config.setProperty("permissions.users.sk89q.groups", new String[]{"admins"});
}
public void load() {
userGroups = new HashMap<String,Set<String>>();
userPermissionsCache = new HashMap<String,Set<String>>();
userGroups = new HashMap<String, Set<String>>();
userPermissionsCache = new HashMap<String, Set<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");

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
package com.sk89q.bukkit.migration;
@ -37,7 +37,7 @@ public class DinnerPermsResolver implements PermissionsResolver {
}
public static PermissionsResolver factory(Server server, Configuration config) {
if(!config.getBoolean("dinnerperms", true)){
if (!config.getBoolean("dinnerperms", true)) {
return null;
}
@ -98,5 +98,4 @@ public class DinnerPermsResolver implements PermissionsResolver {
return "Using the Bukkit Permissions API.";
}
}

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
package com.sk89q.bukkit.migration;
@ -32,25 +32,25 @@ import org.bukkit.Server;
import org.bukkit.util.config.Configuration;
public class FlatFilePermissionsResolver implements PermissionsResolver {
private Map<String,Set<String>> userPermissionsCache;
private Map<String, Set<String>> userPermissionsCache;
private Set<String> defaultPermissionsCache;
private Map<String,Set<String>> userGroups;
private Map<String, Set<String>> userGroups;
protected File groupFile;
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 users = new File("perms_users.txt");
if(!groups.exists() || !users.exists()){
if (!groups.exists() || !users.exists()) {
return null;
}
return new FlatFilePermissionsResolver(groups, users);
}
public FlatFilePermissionsResolver(){
public FlatFilePermissionsResolver() {
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();
}
public Map<String,Set<String>> loadGroupPermissions() {
Map<String,Set<String>> userGroupPermissions = new HashMap<String,Set<String>>();
public Map<String, Set<String>> loadGroupPermissions() {
Map<String, Set<String>> userGroupPermissions = new HashMap<String, Set<String>>();
FileReader input = null;
@ -110,11 +110,11 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
}
public void load() {
userGroups = new HashMap<String,Set<String>>();
userPermissionsCache = new HashMap<String,Set<String>>();
userGroups = new HashMap<String, Set<String>>();
userPermissionsCache = new HashMap<String, Set<String>>();
defaultPermissionsCache = new HashSet<String>();
Map<String,Set<String>> userGroupPermissions = loadGroupPermissions();
Map<String, Set<String>> userGroupPermissions = loadGroupPermissions();
if (userGroupPermissions.containsKey("default")) {
defaultPermissionsCache = userGroupPermissions.get("default");

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
package com.sk89q.bukkit.migration;
@ -38,16 +38,16 @@ public class NijiPermissionsResolver implements PermissionsResolver {
Plugin plugin = pluginManager.getPlugin("Permissions");
// Check if plugin is loaded and have Permissions interface
if(plugin == null || !(plugin instanceof Permissions)){
if (plugin == null || !(plugin instanceof Permissions)) {
return null;
}
// 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 new NijiPermissionsResolver(server, (Permissions)plugin);
return new NijiPermissionsResolver(server, (Permissions) plugin);
}
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) {
try {
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) {
try {
Player player = server.getPlayer(name);
@ -114,8 +114,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
groups = api.getHandler().getGroups(player.getWorld().getName(), player.getName());
} catch (Throwable t) {
String group = api.Security.getGroup(player.getWorld().getName(), player.getName());
if (group != null)
groups = new String[] {group};
if (group != null) groups = new String[] { group };
}
if (groups == null) {
return new String[0];
@ -144,7 +143,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
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");
return !(permsCommand.getPlugin().equals(plugin));

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
package com.sk89q.bukkit.migration;
@ -31,10 +31,10 @@ public class PermissionsExResolver implements PermissionsResolver {
private final PermissionManager manager;
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);
if(manager == null){
if (manager == null) {
return null;
}

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
package com.sk89q.bukkit.migration;

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
package com.sk89q.bukkit.migration;

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
package com.sk89q.bukkit.migration;
@ -59,7 +59,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
private String name;
private Logger logger;
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[]{
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[] {
PluginPermissionsResolver.class,
PermissionsExResolver.class,
NijiPermissionsResolver.class,
@ -87,13 +87,13 @@ public class PermissionsResolverManager implements PermissionsResolver {
}
public void findResolver() {
for (Class resolverClass : availableResolvers){
for (Class resolverClass : availableResolvers) {
try {
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());
return;
}
@ -156,7 +156,6 @@ public class PermissionsResolverManager implements PermissionsResolver {
config.setProperty("ignore-nijiperms-bridges", true);
isUpdated = true;
}
if (keys.contains("dinner-perms")) {
config.removeProperty("dinner-perms");
isUpdated = true;

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
package com.sk89q.bukkit.migration;
@ -82,5 +82,4 @@ public class PermissionsResolverServerListener extends ServerListener {
manager.setServerListener(this);
}
}

View File

@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
package com.sk89q.bukkit.migration;
@ -29,18 +29,18 @@ public class PluginPermissionsResolver implements PermissionsResolver {
protected PermissionsProvider resolver;
protected Plugin plugin;
public static PermissionsResolver factory(Server server, Configuration config){
public static PermissionsResolver factory(Server server, Configuration config) {
// Looking for service
RegisteredServiceProvider<PermissionsProvider> serviceProvider = server.getServicesManager().getRegistration(PermissionsProvider.class);
if(serviceProvider != null){
if (serviceProvider != null) {
return new PluginPermissionsResolver(serviceProvider.getProvider(), serviceProvider.getPlugin());
}
// Looking for plugin
for (Plugin plugin : server.getPluginManager().getPlugins()) {
if(plugin instanceof PermissionsProvider){
return new PluginPermissionsResolver((PermissionsProvider)plugin, plugin);
if (plugin instanceof PermissionsProvider) {
return new PluginPermissionsResolver((PermissionsProvider) plugin, plugin);
}
}