Fix various code issues as detected by Sonar
Mostly minor changes: - Add deprecated javadoc tag on deprecated members - Reduce duplication (FlatFile, BackupService, ...) - Make methods static - Reduce size of anonymous classes - Replace name with displayName in PermissionsSystemType (avoids confusing with Enum name()) - Tabs to spaces - Merge if statements Code from third-party sources (BCryptService, BinTools, PHPBB) not modified.
This commit is contained in:
@@ -31,7 +31,8 @@ public class AuthGroupHandler implements Reloadable {
|
||||
private String unregisteredGroup;
|
||||
private String registeredGroup;
|
||||
|
||||
AuthGroupHandler() { }
|
||||
AuthGroupHandler() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the group of a player, by its AuthMe group type.
|
||||
|
||||
@@ -78,12 +78,12 @@ public class PermissionsManager implements Reloadable {
|
||||
if (handler != null) {
|
||||
// Show a success message and return
|
||||
this.handler = handler;
|
||||
ConsoleLogger.info("Hooked into " + type.getName() + "!");
|
||||
ConsoleLogger.info("Hooked into " + type.getDisplayName() + "!");
|
||||
return;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// An error occurred, show a warning message
|
||||
ConsoleLogger.logException("Error while hooking into " + type.getName(), ex);
|
||||
ConsoleLogger.logException("Error while hooking into " + type.getDisplayName(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public class PermissionsManager implements Reloadable {
|
||||
|
||||
// Make sure the plugin is enabled before hooking
|
||||
if (!plugin.isEnabled()) {
|
||||
ConsoleLogger.info("Not hooking into " + type.getName() + " because it's disabled!");
|
||||
ConsoleLogger.info("Not hooking into " + type.getDisplayName() + " because it's disabled!");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ public class PermissionsManager implements Reloadable {
|
||||
*/
|
||||
public boolean setGroups(Player player, List<String> groupNames) {
|
||||
// If no permissions system is used or if there's no group supplied, return false
|
||||
if (!isEnabled() || groupNames.size() <= 0)
|
||||
if (!isEnabled() || groupNames.isEmpty())
|
||||
return false;
|
||||
|
||||
// Set the main group
|
||||
|
||||
@@ -33,21 +33,21 @@ public enum PermissionsSystemType {
|
||||
/**
|
||||
* The display name of the permissions system.
|
||||
*/
|
||||
public String name;
|
||||
private String displayName;
|
||||
|
||||
/**
|
||||
* The name of the permissions system plugin.
|
||||
*/
|
||||
public String pluginName;
|
||||
private String pluginName;
|
||||
|
||||
/**
|
||||
* Constructor for PermissionsSystemType.
|
||||
*
|
||||
* @param name Display name of the permissions system.
|
||||
* @param displayName Display name of the permissions system.
|
||||
* @param pluginName Name of the plugin.
|
||||
*/
|
||||
PermissionsSystemType(String name, String pluginName) {
|
||||
this.name = name;
|
||||
PermissionsSystemType(String displayName, String pluginName) {
|
||||
this.displayName = displayName;
|
||||
this.pluginName = pluginName;
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ public enum PermissionsSystemType {
|
||||
*
|
||||
* @return Display name.
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +76,7 @@ public enum PermissionsSystemType {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
return getDisplayName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,7 +55,7 @@ public class BPermissionsHandler implements PermissionHandler {
|
||||
List<String> groups = getGroups(player);
|
||||
|
||||
// Make sure there is any group available, or return null
|
||||
if (groups.size() == 0)
|
||||
if (groups.isEmpty())
|
||||
return null;
|
||||
|
||||
// Return the first group
|
||||
|
||||
@@ -54,7 +54,7 @@ public class PermissionsBukkitHandler implements PermissionHandler {
|
||||
List<String> groups = getGroups(player);
|
||||
|
||||
// Make sure there is any group available, or return null
|
||||
if (groups.size() == 0)
|
||||
if (groups.isEmpty())
|
||||
return null;
|
||||
|
||||
// Return the first group
|
||||
|
||||
@@ -77,7 +77,7 @@ public class PermissionsExHandler implements PermissionHandler {
|
||||
PermissionUser user = permissionManager.getUser(player);
|
||||
|
||||
List<String> groups = user.getParentIdentifiers(null);
|
||||
if (groups.size() == 0)
|
||||
if (groups.isEmpty())
|
||||
return null;
|
||||
|
||||
return groups.get(0);
|
||||
|
||||
Reference in New Issue
Block a user