Remove lombok from the project

This commit is contained in:
Luck
2018-01-07 18:40:02 +00:00
Unverified
parent 17ff9ac328
commit f646c04d09
398 changed files with 8482 additions and 4818 deletions
@@ -53,17 +53,17 @@ public class BungeeCommandExecutor extends Command implements TabExecutor {
@Override
public void execute(CommandSender sender, String[] args) {
Sender lpSender = plugin.getSenderFactory().wrap(sender);
Sender lpSender = this.plugin.getSenderFactory().wrap(sender);
List<String> arguments = CommandManager.stripQuotes(ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
manager.onCommand(lpSender, "lpb", arguments);
this.manager.onCommand(lpSender, "lpb", arguments);
}
@Override
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
Sender lpSender = plugin.getSenderFactory().wrap(sender);
Sender lpSender = this.plugin.getSenderFactory().wrap(sender);
List<String> arguments = CommandManager.stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
return manager.onTabComplete(lpSender, arguments);
return this.manager.onTabComplete(lpSender, arguments);
}
}
@@ -55,7 +55,7 @@ public class BungeeConfigAdapter extends AbstractConfigurationAdapter implements
@Override
public void reload() {
try {
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
this.configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -63,32 +63,32 @@ public class BungeeConfigAdapter extends AbstractConfigurationAdapter implements
@Override
public boolean contains(String path) {
return configuration.contains(path);
return this.configuration.contains(path);
}
@Override
public String getString(String path, String def) {
return configuration.getString(path, def);
return this.configuration.getString(path, def);
}
@Override
public int getInt(String path, int def) {
return configuration.getInt(path, def);
return this.configuration.getInt(path, def);
}
@Override
public boolean getBoolean(String path, boolean def) {
return configuration.getBoolean(path, def);
return this.configuration.getBoolean(path, def);
}
@Override
public List<String> getList(String path, List<String> def) {
return Optional.ofNullable(configuration.getStringList(path)).orElse(def);
return Optional.ofNullable(this.configuration.getStringList(path)).orElse(def);
}
@Override
public List<String> getObjectList(String path, List<String> def) {
Configuration section = configuration.getSection(path);
Configuration section = this.configuration.getSection(path);
if (section == null) {
return def;
}
@@ -99,7 +99,7 @@ public class BungeeConfigAdapter extends AbstractConfigurationAdapter implements
@Override
public Map<String, String> getMap(String path, Map<String, String> def) {
Map<String, String> map = new HashMap<>();
Configuration section = configuration.getSection(path);
Configuration section = this.configuration.getSection(path);
if (section == null) {
return def;
}
@@ -47,17 +47,17 @@ public class BungeeSchedulerAdapter implements SchedulerAdapter {
@Override
public Executor async() {
return asyncExecutor;
return this.asyncExecutor;
}
@Override
public Executor sync() {
return asyncExecutor;
return this.asyncExecutor;
}
@Override
public void doAsync(Runnable runnable) {
asyncExecutor.execute(runnable);
this.asyncExecutor.execute(runnable);
}
@Override
@@ -68,8 +68,8 @@ public class BungeeSchedulerAdapter implements SchedulerAdapter {
@Override
public void asyncRepeating(Runnable runnable, long intervalTicks) {
long millis = intervalTicks * 50L; // convert from ticks to milliseconds
ScheduledTask task = plugin.getProxy().getScheduler().schedule(plugin, runnable, millis, millis, TimeUnit.MILLISECONDS);
tasks.add(task);
ScheduledTask task = this.plugin.getProxy().getScheduler().schedule(this.plugin, runnable, millis, millis, TimeUnit.MILLISECONDS);
this.tasks.add(task);
}
@Override
@@ -80,7 +80,7 @@ public class BungeeSchedulerAdapter implements SchedulerAdapter {
@Override
public void asyncLater(Runnable runnable, long delayTicks) {
long millis = delayTicks * 50L; // convert from ticks to milliseconds
plugin.getProxy().getScheduler().schedule(plugin, runnable, millis, TimeUnit.MILLISECONDS);
this.plugin.getProxy().getScheduler().schedule(this.plugin, runnable, millis, TimeUnit.MILLISECONDS);
}
@Override
@@ -90,6 +90,6 @@ public class BungeeSchedulerAdapter implements SchedulerAdapter {
@Override
public void shutdown() {
tasks.forEach(ScheduledTask::cancel);
this.tasks.forEach(ScheduledTask::cancel);
}
}
@@ -25,8 +25,6 @@
package me.lucko.luckperms.bungee;
import lombok.Getter;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.platform.PlatformType;
import me.lucko.luckperms.bungee.calculators.BungeeCalculatorFactory;
@@ -97,7 +95,6 @@ import java.util.stream.Stream;
/**
* LuckPerms implementation for the BungeeCord API.
*/
@Getter
public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
private long startTime;
@@ -129,93 +126,93 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
@Override
public void onLoad() {
// setup minimal functionality in order to load initial dependencies
scheduler = new BungeeSchedulerAdapter(this);
localeManager = new NoopLocaleManager();
senderFactory = new BungeeSenderFactory(this);
log = new SenderLogger(this, getConsoleSender());
this.scheduler = new BungeeSchedulerAdapter(this);
this.localeManager = new NoopLocaleManager();
this.senderFactory = new BungeeSenderFactory(this);
this.log = new SenderLogger(this, getConsoleSender());
dependencyManager = new DependencyManager(this);
dependencyManager.loadDependencies(Collections.singleton(Dependency.CAFFEINE));
this.dependencyManager = new DependencyManager(this);
this.dependencyManager.loadDependencies(Collections.singleton(Dependency.CAFFEINE));
}
@Override
public void onEnable() {
startTime = System.currentTimeMillis();
this.startTime = System.currentTimeMillis();
sendStartupBanner(getConsoleSender());
verboseHandler = new VerboseHandler(scheduler.async(), getVersion());
permissionVault = new PermissionVault(scheduler.async());
logDispatcher = new LogDispatcher(this);
this.verboseHandler = new VerboseHandler(this.scheduler.async(), getVersion());
this.permissionVault = new PermissionVault(this.scheduler.async());
this.logDispatcher = new LogDispatcher(this);
getLog().info("Loading configuration...");
configuration = new AbstractConfiguration(this, new BungeeConfigAdapter(this, resolveConfig("config.yml")));
configuration.loadAll();
this.configuration = new AbstractConfiguration(this, new BungeeConfigAdapter(this, resolveConfig("config.yml")));
this.configuration.loadAll();
StorageFactory storageFactory = new StorageFactory(this);
Set<StorageType> storageTypes = storageFactory.getRequiredTypes(StorageType.H2);
dependencyManager.loadStorageDependencies(storageTypes);
this.dependencyManager.loadStorageDependencies(storageTypes);
// register events
getProxy().getPluginManager().registerListener(this, new BungeeConnectionListener(this));
getProxy().getPluginManager().registerListener(this, new BungeePermissionCheckListener(this));
if (getConfiguration().get(ConfigKeys.WATCH_FILES)) {
fileWatcher = new FileWatcher(this);
getScheduler().asyncRepeating(fileWatcher, 30L);
this.fileWatcher = new FileWatcher(this);
getScheduler().asyncRepeating(this.fileWatcher, 30L);
}
// initialise datastore
storage = storageFactory.getInstance(StorageType.H2);
this.storage = storageFactory.getInstance(StorageType.H2);
// initialise messaging
messagingService = new BungeeMessagingFactory(this).getInstance();
this.messagingService = new BungeeMessagingFactory(this).getInstance();
// setup the update task buffer
updateTaskBuffer = new UpdateTaskBuffer(this);
this.updateTaskBuffer = new UpdateTaskBuffer(this);
// load locale
localeManager = new SimpleLocaleManager();
localeManager.tryLoad(this, new File(getDataFolder(), "lang.yml"));
this.localeManager = new SimpleLocaleManager();
this.localeManager.tryLoad(this, new File(getDataFolder(), "lang.yml"));
// register commands
commandManager = new CommandManager(this);
getProxy().getPluginManager().registerCommand(this, new BungeeCommandExecutor(this, commandManager));
this.commandManager = new CommandManager(this);
getProxy().getPluginManager().registerCommand(this, new BungeeCommandExecutor(this, this.commandManager));
// disable the default Bungee /perms command so it gets handled by the Bukkit plugin
getProxy().getDisabledCommands().add("perms");
// load internal managers
getLog().info("Loading internal permission managers...");
uuidCache = new UuidCache(this);
userManager = new GenericUserManager(this);
groupManager = new GenericGroupManager(this);
trackManager = new GenericTrackManager(this);
calculatorFactory = new BungeeCalculatorFactory(this);
cachedStateManager = new CachedStateManager();
this.uuidCache = new UuidCache(this);
this.userManager = new GenericUserManager(this);
this.groupManager = new GenericGroupManager(this);
this.trackManager = new GenericTrackManager(this);
this.calculatorFactory = new BungeeCalculatorFactory(this);
this.cachedStateManager = new CachedStateManager();
// setup context manager
contextManager = new BungeeContextManager(this);
contextManager.registerCalculator(new BackendServerCalculator(this));
contextManager.registerStaticCalculator(new LuckPermsCalculator(getConfiguration()));
this.contextManager = new BungeeContextManager(this);
this.contextManager.registerCalculator(new BackendServerCalculator(this));
this.contextManager.registerStaticCalculator(new LuckPermsCalculator(getConfiguration()));
if (getProxy().getPluginManager().getPlugin("RedisBungee") != null) {
contextManager.registerStaticCalculator(new RedisBungeeCalculator());
this.contextManager.registerStaticCalculator(new RedisBungeeCalculator());
}
// register with the LP API
apiProvider = new LuckPermsApiProvider(this);
this.apiProvider = new LuckPermsApiProvider(this);
// setup event factory
eventFactory = new EventFactory(this, apiProvider);
this.eventFactory = new EventFactory(this, this.apiProvider);
ApiRegistrationUtil.registerProvider(apiProvider);
ApiRegistrationUtil.registerProvider(this.apiProvider);
// schedule update tasks
int mins = getConfiguration().get(ConfigKeys.SYNC_TIME);
if (mins > 0) {
long ticks = mins * 60 * 20;
scheduler.asyncRepeating(() -> updateTaskBuffer.request(), ticks);
this.scheduler.asyncRepeating(() -> this.updateTaskBuffer.request(), ticks);
}
scheduler.asyncLater(() -> updateTaskBuffer.request(), 40L);
this.scheduler.asyncLater(() -> this.updateTaskBuffer.request(), 40L);
// run an update instantly.
getLog().info("Performing initial data load...");
@@ -227,33 +224,33 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
// register tasks
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
scheduler.asyncRepeating(new CacheHousekeepingTask(this), 2400L);
this.scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
this.scheduler.asyncRepeating(new CacheHousekeepingTask(this), 2400L);
getLog().info("Successfully enabled. (took " + (System.currentTimeMillis() - startTime) + "ms)");
getLog().info("Successfully enabled. (took " + (System.currentTimeMillis() - this.startTime) + "ms)");
}
@Override
public void onDisable() {
permissionVault.shutdown();
verboseHandler.shutdown();
this.permissionVault.shutdown();
this.verboseHandler.shutdown();
getLog().info("Closing storage...");
storage.shutdown();
this.storage.shutdown();
if (fileWatcher != null) {
fileWatcher.close();
if (this.fileWatcher != null) {
this.fileWatcher.close();
}
if (messagingService != null) {
if (this.messagingService != null) {
getLog().info("Closing messaging service...");
messagingService.close();
this.messagingService.close();
}
ApiRegistrationUtil.unregisterProvider();
getLog().info("Shutting down internal scheduler...");
scheduler.shutdown();
this.scheduler.shutdown();
getProxy().getScheduler().cancel(this);
getProxy().getPluginManager().unregisterListeners(this);
@@ -277,11 +274,12 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
@Override
public Optional<ExtendedMessagingService> getMessagingService() {
return Optional.ofNullable(messagingService);
return Optional.ofNullable(this.messagingService);
}
@Override
public Optional<FileWatcher> getFileWatcher() {
return Optional.ofNullable(fileWatcher);
return Optional.ofNullable(this.fileWatcher);
}
@Override
@@ -316,7 +314,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
@Override
public ProxiedPlayer getPlayer(User user) {
return getProxy().getPlayer(uuidCache.getExternalUUID(user.getUuid()));
return getProxy().getPlayer(this.uuidCache.getExternalUUID(user.getUuid()));
}
@Override
@@ -338,7 +336,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
if (player == null) {
return null;
}
return contextManager.getApplicableContexts(player);
return this.contextManager.getApplicableContexts(player);
}
@Override
@@ -374,4 +372,118 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
public Sender getConsoleSender() {
return getSenderFactory().wrap(getProxy().getConsole());
}
@Override
public long getStartTime() {
return this.startTime;
}
@Override
public SchedulerAdapter getScheduler() {
return this.scheduler;
}
@Override
public CommandManager getCommandManager() {
return this.commandManager;
}
@Override
public LuckPermsConfiguration getConfiguration() {
return this.configuration;
}
@Override
public UserManager getUserManager() {
return this.userManager;
}
@Override
public GroupManager getGroupManager() {
return this.groupManager;
}
@Override
public TrackManager getTrackManager() {
return this.trackManager;
}
@Override
public Storage getStorage() {
return this.storage;
}
@Override
public UuidCache getUuidCache() {
return this.uuidCache;
}
@Override
public LuckPermsApiProvider getApiProvider() {
return this.apiProvider;
}
@Override
public EventFactory getEventFactory() {
return this.eventFactory;
}
@Override
public Logger getLog() {
return this.log;
}
@Override
public LocaleManager getLocaleManager() {
return this.localeManager;
}
@Override
public DependencyManager getDependencyManager() {
return this.dependencyManager;
}
@Override
public CachedStateManager getCachedStateManager() {
return this.cachedStateManager;
}
@Override
public ContextManager<ProxiedPlayer> getContextManager() {
return this.contextManager;
}
@Override
public CalculatorFactory getCalculatorFactory() {
return this.calculatorFactory;
}
@Override
public BufferedRequest<Void> getUpdateTaskBuffer() {
return this.updateTaskBuffer;
}
@Override
public VerboseHandler getVerboseHandler() {
return this.verboseHandler;
}
public BungeeSenderFactory getSenderFactory() {
return this.senderFactory;
}
@Override
public PermissionVault getPermissionVault() {
return this.permissionVault;
}
@Override
public LogDispatcher getLogDispatcher() {
return this.logDispatcher;
}
@Override
public Set<UUID> getUniqueConnections() {
return this.uniqueConnections;
}
}
@@ -25,8 +25,6 @@
package me.lucko.luckperms.bungee.calculators;
import lombok.AllArgsConstructor;
import com.google.common.collect.ImmutableList;
import me.lucko.luckperms.api.Contexts;
@@ -42,33 +40,36 @@ import me.lucko.luckperms.common.processors.WildcardProcessor;
import java.util.List;
@AllArgsConstructor
public class BungeeCalculatorFactory extends AbstractCalculatorFactory {
private final LPBungeePlugin plugin;
public BungeeCalculatorFactory(LPBungeePlugin plugin) {
this.plugin = plugin;
}
@Override
public PermissionCalculator build(Contexts contexts, PermissionCalculatorMetadata metadata) {
ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();
processors.add(new MapProcessor());
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) {
if (this.plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) {
processors.add(new RegexProcessor());
}
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_WILDCARDS)) {
if (this.plugin.getConfiguration().get(ConfigKeys.APPLYING_WILDCARDS)) {
processors.add(new WildcardProcessor());
}
return registerCalculator(new PermissionCalculator(plugin, metadata, processors.build()));
return registerCalculator(new PermissionCalculator(this.plugin, metadata, processors.build()));
}
@Override
public List<String> getActiveProcessors() {
ImmutableList.Builder<String> ret = ImmutableList.builder();
ret.add("Map");
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) ret.add("Regex");
if (plugin.getConfiguration().get(ConfigKeys.APPLYING_WILDCARDS)) ret.add("Wildcards");
if (this.plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) ret.add("Regex");
if (this.plugin.getConfiguration().get(ConfigKeys.APPLYING_WILDCARDS)) ret.add("Wildcards");
return ret.build();
}
}
@@ -25,8 +25,6 @@
package me.lucko.luckperms.bungee.contexts;
import lombok.RequiredArgsConstructor;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.context.ContextCalculator;
import me.lucko.luckperms.api.context.MutableContextSet;
@@ -35,7 +33,8 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@RequiredArgsConstructor
import javax.annotation.Nonnull;
public class BackendServerCalculator implements ContextCalculator<ProxiedPlayer> {
private static String getServer(ProxiedPlayer player) {
@@ -44,12 +43,17 @@ public class BackendServerCalculator implements ContextCalculator<ProxiedPlayer>
private final LuckPermsPlugin plugin;
public BackendServerCalculator(LuckPermsPlugin plugin) {
this.plugin = plugin;
}
@Nonnull
@Override
public MutableContextSet giveApplicableContext(ProxiedPlayer subject, MutableContextSet accumulator) {
public MutableContextSet giveApplicableContext(@Nonnull ProxiedPlayer subject, @Nonnull MutableContextSet accumulator) {
String server = getServer(subject);
while (server != null && !accumulator.has(Contexts.WORLD_KEY, server)) {
accumulator.add(Contexts.WORLD_KEY, server);
server = plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).getOrDefault(server, server).toLowerCase();
server = this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).getOrDefault(server, server).toLowerCase();
}
return accumulator;
@@ -42,11 +42,11 @@ public class BungeeContextManager extends AbstractContextManager<ProxiedPlayer>
public Contexts formContexts(ProxiedPlayer subject, ImmutableContextSet contextSet) {
return new Contexts(
contextSet,
plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
this.plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
this.plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
true,
plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
this.plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
this.plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
false
);
}
@@ -31,11 +31,14 @@ import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
import me.lucko.luckperms.api.context.MutableContextSet;
import me.lucko.luckperms.api.context.StaticContextCalculator;
import javax.annotation.Nonnull;
public class RedisBungeeCalculator implements StaticContextCalculator {
private static final String PROXY_KEY = "proxy";
@Nonnull
@Override
public MutableContextSet giveApplicableContext(MutableContextSet accumulator) {
public MutableContextSet giveApplicableContext(@Nonnull MutableContextSet accumulator) {
RedisBungeeAPI redisBungee = RedisBungee.getApi();
if (redisBungee != null) {
accumulator.add(PROXY_KEY, redisBungee.getServerId());
@@ -25,12 +25,6 @@
package me.lucko.luckperms.bungee.event;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import me.lucko.luckperms.api.Tristate;
import net.md_5.bungee.api.CommandSender;
@@ -40,10 +34,6 @@ import net.md_5.bungee.api.plugin.Event;
/**
* Copy of the internal BungeeCord "PermissionCheckEvent", returning a tristate instead of a boolean.
*/
@Getter
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@ToString
public class TristateCheckEvent extends Event {
public static Tristate call(CommandSender sender, String permission) {
return ProxyServer.getInstance().getPluginManager().callEvent(new TristateCheckEvent(sender, permission)).getResult();
@@ -52,11 +42,40 @@ public class TristateCheckEvent extends Event {
private final CommandSender sender;
private final String permission;
@Setter
private Tristate result;
public TristateCheckEvent(CommandSender sender, String permission) {
this(sender, permission, sender.getPermissions().contains(permission) ? Tristate.TRUE : Tristate.UNDEFINED);
}
public TristateCheckEvent(CommandSender sender, String permission, Tristate result) {
this.sender = sender;
this.permission = permission;
this.result = result;
}
public CommandSender getSender() {
return this.sender;
}
public String getPermission() {
return this.permission;
}
public Tristate getResult() {
return this.result;
}
public void setResult(Tristate result) {
this.result = result;
}
@Override
public String toString() {
return "TristateCheckEvent(" +
"sender=" + this.sender + ", " +
"permission=" + this.permission + ", " +
"result=" + this.result + ")";
}
}
@@ -25,8 +25,6 @@
package me.lucko.luckperms.bungee.listeners;
import lombok.RequiredArgsConstructor;
import me.lucko.luckperms.bungee.LPBungeePlugin;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.locale.Message;
@@ -45,10 +43,13 @@ import net.md_5.bungee.event.EventPriority;
import java.util.concurrent.TimeUnit;
@RequiredArgsConstructor
public class BungeeConnectionListener implements Listener {
private final LPBungeePlugin plugin;
public BungeeConnectionListener(LPBungeePlugin plugin) {
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.LOW)
public void onPlayerLogin(LoginEvent e) {
/* Called when the player first attempts a connection with the server.
@@ -60,16 +61,16 @@ public class BungeeConnectionListener implements Listener {
/* registers the plugins intent to modify this events state going forward.
this will prevent the event from completing until we're finished handling. */
e.registerIntent(plugin);
e.registerIntent(this.plugin);
final PendingConnection c = e.getConnection();
if (plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
plugin.getLog().info("Processing pre-login for " + c.getUniqueId() + " - " + c.getName());
if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
this.plugin.getLog().info("Processing pre-login for " + c.getUniqueId() + " - " + c.getName());
}
plugin.getScheduler().doAsync(() -> {
plugin.getUniqueConnections().add(c.getUniqueId());
this.plugin.getScheduler().doAsync(() -> {
this.plugin.getUniqueConnections().add(c.getUniqueId());
/* Actually process the login for the connection.
We do this here to delay the login until the data is ready.
@@ -81,51 +82,51 @@ public class BungeeConnectionListener implements Listener {
- creating a user instance in the UserManager for this connection.
- setting up cached data. */
try {
User user = LoginHelper.loadUser(plugin, c.getUniqueId(), c.getName(), true);
plugin.getEventFactory().handleUserLoginProcess(c.getUniqueId(), c.getName(), user);
User user = LoginHelper.loadUser(this.plugin, c.getUniqueId(), c.getName(), true);
this.plugin.getEventFactory().handleUserLoginProcess(c.getUniqueId(), c.getName(), user);
} catch (Exception ex) {
plugin.getLog().severe("Exception occured whilst loading data for " + c.getUniqueId() + " - " + c.getName());
this.plugin.getLog().severe("Exception occured whilst loading data for " + c.getUniqueId() + " - " + c.getName());
ex.printStackTrace();
// there was some error loading
if (plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) {
if (this.plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) {
// cancel the login attempt
e.setCancelReason(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(plugin.getLocaleManager())));
e.setCancelReason(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
e.setCancelled(true);
}
}
// finally, complete our intent to modify state, so the proxy can continue handling the connection.
e.completeIntent(plugin);
e.completeIntent(this.plugin);
// schedule a cleanup of the users data in a few seconds.
// this should cover the eventuality that the login fails.
plugin.getUserManager().scheduleUnload(c.getUniqueId());
this.plugin.getUserManager().scheduleUnload(c.getUniqueId());
});
}
@EventHandler
public void onPlayerPostLogin(PostLoginEvent e) {
final ProxiedPlayer player = e.getPlayer();
final User user = plugin.getUserManager().getIfLoaded(plugin.getUuidCache().getUUID(e.getPlayer().getUniqueId()));
final User user = this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(e.getPlayer().getUniqueId()));
if (plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
plugin.getLog().info("Processing post-login for " + player.getUniqueId() + " - " + player.getName());
if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
this.plugin.getLog().info("Processing post-login for " + player.getUniqueId() + " - " + player.getName());
}
if (user == null) {
if (plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) {
if (this.plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) {
// disconnect the user
plugin.getLog().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded - cancelling login.");
e.getPlayer().disconnect(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(plugin.getLocaleManager())));
this.plugin.getLog().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded - cancelling login.");
e.getPlayer().disconnect(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
} else {
// just send a message
plugin.getProxy().getScheduler().schedule(plugin, () -> {
this.plugin.getProxy().getScheduler().schedule(this.plugin, () -> {
if (!player.isConnected()) {
return;
}
player.sendMessage(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(plugin.getLocaleManager())));
player.sendMessage(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
}, 1, TimeUnit.SECONDS);
}
}
@@ -135,7 +136,7 @@ public class BungeeConnectionListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerQuit(PlayerDisconnectEvent e) {
// Request that the users data is unloaded.
plugin.getUserManager().scheduleUnload(e.getPlayer().getUniqueId());
this.plugin.getUserManager().scheduleUnload(e.getPlayer().getUniqueId());
}
}
@@ -25,8 +25,6 @@
package me.lucko.luckperms.bungee.listeners;
import lombok.RequiredArgsConstructor;
import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.Tristate;
import me.lucko.luckperms.bungee.LPBungeePlugin;
@@ -41,10 +39,13 @@ import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.event.EventPriority;
@RequiredArgsConstructor
public class BungeePermissionCheckListener implements Listener {
private final LPBungeePlugin plugin;
public BungeePermissionCheckListener(LPBungeePlugin plugin) {
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerPermissionCheck(PermissionCheckEvent e) {
if (!(e.getSender() instanceof ProxiedPlayer)) {
@@ -53,15 +54,15 @@ public class BungeePermissionCheckListener implements Listener {
ProxiedPlayer player = ((ProxiedPlayer) e.getSender());
User user = plugin.getUserManager().getIfLoaded(plugin.getUuidCache().getUUID(player.getUniqueId()));
User user = this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(player.getUniqueId()));
if (user == null) {
e.setHasPermission(false);
return;
}
Contexts contexts = plugin.getContextManager().getApplicableContexts(player);
Contexts contexts = this.plugin.getContextManager().getApplicableContexts(player);
Tristate result = user.getCachedData().getPermissionData(contexts).getPermissionValue(e.getPermission(), CheckOrigin.PLATFORM_PERMISSION_CHECK);
if (result == Tristate.UNDEFINED && plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
if (result == Tristate.UNDEFINED && this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
return; // just use the result provided by the proxy when the event was created
}
@@ -76,15 +77,15 @@ public class BungeePermissionCheckListener implements Listener {
ProxiedPlayer player = ((ProxiedPlayer) e.getSender());
User user = plugin.getUserManager().getIfLoaded(plugin.getUuidCache().getUUID(player.getUniqueId()));
User user = this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(player.getUniqueId()));
if (user == null) {
e.setResult(Tristate.UNDEFINED);
return;
}
Contexts contexts = plugin.getContextManager().getApplicableContexts(player);
Contexts contexts = this.plugin.getContextManager().getApplicableContexts(player);
Tristate result = user.getCachedData().getPermissionData(contexts).getPermissionValue(e.getPermission(), CheckOrigin.PLATFORM_LOOKUP_CHECK);
if (result == Tristate.UNDEFINED && plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
if (result == Tristate.UNDEFINED && this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
return; // just use the result provided by the proxy when the event was created
}
@@ -51,13 +51,13 @@ public class BungeeMessagingService extends AbstractMessagingService implements
}
public void init() {
plugin.getProxy().getPluginManager().registerListener(plugin, this);
plugin.getProxy().registerChannel(CHANNEL);
this.plugin.getProxy().getPluginManager().registerListener(this.plugin, this);
this.plugin.getProxy().registerChannel(CHANNEL);
}
@Override
public void close() {
plugin.getProxy().unregisterChannel(CHANNEL);
this.plugin.getProxy().unregisterChannel(CHANNEL);
}
@Override
@@ -68,7 +68,7 @@ public class BungeeMessagingService extends AbstractMessagingService implements
byte[] data = out.toByteArray();
for (ServerInfo server : plugin.getProxy().getServers().values()) {
for (ServerInfo server : this.plugin.getProxy().getServers().values()) {
server.sendData(CHANNEL, data, true);
}
}
@@ -90,7 +90,7 @@ public class BungeeMessagingService extends AbstractMessagingService implements
onMessage(msg, u -> {
// Forward to other servers
plugin.getScheduler().doAsync(() -> sendMessage(u));
this.plugin.getScheduler().doAsync(() -> sendMessage(u));
});
}
}
@@ -50,22 +50,22 @@ public class RedisBungeeMessagingService extends AbstractMessagingService implem
public void init() {
this.redisBungee = RedisBungee.getApi();
redisBungee.registerPubSubChannels(CHANNEL);
this.redisBungee.registerPubSubChannels(CHANNEL);
plugin.getProxy().getPluginManager().registerListener(plugin, this);
this.plugin.getProxy().getPluginManager().registerListener(this.plugin, this);
}
@Override
public void close() {
redisBungee.unregisterPubSubChannels(CHANNEL);
redisBungee = null;
this.redisBungee.unregisterPubSubChannels(CHANNEL);
this.redisBungee = null;
plugin.getProxy().getPluginManager().unregisterListener(this);
this.plugin.getProxy().getPluginManager().unregisterListener(this);
}
@Override
protected void sendMessage(String message) {
redisBungee.sendChannelMessage(CHANNEL, message);
this.redisBungee.sendChannelMessage(CHANNEL, message);
}
@EventHandler
@@ -26,7 +26,6 @@
package me.lucko.luckperms.bungee.migration;
import me.lucko.luckperms.api.event.cause.CreationCause;
import me.lucko.luckperms.common.commands.CommandException;
import me.lucko.luckperms.common.commands.CommandPermission;
import me.lucko.luckperms.common.commands.CommandResult;
import me.lucko.luckperms.common.commands.abstraction.SubCommand;
@@ -57,7 +56,7 @@ public class MigrationBungeePerms extends SubCommand<Object> {
}
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) {
ProgressLogger log = new ProgressLogger("BungeePerms");
log.addListener(plugin.getConsoleSender());
log.addListener(sender);
@@ -25,15 +25,12 @@
package me.lucko.luckperms.bungee.util;
import lombok.experimental.UtilityClass;
import com.imaginarycode.minecraft.redisbungee.RedisBungee;
import java.util.Optional;
import java.util.UUID;
@UtilityClass
public class RedisBungeeUtil {
public final class RedisBungeeUtil {
/**
* Looks up a UUID from username via RedisBungee's uuid cache.
@@ -45,4 +42,6 @@ public class RedisBungeeUtil {
return Optional.ofNullable(RedisBungee.getApi()).flatMap(a -> Optional.ofNullable(a.getUuidFromName(username, true)));
}
private RedisBungeeUtil() {}
}