small cleanup

This commit is contained in:
Luck 2016-06-23 13:29:51 +01:00
parent 0380b7017d
commit 85989aeb7c
21 changed files with 26 additions and 30 deletions

View File

@ -16,6 +16,7 @@ public class BukkitConfig implements LPConfiguration {
create(); create();
} }
@SuppressWarnings("ResultOfMethodCallIgnored")
private void create() { private void create() {
File configFile = new File(plugin.getDataFolder(), "config.yml"); File configFile = new File(plugin.getDataFolder(), "config.yml");

View File

@ -8,7 +8,7 @@ import me.lucko.luckperms.users.User;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
@AllArgsConstructor @AllArgsConstructor
public class VaultHook extends Permission { class VaultHook extends Permission {
private final LPBukkitPlugin plugin; private final LPBukkitPlugin plugin;
@Override @Override
@ -90,9 +90,7 @@ public class VaultHook extends Permission {
@Override @Override
public boolean playerInGroup(String world, String player, String group) { public boolean playerInGroup(String world, String player, String group) {
final User user = plugin.getUserManager().getUser(player); final User user = plugin.getUserManager().getUser(player);
if (user == null) return false; return user != null && user.getGroupNames().contains(group);
return user.getGroupNames().contains(group);
} }
@Override @Override

View File

@ -68,7 +68,7 @@ public class PlayerListener implements Listener {
plugin.getUserManager().unloadUser(user); plugin.getUserManager().unloadUser(user);
} }
public static String color(String string) { private static String color(String string) {
return ChatColor.translateAlternateColorCodes('&', string); return ChatColor.translateAlternateColorCodes('&', string);
} }

View File

@ -18,12 +18,12 @@ public class BukkitUser extends User {
@Setter @Setter
private PermissionAttachment attachment = null; private PermissionAttachment attachment = null;
public BukkitUser(UUID uuid, LPBukkitPlugin plugin) { BukkitUser(UUID uuid, LPBukkitPlugin plugin) {
super(uuid, plugin); super(uuid, plugin);
this.plugin = plugin; this.plugin = plugin;
} }
public BukkitUser(UUID uuid, String username, LPBukkitPlugin plugin) { BukkitUser(UUID uuid, String username, LPBukkitPlugin plugin) {
super(uuid, username, plugin); super(uuid, username, plugin);
this.plugin = plugin; this.plugin = plugin;
} }

View File

@ -27,6 +27,7 @@ public class BungeeConfig implements LPConfiguration {
} }
} }
@SuppressWarnings("ResultOfMethodCallIgnored")
private File makeFile(String file) throws IOException { private File makeFile(String file) throws IOException {
File cfg = new File(plugin.getDataFolder(), file); File cfg = new File(plugin.getDataFolder(), file);

View File

@ -8,7 +8,7 @@ import net.md_5.bungee.api.plugin.Command;
import java.util.Arrays; import java.util.Arrays;
public class MainCommand extends Command { class MainCommand extends Command {
private final CommandManager manager; private final CommandManager manager;
public MainCommand(CommandManager manager) { public MainCommand(CommandManager manager) {

View File

@ -3,7 +3,6 @@ package me.lucko.luckperms.listeners;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import me.lucko.luckperms.LPBungeePlugin; import me.lucko.luckperms.LPBungeePlugin;
import me.lucko.luckperms.commands.Util; import me.lucko.luckperms.commands.Util;
import me.lucko.luckperms.data.Datastore;
import me.lucko.luckperms.users.User; import me.lucko.luckperms.users.User;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;

View File

@ -12,12 +12,12 @@ public class BungeeUser extends User {
private final LPBungeePlugin plugin; private final LPBungeePlugin plugin;
public BungeeUser(UUID uuid, LPBungeePlugin plugin) { BungeeUser(UUID uuid, LPBungeePlugin plugin) {
super(uuid, plugin); super(uuid, plugin);
this.plugin = plugin; this.plugin = plugin;
} }
public BungeeUser(UUID uuid, String username, LPBungeePlugin plugin) { BungeeUser(UUID uuid, String username, LPBungeePlugin plugin) {
super(uuid, username, plugin); super(uuid, username, plugin);
this.plugin = plugin; this.plugin = plugin;
} }

View File

@ -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() + "'"); plugin.getLogger().log(Level.INFO, "[CommandManager] Registered main command '" + command.getName() + "'");
mainCommands.add(command); mainCommands.add(command);
} }

View File

@ -17,7 +17,7 @@ public abstract class MainCommand {
@Getter @Getter
private final int requiredArgsLength; private final int requiredArgsLength;
public MainCommand(String name, String usage, int requiredArgsLength) { protected MainCommand(String name, String usage, int requiredArgsLength) {
this.name = name; this.name = name;
this.usage = usage; this.usage = usage;
this.requiredArgsLength = requiredArgsLength; this.requiredArgsLength = requiredArgsLength;

View File

@ -16,7 +16,7 @@ public abstract class SubCommand {
@Getter @Getter
private final String permission; 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.name = name;
this.description = description; this.description = description;
this.usage = usage; this.usage = usage;

View File

@ -9,7 +9,7 @@ import me.lucko.luckperms.groups.Group;
import java.util.List; import java.util.List;
public abstract class GroupSubCommand extends SubCommand { 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); super(name, description, usage, permission);
} }

View File

@ -9,7 +9,7 @@ import me.lucko.luckperms.users.User;
import java.util.List; import java.util.List;
public abstract class UserSubCommand extends SubCommand { 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); super(name, description, usage, permission);
} }

View File

@ -12,13 +12,13 @@ public abstract class Datastore {
protected final LuckPermsPlugin plugin; protected final LuckPermsPlugin plugin;
@Getter @Getter
public String name; public final String name;
@Getter @Getter
@Setter @Setter
private boolean acceptingLogins; private boolean acceptingLogins;
public Datastore(LuckPermsPlugin plugin, String name) { protected Datastore(LuckPermsPlugin plugin, String name) {
this.plugin = plugin; this.plugin = plugin;
this.name = name; this.name = name;
this.acceptingLogins = true; this.acceptingLogins = true;

View File

@ -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_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 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; private HikariDataSource hikari;
public MySQLDatastore(LuckPermsPlugin plugin, MySQLConfiguration configuration) { public MySQLDatastore(LuckPermsPlugin plugin, MySQLConfiguration configuration) {

View File

@ -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_SELECT = "SELECT uuid FROM lp_uuid WHERE name=?";
private static final String UUIDCACHE_UPDATE = "UPDATE lp_uuid SET 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); super(plugin, name);
gson = new Gson(); gson = new Gson();
} }
@ -317,7 +317,7 @@ public abstract class SQLDatastore extends Datastore {
} }
private class Closer { private class Closer {
private List<AutoCloseable> objects = new ArrayList<>(); private final List<AutoCloseable> objects = new ArrayList<>();
public void add(AutoCloseable a) { public void add(AutoCloseable a) {
objects.add(a); objects.add(a);

View File

@ -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_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 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; private Connection connection = null;
public SQLiteDatastore(LuckPermsPlugin plugin, File file) { public SQLiteDatastore(LuckPermsPlugin plugin, File file) {

View File

@ -12,7 +12,7 @@ public class Group extends PermissionObject {
@Getter @Getter
private final String name; private final String name;
public Group(String name, LuckPermsPlugin plugin) { Group(String name, LuckPermsPlugin plugin) {
super(plugin, name); super(plugin, name);
this.name = name; this.name = name;
} }

View File

@ -26,13 +26,13 @@ public abstract class User extends PermissionObject {
@Setter @Setter
private String name; private String name;
public User(UUID uuid, LuckPermsPlugin plugin) { User(UUID uuid, LuckPermsPlugin plugin) {
super(plugin, uuid.toString()); super(plugin, uuid.toString());
this.uuid = uuid; this.uuid = uuid;
this.name = null; this.name = null;
} }
public User(UUID uuid, String name, LuckPermsPlugin plugin) { User(UUID uuid, String name, LuckPermsPlugin plugin) {
super(plugin, uuid.toString()); super(plugin, uuid.toString());
this.uuid = uuid; this.uuid = uuid;
this.name = name; this.name = name;

View File

@ -2,9 +2,6 @@ package me.lucko.luckperms.users;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; 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 me.lucko.luckperms.data.Datastore;
import java.util.Map; import java.util.Map;

View File

@ -42,7 +42,7 @@ public abstract class PermissionObject {
@Setter @Setter
private Map<String, Boolean> nodes = new HashMap<>(); private Map<String, Boolean> nodes = new HashMap<>();
public PermissionObject(LuckPermsPlugin plugin, String objectName) { protected PermissionObject(LuckPermsPlugin plugin, String objectName) {
this.objectName = objectName; this.objectName = objectName;
this.plugin = plugin; this.plugin = plugin;
this.includeGlobalPermissions = plugin.getConfiguration().getIncludeGlobalPerms(); this.includeGlobalPermissions = plugin.getConfiguration().getIncludeGlobalPerms();