diff --git a/bukkit/src/main/java/me/lucko/luckperms/BukkitConfig.java b/bukkit/src/main/java/me/lucko/luckperms/BukkitConfig.java index c4fb0cc9..5a847dcf 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/BukkitConfig.java +++ b/bukkit/src/main/java/me/lucko/luckperms/BukkitConfig.java @@ -16,6 +16,7 @@ public class BukkitConfig implements LPConfiguration { create(); } + @SuppressWarnings("ResultOfMethodCallIgnored") private void create() { File configFile = new File(plugin.getDataFolder(), "config.yml"); diff --git a/bukkit/src/main/java/me/lucko/luckperms/VaultHook.java b/bukkit/src/main/java/me/lucko/luckperms/VaultHook.java index 6cc6f73d..3d717740 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/VaultHook.java +++ b/bukkit/src/main/java/me/lucko/luckperms/VaultHook.java @@ -8,7 +8,7 @@ import me.lucko.luckperms.users.User; import net.milkbowl.vault.permission.Permission; @AllArgsConstructor -public class VaultHook extends Permission { +class VaultHook extends Permission { private final LPBukkitPlugin plugin; @Override @@ -90,9 +90,7 @@ public class VaultHook extends Permission { @Override public boolean playerInGroup(String world, String player, String group) { final User user = plugin.getUserManager().getUser(player); - if (user == null) return false; - - return user.getGroupNames().contains(group); + return user != null && user.getGroupNames().contains(group); } @Override diff --git a/bukkit/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java b/bukkit/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java index 2c653ec6..52ac0f5c 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java +++ b/bukkit/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java @@ -68,7 +68,7 @@ public class PlayerListener implements Listener { plugin.getUserManager().unloadUser(user); } - public static String color(String string) { + private static String color(String string) { return ChatColor.translateAlternateColorCodes('&', string); } diff --git a/bukkit/src/main/java/me/lucko/luckperms/users/BukkitUser.java b/bukkit/src/main/java/me/lucko/luckperms/users/BukkitUser.java index 128d97c4..690240d6 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/users/BukkitUser.java +++ b/bukkit/src/main/java/me/lucko/luckperms/users/BukkitUser.java @@ -18,12 +18,12 @@ public class BukkitUser extends User { @Setter private PermissionAttachment attachment = null; - public BukkitUser(UUID uuid, LPBukkitPlugin plugin) { + BukkitUser(UUID uuid, LPBukkitPlugin plugin) { super(uuid, plugin); this.plugin = plugin; } - public BukkitUser(UUID uuid, String username, LPBukkitPlugin plugin) { + BukkitUser(UUID uuid, String username, LPBukkitPlugin plugin) { super(uuid, username, plugin); this.plugin = plugin; } diff --git a/bungee/src/main/java/me/lucko/luckperms/BungeeConfig.java b/bungee/src/main/java/me/lucko/luckperms/BungeeConfig.java index 29f6eae0..c1d021c3 100644 --- a/bungee/src/main/java/me/lucko/luckperms/BungeeConfig.java +++ b/bungee/src/main/java/me/lucko/luckperms/BungeeConfig.java @@ -27,6 +27,7 @@ public class BungeeConfig implements LPConfiguration { } } + @SuppressWarnings("ResultOfMethodCallIgnored") private File makeFile(String file) throws IOException { File cfg = new File(plugin.getDataFolder(), file); diff --git a/bungee/src/main/java/me/lucko/luckperms/MainCommand.java b/bungee/src/main/java/me/lucko/luckperms/MainCommand.java index d3605250..be948c9f 100644 --- a/bungee/src/main/java/me/lucko/luckperms/MainCommand.java +++ b/bungee/src/main/java/me/lucko/luckperms/MainCommand.java @@ -8,7 +8,7 @@ import net.md_5.bungee.api.plugin.Command; import java.util.Arrays; -public class MainCommand extends Command { +class MainCommand extends Command { private final CommandManager manager; public MainCommand(CommandManager manager) { diff --git a/bungee/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java b/bungee/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java index adf5c428..b20d53b5 100644 --- a/bungee/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java +++ b/bungee/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java @@ -3,7 +3,6 @@ package me.lucko.luckperms.listeners; import lombok.AllArgsConstructor; import me.lucko.luckperms.LPBungeePlugin; import me.lucko.luckperms.commands.Util; -import me.lucko.luckperms.data.Datastore; import me.lucko.luckperms.users.User; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; diff --git a/bungee/src/main/java/me/lucko/luckperms/users/BungeeUser.java b/bungee/src/main/java/me/lucko/luckperms/users/BungeeUser.java index 64b91cf9..d2b7d589 100644 --- a/bungee/src/main/java/me/lucko/luckperms/users/BungeeUser.java +++ b/bungee/src/main/java/me/lucko/luckperms/users/BungeeUser.java @@ -12,12 +12,12 @@ public class BungeeUser extends User { private final LPBungeePlugin plugin; - public BungeeUser(UUID uuid, LPBungeePlugin plugin) { + BungeeUser(UUID uuid, LPBungeePlugin plugin) { super(uuid, plugin); this.plugin = plugin; } - public BungeeUser(UUID uuid, String username, LPBungeePlugin plugin) { + BungeeUser(UUID uuid, String username, LPBungeePlugin plugin) { super(uuid, username, plugin); this.plugin = plugin; } diff --git a/common/src/main/java/me/lucko/luckperms/commands/CommandManager.java b/common/src/main/java/me/lucko/luckperms/commands/CommandManager.java index 9d911e36..a1c0f64e 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/CommandManager.java +++ b/common/src/main/java/me/lucko/luckperms/commands/CommandManager.java @@ -105,7 +105,7 @@ public class CommandManager { } - public void registerMainCommand(MainCommand command) { + private void registerMainCommand(MainCommand command) { plugin.getLogger().log(Level.INFO, "[CommandManager] Registered main command '" + command.getName() + "'"); mainCommands.add(command); } diff --git a/common/src/main/java/me/lucko/luckperms/commands/MainCommand.java b/common/src/main/java/me/lucko/luckperms/commands/MainCommand.java index 1ca2b310..c91ca408 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/MainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/commands/MainCommand.java @@ -17,7 +17,7 @@ public abstract class MainCommand { @Getter private final int requiredArgsLength; - public MainCommand(String name, String usage, int requiredArgsLength) { + protected MainCommand(String name, String usage, int requiredArgsLength) { this.name = name; this.usage = usage; this.requiredArgsLength = requiredArgsLength; diff --git a/common/src/main/java/me/lucko/luckperms/commands/SubCommand.java b/common/src/main/java/me/lucko/luckperms/commands/SubCommand.java index 376e6f39..bd3016b2 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/SubCommand.java +++ b/common/src/main/java/me/lucko/luckperms/commands/SubCommand.java @@ -16,7 +16,7 @@ public abstract class SubCommand { @Getter private final String permission; - public SubCommand(String name, String description, String usage, String permission) { + protected SubCommand(String name, String description, String usage, String permission) { this.name = name; this.description = description; this.usage = usage; diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/GroupSubCommand.java b/common/src/main/java/me/lucko/luckperms/commands/group/GroupSubCommand.java index bf95f1ec..3ebe581f 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/GroupSubCommand.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/GroupSubCommand.java @@ -9,7 +9,7 @@ import me.lucko.luckperms.groups.Group; import java.util.List; public abstract class GroupSubCommand extends SubCommand { - public GroupSubCommand(String name, String description, String usage, String permission) { + protected GroupSubCommand(String name, String description, String usage, String permission) { super(name, description, usage, permission); } diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/UserSubCommand.java b/common/src/main/java/me/lucko/luckperms/commands/user/UserSubCommand.java index 7362579b..849daaf6 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/UserSubCommand.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/UserSubCommand.java @@ -9,7 +9,7 @@ import me.lucko.luckperms.users.User; import java.util.List; public abstract class UserSubCommand extends SubCommand { - public UserSubCommand(String name, String description, String usage, String permission) { + protected UserSubCommand(String name, String description, String usage, String permission) { super(name, description, usage, permission); } diff --git a/common/src/main/java/me/lucko/luckperms/data/Datastore.java b/common/src/main/java/me/lucko/luckperms/data/Datastore.java index b5afc31d..b70d73ff 100644 --- a/common/src/main/java/me/lucko/luckperms/data/Datastore.java +++ b/common/src/main/java/me/lucko/luckperms/data/Datastore.java @@ -12,13 +12,13 @@ public abstract class Datastore { protected final LuckPermsPlugin plugin; @Getter - public String name; + public final String name; @Getter @Setter private boolean acceptingLogins; - public Datastore(LuckPermsPlugin plugin, String name) { + protected Datastore(LuckPermsPlugin plugin, String name) { this.plugin = plugin; this.name = name; this.acceptingLogins = true; diff --git a/common/src/main/java/me/lucko/luckperms/data/methods/MySQLDatastore.java b/common/src/main/java/me/lucko/luckperms/data/methods/MySQLDatastore.java index 70ae0733..b283e303 100644 --- a/common/src/main/java/me/lucko/luckperms/data/methods/MySQLDatastore.java +++ b/common/src/main/java/me/lucko/luckperms/data/methods/MySQLDatastore.java @@ -13,7 +13,7 @@ public class MySQLDatastore extends SQLDatastore { private static final String CREATETABLE_USERS = "CREATE TABLE IF NOT EXISTS `lp_users` (`uuid` VARCHAR(36) NOT NULL, `name` VARCHAR(16) NOT NULL, `perms` TEXT NOT NULL, PRIMARY KEY (`uuid`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"; private static final String CREATETABLE_GROUPS = "CREATE TABLE IF NOT EXISTS `lp_groups` (`name` VARCHAR(36) NOT NULL, `perms` TEXT NULL, PRIMARY KEY (`name`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"; - private MySQLConfiguration configuration; + private final MySQLConfiguration configuration; private HikariDataSource hikari; public MySQLDatastore(LuckPermsPlugin plugin, MySQLConfiguration configuration) { diff --git a/common/src/main/java/me/lucko/luckperms/data/methods/SQLDatastore.java b/common/src/main/java/me/lucko/luckperms/data/methods/SQLDatastore.java index 0867541c..f808375f 100644 --- a/common/src/main/java/me/lucko/luckperms/data/methods/SQLDatastore.java +++ b/common/src/main/java/me/lucko/luckperms/data/methods/SQLDatastore.java @@ -39,9 +39,9 @@ public abstract class SQLDatastore extends Datastore { private static final String UUIDCACHE_SELECT = "SELECT uuid FROM lp_uuid WHERE name=?"; private static final String UUIDCACHE_UPDATE = "UPDATE lp_uuid SET uuid=? WHERE name=?"; - private Gson gson; + private final Gson gson; - public SQLDatastore(LuckPermsPlugin plugin, String name) { + SQLDatastore(LuckPermsPlugin plugin, String name) { super(plugin, name); gson = new Gson(); } @@ -317,7 +317,7 @@ public abstract class SQLDatastore extends Datastore { } private class Closer { - private List objects = new ArrayList<>(); + private final List objects = new ArrayList<>(); public void add(AutoCloseable a) { objects.add(a); diff --git a/common/src/main/java/me/lucko/luckperms/data/methods/SQLiteDatastore.java b/common/src/main/java/me/lucko/luckperms/data/methods/SQLiteDatastore.java index 8fe9a83a..c02f348a 100644 --- a/common/src/main/java/me/lucko/luckperms/data/methods/SQLiteDatastore.java +++ b/common/src/main/java/me/lucko/luckperms/data/methods/SQLiteDatastore.java @@ -13,7 +13,7 @@ public class SQLiteDatastore extends SQLDatastore { private static final String CREATETABLE_USERS = "CREATE TABLE IF NOT EXISTS `lp_users` (`uuid` VARCHAR(36) NOT NULL, `name` VARCHAR(16) NOT NULL, `perms` TEXT NOT NULL, PRIMARY KEY (`uuid`));"; private static final String CREATETABLE_GROUPS = "CREATE TABLE IF NOT EXISTS `lp_groups` (`name` VARCHAR(36) NOT NULL, `perms` TEXT NULL, PRIMARY KEY (`name`));"; - private File file; + private final File file; private Connection connection = null; public SQLiteDatastore(LuckPermsPlugin plugin, File file) { diff --git a/common/src/main/java/me/lucko/luckperms/groups/Group.java b/common/src/main/java/me/lucko/luckperms/groups/Group.java index df2791da..919748dd 100644 --- a/common/src/main/java/me/lucko/luckperms/groups/Group.java +++ b/common/src/main/java/me/lucko/luckperms/groups/Group.java @@ -12,7 +12,7 @@ public class Group extends PermissionObject { @Getter private final String name; - public Group(String name, LuckPermsPlugin plugin) { + Group(String name, LuckPermsPlugin plugin) { super(plugin, name); this.name = name; } diff --git a/common/src/main/java/me/lucko/luckperms/users/User.java b/common/src/main/java/me/lucko/luckperms/users/User.java index 1b6760b2..e9f4fa19 100644 --- a/common/src/main/java/me/lucko/luckperms/users/User.java +++ b/common/src/main/java/me/lucko/luckperms/users/User.java @@ -26,13 +26,13 @@ public abstract class User extends PermissionObject { @Setter private String name; - public User(UUID uuid, LuckPermsPlugin plugin) { + User(UUID uuid, LuckPermsPlugin plugin) { super(plugin, uuid.toString()); this.uuid = uuid; this.name = null; } - public User(UUID uuid, String name, LuckPermsPlugin plugin) { + User(UUID uuid, String name, LuckPermsPlugin plugin) { super(plugin, uuid.toString()); this.uuid = uuid; this.name = name; diff --git a/common/src/main/java/me/lucko/luckperms/users/UserManager.java b/common/src/main/java/me/lucko/luckperms/users/UserManager.java index 12eb3ced..9ea36966 100644 --- a/common/src/main/java/me/lucko/luckperms/users/UserManager.java +++ b/common/src/main/java/me/lucko/luckperms/users/UserManager.java @@ -2,9 +2,6 @@ package me.lucko.luckperms.users; import lombok.Getter; import lombok.NoArgsConstructor; -import me.lucko.luckperms.LuckPermsPlugin; -import me.lucko.luckperms.commands.Sender; -import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.data.Datastore; import java.util.Map; diff --git a/common/src/main/java/me/lucko/luckperms/utils/PermissionObject.java b/common/src/main/java/me/lucko/luckperms/utils/PermissionObject.java index adf5b993..74683abd 100644 --- a/common/src/main/java/me/lucko/luckperms/utils/PermissionObject.java +++ b/common/src/main/java/me/lucko/luckperms/utils/PermissionObject.java @@ -42,7 +42,7 @@ public abstract class PermissionObject { @Setter private Map nodes = new HashMap<>(); - public PermissionObject(LuckPermsPlugin plugin, String objectName) { + protected PermissionObject(LuckPermsPlugin plugin, String objectName) { this.objectName = objectName; this.plugin = plugin; this.includeGlobalPermissions = plugin.getConfiguration().getIncludeGlobalPerms();