Reduce buffer times, refactor MessagingService init
This commit is contained in:
parent
e1b51dd6af
commit
d60d0ac9c5
@ -32,12 +32,11 @@ import me.lucko.luckperms.api.Logger;
|
|||||||
import me.lucko.luckperms.api.LuckPermsApi;
|
import me.lucko.luckperms.api.LuckPermsApi;
|
||||||
import me.lucko.luckperms.api.PlatformType;
|
import me.lucko.luckperms.api.PlatformType;
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
|
||||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||||
import me.lucko.luckperms.bukkit.calculators.BukkitCalculatorFactory;
|
import me.lucko.luckperms.bukkit.calculators.BukkitCalculatorFactory;
|
||||||
|
import me.lucko.luckperms.bukkit.contexts.BukkitContextManager;
|
||||||
import me.lucko.luckperms.bukkit.contexts.WorldCalculator;
|
import me.lucko.luckperms.bukkit.contexts.WorldCalculator;
|
||||||
import me.lucko.luckperms.bukkit.messaging.BungeeMessagingService;
|
import me.lucko.luckperms.bukkit.messaging.BukkitMessagingFactory;
|
||||||
import me.lucko.luckperms.bukkit.messaging.LilyPadMessagingService;
|
|
||||||
import me.lucko.luckperms.bukkit.model.Injector;
|
import me.lucko.luckperms.bukkit.model.Injector;
|
||||||
import me.lucko.luckperms.bukkit.model.LPPermissible;
|
import me.lucko.luckperms.bukkit.model.LPPermissible;
|
||||||
import me.lucko.luckperms.bukkit.processors.ChildPermissionProvider;
|
import me.lucko.luckperms.bukkit.processors.ChildPermissionProvider;
|
||||||
@ -47,6 +46,7 @@ import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
|||||||
import me.lucko.luckperms.common.api.ApiHandler;
|
import me.lucko.luckperms.common.api.ApiHandler;
|
||||||
import me.lucko.luckperms.common.api.ApiProvider;
|
import me.lucko.luckperms.common.api.ApiProvider;
|
||||||
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
||||||
|
import me.lucko.luckperms.common.buffers.UpdateTaskBuffer;
|
||||||
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||||
@ -68,8 +68,6 @@ import me.lucko.luckperms.common.managers.GroupManager;
|
|||||||
import me.lucko.luckperms.common.managers.TrackManager;
|
import me.lucko.luckperms.common.managers.TrackManager;
|
||||||
import me.lucko.luckperms.common.managers.UserManager;
|
import me.lucko.luckperms.common.managers.UserManager;
|
||||||
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||||
import me.lucko.luckperms.common.messaging.NoopMessagingService;
|
|
||||||
import me.lucko.luckperms.common.messaging.RedisMessagingService;
|
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.storage.Storage;
|
import me.lucko.luckperms.common.storage.Storage;
|
||||||
@ -78,7 +76,6 @@ import me.lucko.luckperms.common.storage.StorageType;
|
|||||||
import me.lucko.luckperms.common.storage.backing.file.FileWatcher;
|
import me.lucko.luckperms.common.storage.backing.file.FileWatcher;
|
||||||
import me.lucko.luckperms.common.tasks.CacheHousekeepingTask;
|
import me.lucko.luckperms.common.tasks.CacheHousekeepingTask;
|
||||||
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
|
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
|
||||||
import me.lucko.luckperms.common.tasks.UpdateTask;
|
|
||||||
import me.lucko.luckperms.common.treeview.PermissionVault;
|
import me.lucko.luckperms.common.treeview.PermissionVault;
|
||||||
import me.lucko.luckperms.common.utils.LoginHelper;
|
import me.lucko.luckperms.common.utils.LoginHelper;
|
||||||
import me.lucko.luckperms.common.utils.UuidCache;
|
import me.lucko.luckperms.common.utils.UuidCache;
|
||||||
@ -131,7 +128,6 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
private LocaleManager localeManager;
|
private LocaleManager localeManager;
|
||||||
private CachedStateManager cachedStateManager;
|
private CachedStateManager cachedStateManager;
|
||||||
private ContextManager<Player> contextManager;
|
private ContextManager<Player> contextManager;
|
||||||
private WorldCalculator worldCalculator;
|
|
||||||
private CalculatorFactory calculatorFactory;
|
private CalculatorFactory calculatorFactory;
|
||||||
private BufferedRequest<Void> updateTaskBuffer;
|
private BufferedRequest<Void> updateTaskBuffer;
|
||||||
private boolean started = false;
|
private boolean started = false;
|
||||||
@ -227,68 +223,14 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
storage = StorageFactory.getInstance(this, StorageType.H2);
|
storage = StorageFactory.getInstance(this, StorageType.H2);
|
||||||
|
|
||||||
// initialise messaging
|
// initialise messaging
|
||||||
String messagingType = getConfiguration().get(ConfigKeys.MESSAGING_SERVICE).toLowerCase();
|
messagingService = new BukkitMessagingFactory(this).getInstance();
|
||||||
if (messagingType.equals("none") && getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
|
|
||||||
messagingType = "redis";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!messagingType.equals("none")) {
|
|
||||||
getLog().info("Loading messaging service... [" + messagingType.toUpperCase() + "]");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messagingType.equals("redis")) {
|
|
||||||
if (getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
|
|
||||||
RedisMessagingService redis = new RedisMessagingService(this);
|
|
||||||
try {
|
|
||||||
redis.init(getConfiguration().get(ConfigKeys.REDIS_ADDRESS), getConfiguration().get(ConfigKeys.REDIS_PASSWORD));
|
|
||||||
messagingService = redis;
|
|
||||||
} catch (Exception e) {
|
|
||||||
getLog().warn("Couldn't load redis...");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
getLog().warn("Messaging Service was set to redis, but redis is not enabled!");
|
|
||||||
}
|
|
||||||
} else if (messagingType.equals("bungee")) {
|
|
||||||
BungeeMessagingService bungeeMessaging = new BungeeMessagingService(this);
|
|
||||||
bungeeMessaging.init();
|
|
||||||
messagingService = bungeeMessaging;
|
|
||||||
} else if (messagingType.equals("lilypad")) {
|
|
||||||
if (getServer().getPluginManager().getPlugin("LilyPad-Connect") == null) {
|
|
||||||
getLog().warn("LilyPad-Connect plugin not present.");
|
|
||||||
} else {
|
|
||||||
LilyPadMessagingService lilyPadMessaging = new LilyPadMessagingService(this);
|
|
||||||
lilyPadMessaging.init();
|
|
||||||
messagingService = lilyPadMessaging;
|
|
||||||
}
|
|
||||||
} else if (!messagingType.equals("none")) {
|
|
||||||
getLog().warn("Messaging service '" + messagingType + "' not recognised.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messagingService == null) {
|
|
||||||
messagingService = new NoopMessagingService();
|
|
||||||
}
|
|
||||||
|
|
||||||
// setup the update task buffer
|
// setup the update task buffer
|
||||||
updateTaskBuffer = new BufferedRequest<Void>(1000L, this::doAsync) {
|
updateTaskBuffer = new UpdateTaskBuffer(this);
|
||||||
@Override
|
|
||||||
protected Void perform() {
|
|
||||||
new UpdateTask(LPBukkitPlugin.this).run();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// load locale
|
// load locale
|
||||||
localeManager = new SimpleLocaleManager();
|
localeManager = new SimpleLocaleManager();
|
||||||
File locale = new File(getDataFolder(), "lang.yml");
|
localeManager.tryLoad(this, new File(getDataFolder(), "lang.yml"));
|
||||||
if (locale.exists()) {
|
|
||||||
getLog().info("Found lang.yml - loading messages...");
|
|
||||||
try {
|
|
||||||
localeManager.loadFromFile(locale);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// register commands
|
// register commands
|
||||||
commandManager = new BukkitCommand(this);
|
commandManager = new BukkitCommand(this);
|
||||||
@ -307,26 +249,10 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
calculatorFactory = new BukkitCalculatorFactory(this);
|
calculatorFactory = new BukkitCalculatorFactory(this);
|
||||||
cachedStateManager = new CachedStateManager();
|
cachedStateManager = new CachedStateManager();
|
||||||
|
|
||||||
contextManager = new ContextManager<Player>() {
|
// setup context manager
|
||||||
@Override
|
contextManager = new BukkitContextManager(this);
|
||||||
public Contexts formContexts(Player player, ImmutableContextSet contextSet) {
|
contextManager.registerCalculator(new WorldCalculator(this));
|
||||||
return new Contexts(
|
contextManager.registerCalculator(new LuckPermsCalculator<>(getConfiguration()), true);
|
||||||
contextSet,
|
|
||||||
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
|
|
||||||
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
|
|
||||||
true,
|
|
||||||
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
|
||||||
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
|
||||||
player.isOp()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
worldCalculator = new WorldCalculator(this);
|
|
||||||
contextManager.registerCalculator(worldCalculator);
|
|
||||||
|
|
||||||
LuckPermsCalculator<Player> staticCalculator = new LuckPermsCalculator<>(getConfiguration());
|
|
||||||
contextManager.registerCalculator(staticCalculator, true);
|
|
||||||
|
|
||||||
// Provide vault support
|
// Provide vault support
|
||||||
tryVaultHook(false);
|
tryVaultHook(false);
|
||||||
@ -465,7 +391,6 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
|||||||
localeManager = null;
|
localeManager = null;
|
||||||
cachedStateManager = null;
|
cachedStateManager = null;
|
||||||
contextManager = null;
|
contextManager = null;
|
||||||
worldCalculator = null;
|
|
||||||
calculatorFactory = null;
|
calculatorFactory = null;
|
||||||
updateTaskBuffer = null;
|
updateTaskBuffer = null;
|
||||||
verboseHandler = null;
|
verboseHandler = null;
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.bukkit.contexts;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Contexts;
|
||||||
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
|
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class BukkitContextManager extends ContextManager<Player> {
|
||||||
|
private final LPBukkitPlugin plugin;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Contexts formContexts(Player subject, ImmutableContextSet contextSet) {
|
||||||
|
return new Contexts(
|
||||||
|
contextSet,
|
||||||
|
plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
|
||||||
|
plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
|
||||||
|
true,
|
||||||
|
plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
||||||
|
plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
||||||
|
subject.isOp()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.bukkit.messaging;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||||
|
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||||
|
import me.lucko.luckperms.common.messaging.MessagingFactory;
|
||||||
|
|
||||||
|
public class BukkitMessagingFactory extends MessagingFactory<LPBukkitPlugin> {
|
||||||
|
public BukkitMessagingFactory(LPBukkitPlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected InternalMessagingService getServiceFor(String messagingType) {
|
||||||
|
if (messagingType.equals("bungee")) {
|
||||||
|
BungeeMessagingService bungeeMessaging = new BungeeMessagingService(getPlugin());
|
||||||
|
bungeeMessaging.init();
|
||||||
|
return bungeeMessaging;
|
||||||
|
} else if (messagingType.equals("lilypad")) {
|
||||||
|
if (getPlugin().getServer().getPluginManager().getPlugin("LilyPad-Connect") == null) {
|
||||||
|
getPlugin().getLog().warn("LilyPad-Connect plugin not present.");
|
||||||
|
} else {
|
||||||
|
LilyPadMessagingService lilyPadMessaging = new LilyPadMessagingService(getPlugin());
|
||||||
|
lilyPadMessaging.init();
|
||||||
|
return lilyPadMessaging;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getServiceFor(messagingType);
|
||||||
|
}
|
||||||
|
}
|
@ -34,13 +34,14 @@ import me.lucko.luckperms.api.context.ContextSet;
|
|||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
import me.lucko.luckperms.bungee.calculators.BungeeCalculatorFactory;
|
import me.lucko.luckperms.bungee.calculators.BungeeCalculatorFactory;
|
||||||
import me.lucko.luckperms.bungee.contexts.BackendServerCalculator;
|
import me.lucko.luckperms.bungee.contexts.BackendServerCalculator;
|
||||||
import me.lucko.luckperms.bungee.messaging.BungeeMessagingService;
|
import me.lucko.luckperms.bungee.contexts.BungeeContextManager;
|
||||||
import me.lucko.luckperms.bungee.messaging.RedisBungeeMessagingService;
|
import me.lucko.luckperms.bungee.messaging.BungeeMessagingFactory;
|
||||||
import me.lucko.luckperms.bungee.util.RedisBungeeUtil;
|
import me.lucko.luckperms.bungee.util.RedisBungeeUtil;
|
||||||
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
||||||
import me.lucko.luckperms.common.api.ApiHandler;
|
import me.lucko.luckperms.common.api.ApiHandler;
|
||||||
import me.lucko.luckperms.common.api.ApiProvider;
|
import me.lucko.luckperms.common.api.ApiProvider;
|
||||||
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
||||||
|
import me.lucko.luckperms.common.buffers.UpdateTaskBuffer;
|
||||||
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.commands.CommandManager;
|
import me.lucko.luckperms.common.commands.CommandManager;
|
||||||
@ -62,8 +63,6 @@ import me.lucko.luckperms.common.managers.GroupManager;
|
|||||||
import me.lucko.luckperms.common.managers.TrackManager;
|
import me.lucko.luckperms.common.managers.TrackManager;
|
||||||
import me.lucko.luckperms.common.managers.UserManager;
|
import me.lucko.luckperms.common.managers.UserManager;
|
||||||
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||||
import me.lucko.luckperms.common.messaging.NoopMessagingService;
|
|
||||||
import me.lucko.luckperms.common.messaging.RedisMessagingService;
|
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsScheduler;
|
import me.lucko.luckperms.common.plugin.LuckPermsScheduler;
|
||||||
@ -73,7 +72,6 @@ import me.lucko.luckperms.common.storage.StorageType;
|
|||||||
import me.lucko.luckperms.common.storage.backing.file.FileWatcher;
|
import me.lucko.luckperms.common.storage.backing.file.FileWatcher;
|
||||||
import me.lucko.luckperms.common.tasks.CacheHousekeepingTask;
|
import me.lucko.luckperms.common.tasks.CacheHousekeepingTask;
|
||||||
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
|
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
|
||||||
import me.lucko.luckperms.common.tasks.UpdateTask;
|
|
||||||
import me.lucko.luckperms.common.treeview.PermissionVault;
|
import me.lucko.luckperms.common.treeview.PermissionVault;
|
||||||
import me.lucko.luckperms.common.utils.UuidCache;
|
import me.lucko.luckperms.common.utils.UuidCache;
|
||||||
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
||||||
@ -158,68 +156,14 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
storage = StorageFactory.getInstance(this, StorageType.H2);
|
storage = StorageFactory.getInstance(this, StorageType.H2);
|
||||||
|
|
||||||
// initialise messaging
|
// initialise messaging
|
||||||
String messagingType = getConfiguration().get(ConfigKeys.MESSAGING_SERVICE).toLowerCase();
|
messagingService = new BungeeMessagingFactory(this).getInstance();
|
||||||
if (messagingType.equals("none") && getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
|
|
||||||
messagingType = "redis";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!messagingType.equals("none")) {
|
|
||||||
getLog().info("Loading messaging service... [" + messagingType.toUpperCase() + "]");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messagingType.equals("redis")) {
|
|
||||||
if (getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
|
|
||||||
RedisMessagingService redis = new RedisMessagingService(this);
|
|
||||||
try {
|
|
||||||
redis.init(getConfiguration().get(ConfigKeys.REDIS_ADDRESS), getConfiguration().get(ConfigKeys.REDIS_PASSWORD));
|
|
||||||
messagingService = redis;
|
|
||||||
} catch (Exception e) {
|
|
||||||
getLog().warn("Couldn't load redis...");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
getLog().warn("Messaging Service was set to redis, but redis is not enabled!");
|
|
||||||
}
|
|
||||||
} else if (messagingType.equals("bungee")) {
|
|
||||||
BungeeMessagingService bungeeMessaging = new BungeeMessagingService(this);
|
|
||||||
bungeeMessaging.init();
|
|
||||||
messagingService = bungeeMessaging;
|
|
||||||
} else if (messagingType.equals("redisbungee")) {
|
|
||||||
if (getProxy().getPluginManager().getPlugin("RedisBungee") == null) {
|
|
||||||
getLog().warn("RedisBungee plugin not present.");
|
|
||||||
} else {
|
|
||||||
RedisBungeeMessagingService redisBungeeMessaging = new RedisBungeeMessagingService(this);
|
|
||||||
redisBungeeMessaging.init();
|
|
||||||
messagingService = redisBungeeMessaging;
|
|
||||||
}
|
|
||||||
} else if (!messagingType.equals("none")) {
|
|
||||||
getLog().warn("Messaging service '" + messagingType + "' not recognised.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messagingService == null) {
|
|
||||||
messagingService = new NoopMessagingService();
|
|
||||||
}
|
|
||||||
|
|
||||||
// setup the update task buffer
|
// setup the update task buffer
|
||||||
updateTaskBuffer = new BufferedRequest<Void>(1000L, this::doAsync) {
|
updateTaskBuffer = new UpdateTaskBuffer(this);
|
||||||
@Override
|
|
||||||
protected Void perform() {
|
|
||||||
new UpdateTask(LPBungeePlugin.this).run();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// load locale
|
// load locale
|
||||||
localeManager = new SimpleLocaleManager();
|
localeManager = new SimpleLocaleManager();
|
||||||
File locale = new File(getDataFolder(), "lang.yml");
|
localeManager.tryLoad(this, new File(getDataFolder(), "lang.yml"));
|
||||||
if (locale.exists()) {
|
|
||||||
getLog().info("Found lang.yml - loading messages...");
|
|
||||||
try {
|
|
||||||
localeManager.loadFromFile(locale);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// register commands
|
// register commands
|
||||||
commandManager = new CommandManager(this);
|
commandManager = new CommandManager(this);
|
||||||
@ -237,26 +181,10 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
calculatorFactory = new BungeeCalculatorFactory(this);
|
calculatorFactory = new BungeeCalculatorFactory(this);
|
||||||
cachedStateManager = new CachedStateManager();
|
cachedStateManager = new CachedStateManager();
|
||||||
|
|
||||||
contextManager = new ContextManager<ProxiedPlayer>() {
|
// setup context manager
|
||||||
@Override
|
contextManager = new BungeeContextManager(this);
|
||||||
public Contexts formContexts(ProxiedPlayer player, ImmutableContextSet contextSet) {
|
contextManager.registerCalculator(new BackendServerCalculator(this));
|
||||||
return new Contexts(
|
contextManager.registerCalculator(new LuckPermsCalculator<>(getConfiguration()), true);
|
||||||
contextSet,
|
|
||||||
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
|
|
||||||
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
|
|
||||||
true,
|
|
||||||
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
|
||||||
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
BackendServerCalculator serverCalculator = new BackendServerCalculator(this);
|
|
||||||
contextManager.registerCalculator(serverCalculator);
|
|
||||||
|
|
||||||
LuckPermsCalculator<ProxiedPlayer> staticCalculator = new LuckPermsCalculator<>(getConfiguration());
|
|
||||||
contextManager.registerCalculator(staticCalculator, true);
|
|
||||||
|
|
||||||
// register with the LP API
|
// register with the LP API
|
||||||
apiProvider = new ApiProvider(this);
|
apiProvider = new ApiProvider(this);
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.bungee.contexts;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Contexts;
|
||||||
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
|
import me.lucko.luckperms.bungee.LPBungeePlugin;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
|
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class BungeeContextManager extends ContextManager<ProxiedPlayer> {
|
||||||
|
private final LPBungeePlugin plugin;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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),
|
||||||
|
true,
|
||||||
|
plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
||||||
|
plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.bungee.messaging;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.bungee.LPBungeePlugin;
|
||||||
|
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||||
|
import me.lucko.luckperms.common.messaging.MessagingFactory;
|
||||||
|
|
||||||
|
public class BungeeMessagingFactory extends MessagingFactory<LPBungeePlugin> {
|
||||||
|
public BungeeMessagingFactory(LPBungeePlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected InternalMessagingService getServiceFor(String messagingType) {
|
||||||
|
if (messagingType.equals("bungee")) {
|
||||||
|
BungeeMessagingService bungeeMessaging = new BungeeMessagingService(getPlugin());
|
||||||
|
bungeeMessaging.init();
|
||||||
|
return bungeeMessaging;
|
||||||
|
} else if (messagingType.equals("redisbungee")) {
|
||||||
|
if (getPlugin().getProxy().getPluginManager().getPlugin("RedisBungee") == null) {
|
||||||
|
getPlugin().getLog().warn("RedisBungee plugin not present.");
|
||||||
|
} else {
|
||||||
|
RedisBungeeMessagingService redisBungeeMessaging = new RedisBungeeMessagingService(getPlugin());
|
||||||
|
redisBungeeMessaging.init();
|
||||||
|
return redisBungeeMessaging;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getServiceFor(messagingType);
|
||||||
|
}
|
||||||
|
}
|
@ -79,57 +79,57 @@ public class StorageDelegate implements Storage {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> logAction(@NonNull LogEntry entry) {
|
public CompletableFuture<Boolean> logAction(@NonNull LogEntry entry) {
|
||||||
return handle.force().logAction(entry);
|
return handle.noBuffer().logAction(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Log> getLog() {
|
public CompletableFuture<Log> getLog() {
|
||||||
return handle.force().getLog().thenApply(log -> log == null ? null : new LogDelegate(log));
|
return handle.noBuffer().getLog().thenApply(log -> log == null ? null : new LogDelegate(log));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> loadUser(@NonNull UUID uuid, String username) {
|
public CompletableFuture<Boolean> loadUser(@NonNull UUID uuid, String username) {
|
||||||
return handle.force().loadUser(uuid, username == null ? null : checkUsername(username));
|
return handle.noBuffer().loadUser(uuid, username == null ? null : checkUsername(username));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> saveUser(@NonNull User user) {
|
public CompletableFuture<Boolean> saveUser(@NonNull User user) {
|
||||||
return handle.force().saveUser(UserDelegate.cast(user));
|
return handle.noBuffer().saveUser(UserDelegate.cast(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> cleanupUsers() {
|
public CompletableFuture<Boolean> cleanupUsers() {
|
||||||
return handle.force().cleanupUsers();
|
return handle.noBuffer().cleanupUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Set<UUID>> getUniqueUsers() {
|
public CompletableFuture<Set<UUID>> getUniqueUsers() {
|
||||||
return handle.force().getUniqueUsers();
|
return handle.noBuffer().getUniqueUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(@NonNull String permission) {
|
public CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(@NonNull String permission) {
|
||||||
return handle.force().getUsersWithPermission(permission);
|
return handle.noBuffer().getUsersWithPermission(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> createAndLoadGroup(@NonNull String name) {
|
public CompletableFuture<Boolean> createAndLoadGroup(@NonNull String name) {
|
||||||
return handle.force().createAndLoadGroup(checkName(name), CreationCause.API);
|
return handle.noBuffer().createAndLoadGroup(checkName(name), CreationCause.API);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> loadGroup(@NonNull String name) {
|
public CompletableFuture<Boolean> loadGroup(@NonNull String name) {
|
||||||
return handle.force().loadGroup(checkName(name));
|
return handle.noBuffer().loadGroup(checkName(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> loadAllGroups() {
|
public CompletableFuture<Boolean> loadAllGroups() {
|
||||||
return handle.force().loadAllGroups();
|
return handle.noBuffer().loadAllGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> saveGroup(@NonNull Group group) {
|
public CompletableFuture<Boolean> saveGroup(@NonNull Group group) {
|
||||||
return handle.force().saveGroup(GroupDelegate.cast(group));
|
return handle.noBuffer().saveGroup(GroupDelegate.cast(group));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -137,51 +137,51 @@ public class StorageDelegate implements Storage {
|
|||||||
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().get(ConfigKeys.DEFAULT_GROUP_NAME))) {
|
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().get(ConfigKeys.DEFAULT_GROUP_NAME))) {
|
||||||
throw new IllegalArgumentException("Cannot delete the default group.");
|
throw new IllegalArgumentException("Cannot delete the default group.");
|
||||||
}
|
}
|
||||||
return handle.force().deleteGroup(GroupDelegate.cast(group), DeletionCause.API);
|
return handle.noBuffer().deleteGroup(GroupDelegate.cast(group), DeletionCause.API);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(@NonNull String permission) {
|
public CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(@NonNull String permission) {
|
||||||
return handle.force().getGroupsWithPermission(permission);
|
return handle.noBuffer().getGroupsWithPermission(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> createAndLoadTrack(@NonNull String name) {
|
public CompletableFuture<Boolean> createAndLoadTrack(@NonNull String name) {
|
||||||
return handle.force().createAndLoadTrack(checkName(name), CreationCause.API);
|
return handle.noBuffer().createAndLoadTrack(checkName(name), CreationCause.API);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> loadTrack(@NonNull String name) {
|
public CompletableFuture<Boolean> loadTrack(@NonNull String name) {
|
||||||
return handle.force().loadTrack(checkName(name));
|
return handle.noBuffer().loadTrack(checkName(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> loadAllTracks() {
|
public CompletableFuture<Boolean> loadAllTracks() {
|
||||||
return handle.force().loadAllTracks();
|
return handle.noBuffer().loadAllTracks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> saveTrack(@NonNull Track track) {
|
public CompletableFuture<Boolean> saveTrack(@NonNull Track track) {
|
||||||
return handle.force().saveTrack(TrackDelegate.cast(track));
|
return handle.noBuffer().saveTrack(TrackDelegate.cast(track));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> deleteTrack(@NonNull Track track) {
|
public CompletableFuture<Boolean> deleteTrack(@NonNull Track track) {
|
||||||
return handle.force().deleteTrack(TrackDelegate.cast(track), DeletionCause.API);
|
return handle.noBuffer().deleteTrack(TrackDelegate.cast(track), DeletionCause.API);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Boolean> saveUUIDData(@NonNull String username, @NonNull UUID uuid) {
|
public CompletableFuture<Boolean> saveUUIDData(@NonNull String username, @NonNull UUID uuid) {
|
||||||
return handle.force().saveUUIDData(checkUsername(username), uuid);
|
return handle.noBuffer().saveUUIDData(checkUsername(username), uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<UUID> getUUID(@NonNull String username) {
|
public CompletableFuture<UUID> getUUID(@NonNull String username) {
|
||||||
return handle.force().getUUID(checkUsername(username));
|
return handle.noBuffer().getUUID(checkUsername(username));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<String> getName(@NonNull UUID uuid) {
|
public CompletableFuture<String> getName(@NonNull UUID uuid) {
|
||||||
return handle.force().getName(uuid);
|
return handle.noBuffer().getName(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ import java.util.function.Supplier;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public abstract class BufferedRequest<T> {
|
public abstract class BufferedRequest<T> {
|
||||||
private final long bufferTimeMillis;
|
private final long bufferTimeMillis;
|
||||||
|
private final long sleepInterval;
|
||||||
private final Executor executor;
|
private final Executor executor;
|
||||||
|
|
||||||
private WeakReference<Processor<T>> processor = null;
|
private WeakReference<Processor<T>> processor = null;
|
||||||
@ -60,7 +61,7 @@ public abstract class BufferedRequest<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Processor<T> p = new Processor<>(bufferTimeMillis, this::perform);
|
Processor<T> p = new Processor<>(bufferTimeMillis, sleepInterval, this::perform);
|
||||||
executor.execute(p);
|
executor.execute(p);
|
||||||
processor = new WeakReference<>(p);
|
processor = new WeakReference<>(p);
|
||||||
return p.get();
|
return p.get();
|
||||||
@ -79,6 +80,7 @@ public abstract class BufferedRequest<T> {
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
private static class Processor<R> implements Runnable {
|
private static class Processor<R> implements Runnable {
|
||||||
private final long delayMillis;
|
private final long delayMillis;
|
||||||
|
private final long sleepMillis;
|
||||||
private final Supplier<R> supplier;
|
private final Supplier<R> supplier;
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
private final CompletableFuture<R> future = new CompletableFuture<>();
|
private final CompletableFuture<R> future = new CompletableFuture<>();
|
||||||
@ -108,7 +110,7 @@ public abstract class BufferedRequest<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500);
|
Thread.sleep(sleepMillis);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.common.buffers;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.tasks.UpdateTask;
|
||||||
|
|
||||||
|
public class UpdateTaskBuffer extends BufferedRequest<Void> {
|
||||||
|
private final LuckPermsPlugin plugin;
|
||||||
|
|
||||||
|
public UpdateTaskBuffer(LuckPermsPlugin plugin) {
|
||||||
|
super(250L, 50L, plugin::doAsync);
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void perform() {
|
||||||
|
new UpdateTask(plugin).run();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -173,7 +173,7 @@ public abstract class SubCommand<T> extends Command<T, Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void save(User user, Sender sender, LuckPermsPlugin plugin) {
|
public static void save(User user, Sender sender, LuckPermsPlugin plugin) {
|
||||||
boolean success = plugin.getStorage().force().saveUser(user).join();
|
boolean success = plugin.getStorage().noBuffer().saveUser(user).join();
|
||||||
|
|
||||||
if (sender.isImport()) {
|
if (sender.isImport()) {
|
||||||
user.getRefreshBuffer().request();
|
user.getRefreshBuffer().request();
|
||||||
@ -192,7 +192,7 @@ public abstract class SubCommand<T> extends Command<T, Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void save(Group group, Sender sender, LuckPermsPlugin plugin) {
|
public static void save(Group group, Sender sender, LuckPermsPlugin plugin) {
|
||||||
boolean success = plugin.getStorage().force().saveGroup(group).join();
|
boolean success = plugin.getStorage().noBuffer().saveGroup(group).join();
|
||||||
|
|
||||||
if (sender.isImport()) {
|
if (sender.isImport()) {
|
||||||
plugin.getUpdateTaskBuffer().request();
|
plugin.getUpdateTaskBuffer().request();
|
||||||
@ -211,7 +211,7 @@ public abstract class SubCommand<T> extends Command<T, Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void save(Track track, Sender sender, LuckPermsPlugin plugin) {
|
public static void save(Track track, Sender sender, LuckPermsPlugin plugin) {
|
||||||
boolean success = plugin.getStorage().force().saveTrack(track).join();
|
boolean success = plugin.getStorage().noBuffer().saveTrack(track).join();
|
||||||
|
|
||||||
if (sender.isImport()) {
|
if (sender.isImport()) {
|
||||||
plugin.getUpdateTaskBuffer().request();
|
plugin.getUpdateTaskBuffer().request();
|
||||||
|
@ -78,7 +78,7 @@ public class LogNotify extends SubCommand<Log> {
|
|||||||
user.removeIf(n -> n.getPermission().equalsIgnoreCase("luckperms.log.notify.ignoring"));
|
user.removeIf(n -> n.getPermission().equalsIgnoreCase("luckperms.log.notify.ignoring"));
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getStorage().force().saveUser(user).join();
|
plugin.getStorage().noBuffer().saveUser(user).join();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.locale;
|
package me.lucko.luckperms.common.locale;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,8 +34,27 @@ import java.io.File;
|
|||||||
*/
|
*/
|
||||||
public interface LocaleManager {
|
public interface LocaleManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to load from a locale file, and logs via the plugin if successful.
|
||||||
|
*
|
||||||
|
* @param plugin the plugin to log to
|
||||||
|
* @param file the file to load from
|
||||||
|
*/
|
||||||
|
void tryLoad(LuckPermsPlugin plugin, File file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a locale file
|
||||||
|
*
|
||||||
|
* @param file the file to load from
|
||||||
|
* @throws Exception if the process fails
|
||||||
|
*/
|
||||||
void loadFromFile(File file) throws Exception;
|
void loadFromFile(File file) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the size of loaded translations
|
||||||
|
*
|
||||||
|
* @return the size of the loaded translations
|
||||||
|
*/
|
||||||
int getSize();
|
int getSize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,10 +25,17 @@
|
|||||||
|
|
||||||
package me.lucko.luckperms.common.locale;
|
package me.lucko.luckperms.common.locale;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class NoopLocaleManager implements LocaleManager {
|
public class NoopLocaleManager implements LocaleManager {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tryLoad(LuckPermsPlugin plugin, File file) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadFromFile(File file) throws Exception {
|
public void loadFromFile(File file) throws Exception {
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ package me.lucko.luckperms.common.locale;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@ -40,6 +42,17 @@ public class SimpleLocaleManager implements LocaleManager {
|
|||||||
private Map<Message, String> messages = ImmutableMap.of();
|
private Map<Message, String> messages = ImmutableMap.of();
|
||||||
private Map<CommandSpec, CommandSpec.CommandSpecData> commands = ImmutableMap.of();
|
private Map<CommandSpec, CommandSpec.CommandSpecData> commands = ImmutableMap.of();
|
||||||
|
|
||||||
|
public void tryLoad(LuckPermsPlugin plugin, File file) {
|
||||||
|
if (file.exists()) {
|
||||||
|
plugin.getLog().info("Found lang.yml - loading messages...");
|
||||||
|
try {
|
||||||
|
loadFromFile(file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void loadFromFile(File file) throws Exception {
|
public void loadFromFile(File file) throws Exception {
|
||||||
try (BufferedReader reader = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8)) {
|
try (BufferedReader reader = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8)) {
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
package me.lucko.luckperms.common.messaging;
|
package me.lucko.luckperms.common.messaging;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
@ -47,9 +46,8 @@ import java.util.function.Consumer;
|
|||||||
/**
|
/**
|
||||||
* An abstract implementation of {@link me.lucko.luckperms.api.MessagingService}.
|
* An abstract implementation of {@link me.lucko.luckperms.api.MessagingService}.
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
public abstract class AbstractMessagingService implements InternalMessagingService {
|
public abstract class AbstractMessagingService implements InternalMessagingService {
|
||||||
public static final String CHANNEL = "lpuc";
|
protected static final String CHANNEL = "lpuc";
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final LuckPermsPlugin plugin;
|
private final LuckPermsPlugin plugin;
|
||||||
@ -57,17 +55,19 @@ public abstract class AbstractMessagingService implements InternalMessagingServi
|
|||||||
@Getter
|
@Getter
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
private final Set<UUID> receivedMessages = Collections.synchronizedSet(new HashSet<>());
|
private final Set<UUID> receivedMessages;
|
||||||
private final Gson gson = new Gson();
|
private final Gson gson;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final BufferedRequest<Void> updateBuffer = new BufferedRequest<Void>(3000L, r -> getPlugin().doAsync(r)) {
|
private final BufferedRequest<Void> updateBuffer;
|
||||||
@Override
|
|
||||||
protected Void perform() {
|
public AbstractMessagingService(LuckPermsPlugin plugin, String name) {
|
||||||
pushUpdate();
|
this.plugin = plugin;
|
||||||
return null;
|
this.name = name;
|
||||||
}
|
this.receivedMessages = Collections.synchronizedSet(new HashSet<>());
|
||||||
};
|
this.gson = new Gson();
|
||||||
|
this.updateBuffer = new PushUpdateBuffer(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void sendMessage(String channel, String message);
|
protected abstract void sendMessage(String channel, String message);
|
||||||
|
|
||||||
@ -164,4 +164,16 @@ public abstract class AbstractMessagingService implements InternalMessagingServi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final class PushUpdateBuffer extends BufferedRequest<Void> {
|
||||||
|
public PushUpdateBuffer(LuckPermsPlugin plugin) {
|
||||||
|
super(3000L, 200L, plugin::doAsync);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void perform() {
|
||||||
|
pushUpdate();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.common.messaging;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MessagingFactory<P extends LuckPermsPlugin> {
|
||||||
|
|
||||||
|
@Getter(AccessLevel.PROTECTED)
|
||||||
|
private final P plugin;
|
||||||
|
|
||||||
|
public final InternalMessagingService getInstance() {
|
||||||
|
String messagingType = plugin.getConfiguration().get(ConfigKeys.MESSAGING_SERVICE).toLowerCase();
|
||||||
|
if (messagingType.equals("none") && plugin.getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
|
||||||
|
messagingType = "redis";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (messagingType.equals("none")) {
|
||||||
|
return new NoopMessagingService();
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.getLog().info("Loading messaging service... [" + messagingType.toUpperCase() + "]");
|
||||||
|
|
||||||
|
InternalMessagingService service = getServiceFor(messagingType);
|
||||||
|
if (service != null) {
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.getLog().warn("Messaging service '" + messagingType + "' not recognised.");
|
||||||
|
return new NoopMessagingService();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected InternalMessagingService getServiceFor(String messagingType) {
|
||||||
|
if (messagingType.equals("redis")) {
|
||||||
|
if (plugin.getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
|
||||||
|
RedisMessagingService redis = new RedisMessagingService(plugin);
|
||||||
|
try {
|
||||||
|
redis.init(plugin.getConfiguration().get(ConfigKeys.REDIS_ADDRESS), plugin.getConfiguration().get(ConfigKeys.REDIS_PASSWORD));
|
||||||
|
return redis;
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLog().warn("Couldn't load redis...");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
plugin.getLog().warn("Messaging Service was set to redis, but redis is not enabled!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -70,7 +70,7 @@ public class User extends PermissionHolder implements Identifiable<UserIdentifie
|
|||||||
private final UserCache userData = new UserCache(this);
|
private final UserCache userData = new UserCache(this);
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private BufferedRequest<Void> refreshBuffer = new BufferedRequest<Void>(1000L, r -> getPlugin().doAsync(r)) {
|
private BufferedRequest<Void> refreshBuffer = new BufferedRequest<Void>(250L, 50L, r -> getPlugin().doAsync(r)) {
|
||||||
@Override
|
@Override
|
||||||
protected Void perform() {
|
protected Void perform() {
|
||||||
refreshPermissions();
|
refreshPermissions();
|
||||||
|
@ -58,8 +58,8 @@ import java.util.function.Supplier;
|
|||||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class AbstractStorage implements Storage {
|
public class AbstractStorage implements Storage {
|
||||||
public static Storage wrap(LuckPermsPlugin plugin, AbstractBacking backing) {
|
public static Storage wrap(LuckPermsPlugin plugin, AbstractBacking backing) {
|
||||||
BufferedOutputStorage bufferedDs = BufferedOutputStorage.wrap(PhasedStorage.wrap(new AbstractStorage(plugin, backing)), 1000L);
|
BufferedOutputStorage bufferedDs = BufferedOutputStorage.wrap(PhasedStorage.wrap(new AbstractStorage(plugin, backing)), 250L);
|
||||||
plugin.getScheduler().asyncRepeating(bufferedDs, 5L);
|
plugin.getScheduler().asyncRepeating(bufferedDs, 2L);
|
||||||
return bufferedDs;
|
return bufferedDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ public class AbstractStorage implements Storage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Storage force() {
|
public Storage noBuffer() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public interface Storage {
|
|||||||
|
|
||||||
void setAcceptingLogins(boolean acceptingLogins);
|
void setAcceptingLogins(boolean acceptingLogins);
|
||||||
|
|
||||||
Storage force();
|
Storage noBuffer();
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ public class MongoDBBacking extends AbstractBacking {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean cleanupUsers() {
|
public boolean cleanupUsers() {
|
||||||
return true; // TODO
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -496,7 +496,7 @@ public class SQLBacking extends AbstractBacking {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean cleanupUsers() {
|
public boolean cleanupUsers() {
|
||||||
return true; // TODO
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,10 +34,8 @@ import me.lucko.luckperms.common.buffers.Buffer;
|
|||||||
import me.lucko.luckperms.common.model.Group;
|
import me.lucko.luckperms.common.model.Group;
|
||||||
import me.lucko.luckperms.common.model.Track;
|
import me.lucko.luckperms.common.model.Track;
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.references.UserIdentifier;
|
|
||||||
import me.lucko.luckperms.common.storage.Storage;
|
import me.lucko.luckperms.common.storage.Storage;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
@ -55,7 +53,6 @@ public class BufferedOutputStorage implements Storage, Runnable {
|
|||||||
private final Buffer<User, Boolean> userOutputBuffer = Buffer.of(user -> BufferedOutputStorage.this.backing.saveUser(user).join());
|
private final Buffer<User, Boolean> userOutputBuffer = Buffer.of(user -> BufferedOutputStorage.this.backing.saveUser(user).join());
|
||||||
private final Buffer<Group, Boolean> groupOutputBuffer = Buffer.of(group -> BufferedOutputStorage.this.backing.saveGroup(group).join());
|
private final Buffer<Group, Boolean> groupOutputBuffer = Buffer.of(group -> BufferedOutputStorage.this.backing.saveGroup(group).join());
|
||||||
private final Buffer<Track, Boolean> trackOutputBuffer = Buffer.of(track -> BufferedOutputStorage.this.backing.saveTrack(track).join());
|
private final Buffer<Track, Boolean> trackOutputBuffer = Buffer.of(track -> BufferedOutputStorage.this.backing.saveTrack(track).join());
|
||||||
private final Buffer<UserIdentifier, Boolean> uuidDataOutputBuffer = Buffer.of(userIdentifier -> BufferedOutputStorage.this.backing.saveUUIDData(userIdentifier.getUsername().get(), userIdentifier.getUuid()).join());
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -70,11 +67,10 @@ public class BufferedOutputStorage implements Storage, Runnable {
|
|||||||
userOutputBuffer.flush(flushTime);
|
userOutputBuffer.flush(flushTime);
|
||||||
groupOutputBuffer.flush(flushTime);
|
groupOutputBuffer.flush(flushTime);
|
||||||
trackOutputBuffer.flush(flushTime);
|
trackOutputBuffer.flush(flushTime);
|
||||||
userOutputBuffer.flush(flushTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Storage force() {
|
public Storage noBuffer() {
|
||||||
return backing;
|
return backing;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,17 +95,11 @@ public class BufferedOutputStorage implements Storage, Runnable {
|
|||||||
return trackOutputBuffer.enqueue(track);
|
return trackOutputBuffer.enqueue(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<Boolean> saveUUIDData(String username, UUID uuid) {
|
|
||||||
return uuidDataOutputBuffer.enqueue(UserIdentifier.of(uuid, username));
|
|
||||||
}
|
|
||||||
|
|
||||||
private interface Exclude {
|
private interface Exclude {
|
||||||
Storage force();
|
Storage noBuffer();
|
||||||
CompletableFuture<Void> shutdown();
|
CompletableFuture<Void> shutdown();
|
||||||
CompletableFuture<Boolean> saveUser(User user);
|
CompletableFuture<Boolean> saveUser(User user);
|
||||||
CompletableFuture<Boolean> saveGroup(Group group);
|
CompletableFuture<Boolean> saveGroup(Group group);
|
||||||
CompletableFuture<Boolean> saveTrack(Track track);
|
CompletableFuture<Boolean> saveTrack(Track track);
|
||||||
CompletableFuture<Boolean> saveUUIDData(String username, UUID uuid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class PhasedStorage implements Storage {
|
|||||||
private final Phaser phaser = new Phaser();
|
private final Phaser phaser = new Phaser();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Storage force() {
|
public Storage noBuffer() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public class PhasedStorage implements Storage {
|
|||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
// Wait for other threads to finish.
|
// Wait for other threads to finish.
|
||||||
try {
|
try {
|
||||||
phaser.awaitAdvanceInterruptibly(phaser.getPhase(), 5, TimeUnit.SECONDS);
|
phaser.awaitAdvanceInterruptibly(phaser.getPhase(), 10, TimeUnit.SECONDS);
|
||||||
} catch (InterruptedException | TimeoutException e) {
|
} catch (InterruptedException | TimeoutException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -46,32 +46,32 @@ public class LoginHelper {
|
|||||||
|
|
||||||
final UuidCache cache = plugin.getUuidCache();
|
final UuidCache cache = plugin.getUuidCache();
|
||||||
if (!plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUIDS)) {
|
if (!plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUIDS)) {
|
||||||
UUID uuid = plugin.getStorage().force().getUUID(username).join();
|
UUID uuid = plugin.getStorage().noBuffer().getUUID(username).join();
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
cache.addToCache(u, uuid);
|
cache.addToCache(u, uuid);
|
||||||
} else {
|
} else {
|
||||||
// No previous data for this player
|
// No previous data for this player
|
||||||
plugin.getApiProvider().getEventFactory().handleUserFirstLogin(u, username);
|
plugin.getApiProvider().getEventFactory().handleUserFirstLogin(u, username);
|
||||||
cache.addToCache(u, u);
|
cache.addToCache(u, u);
|
||||||
CompletableFuture<Boolean> future = plugin.getStorage().force().saveUUIDData(username, u);
|
CompletableFuture<Boolean> future = plugin.getStorage().noBuffer().saveUUIDData(username, u);
|
||||||
if (joinUuidSave) {
|
if (joinUuidSave) {
|
||||||
future.join();
|
future.join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String name = plugin.getStorage().force().getName(u).join();
|
String name = plugin.getStorage().noBuffer().getName(u).join();
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
plugin.getApiProvider().getEventFactory().handleUserFirstLogin(u, username);
|
plugin.getApiProvider().getEventFactory().handleUserFirstLogin(u, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Online mode, no cache needed. This is just for name -> uuid lookup.
|
// Online mode, no cache needed. This is just for name -> uuid lookup.
|
||||||
CompletableFuture<Boolean> future = plugin.getStorage().force().saveUUIDData(username, u);
|
CompletableFuture<Boolean> future = plugin.getStorage().noBuffer().saveUUIDData(username, u);
|
||||||
if (joinUuidSave) {
|
if (joinUuidSave) {
|
||||||
future.join();
|
future.join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getStorage().force().loadUser(cache.getUUID(u), username).join();
|
plugin.getStorage().noBuffer().loadUser(cache.getUUID(u), username).join();
|
||||||
User user = plugin.getUserManager().getIfLoaded(cache.getUUID(u));
|
User user = plugin.getUserManager().getIfLoaded(cache.getUUID(u));
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
plugin.getLog().warn("Failed to load user: " + username);
|
plugin.getLog().warn("Failed to load user: " + username);
|
||||||
@ -87,7 +87,7 @@ public class LoginHelper {
|
|||||||
|
|
||||||
// If they were given a default, persist the new assignments back to the storage.
|
// If they were given a default, persist the new assignments back to the storage.
|
||||||
if (save) {
|
if (save) {
|
||||||
plugin.getStorage().force().saveUser(user).join();
|
plugin.getStorage().noBuffer().saveUser(user).join();
|
||||||
}
|
}
|
||||||
|
|
||||||
user.preCalculateData(false); // Pretty nasty calculation call. Sets up the caching system so data is ready when the user joins.
|
user.preCalculateData(false); // Pretty nasty calculation call. Sets up the caching system so data is ready when the user joins.
|
||||||
|
@ -32,12 +32,12 @@ import com.google.inject.Inject;
|
|||||||
import me.lucko.luckperms.api.Contexts;
|
import me.lucko.luckperms.api.Contexts;
|
||||||
import me.lucko.luckperms.api.LuckPermsApi;
|
import me.lucko.luckperms.api.LuckPermsApi;
|
||||||
import me.lucko.luckperms.api.PlatformType;
|
import me.lucko.luckperms.api.PlatformType;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
|
||||||
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
||||||
import me.lucko.luckperms.common.api.ApiHandler;
|
import me.lucko.luckperms.common.api.ApiHandler;
|
||||||
import me.lucko.luckperms.common.api.ApiProvider;
|
import me.lucko.luckperms.common.api.ApiProvider;
|
||||||
import me.lucko.luckperms.common.backup.ImporterSender;
|
import me.lucko.luckperms.common.backup.ImporterSender;
|
||||||
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
||||||
|
import me.lucko.luckperms.common.buffers.UpdateTaskBuffer;
|
||||||
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
||||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||||
import me.lucko.luckperms.common.commands.abstraction.Command;
|
import me.lucko.luckperms.common.commands.abstraction.Command;
|
||||||
@ -55,8 +55,6 @@ import me.lucko.luckperms.common.logging.SenderLogger;
|
|||||||
import me.lucko.luckperms.common.managers.GenericTrackManager;
|
import me.lucko.luckperms.common.managers.GenericTrackManager;
|
||||||
import me.lucko.luckperms.common.managers.TrackManager;
|
import me.lucko.luckperms.common.managers.TrackManager;
|
||||||
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||||
import me.lucko.luckperms.common.messaging.NoopMessagingService;
|
|
||||||
import me.lucko.luckperms.common.messaging.RedisMessagingService;
|
|
||||||
import me.lucko.luckperms.common.model.User;
|
import me.lucko.luckperms.common.model.User;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsScheduler;
|
import me.lucko.luckperms.common.plugin.LuckPermsScheduler;
|
||||||
@ -66,16 +64,16 @@ import me.lucko.luckperms.common.storage.StorageType;
|
|||||||
import me.lucko.luckperms.common.storage.backing.file.FileWatcher;
|
import me.lucko.luckperms.common.storage.backing.file.FileWatcher;
|
||||||
import me.lucko.luckperms.common.tasks.CacheHousekeepingTask;
|
import me.lucko.luckperms.common.tasks.CacheHousekeepingTask;
|
||||||
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
|
import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
|
||||||
import me.lucko.luckperms.common.tasks.UpdateTask;
|
|
||||||
import me.lucko.luckperms.common.treeview.PermissionVault;
|
import me.lucko.luckperms.common.treeview.PermissionVault;
|
||||||
import me.lucko.luckperms.common.utils.UuidCache;
|
import me.lucko.luckperms.common.utils.UuidCache;
|
||||||
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
||||||
import me.lucko.luckperms.sponge.calculators.SpongeCalculatorFactory;
|
import me.lucko.luckperms.sponge.calculators.SpongeCalculatorFactory;
|
||||||
import me.lucko.luckperms.sponge.commands.SpongeMainCommand;
|
import me.lucko.luckperms.sponge.commands.SpongeMainCommand;
|
||||||
|
import me.lucko.luckperms.sponge.contexts.SpongeContextManager;
|
||||||
import me.lucko.luckperms.sponge.contexts.WorldCalculator;
|
import me.lucko.luckperms.sponge.contexts.WorldCalculator;
|
||||||
import me.lucko.luckperms.sponge.managers.SpongeGroupManager;
|
import me.lucko.luckperms.sponge.managers.SpongeGroupManager;
|
||||||
import me.lucko.luckperms.sponge.managers.SpongeUserManager;
|
import me.lucko.luckperms.sponge.managers.SpongeUserManager;
|
||||||
import me.lucko.luckperms.sponge.messaging.BungeeMessagingService;
|
import me.lucko.luckperms.sponge.messaging.SpongeMessagingFactory;
|
||||||
import me.lucko.luckperms.sponge.service.LuckPermsService;
|
import me.lucko.luckperms.sponge.service.LuckPermsService;
|
||||||
import me.lucko.luckperms.sponge.service.model.LPPermissionService;
|
import me.lucko.luckperms.sponge.service.model.LPPermissionService;
|
||||||
import me.lucko.luckperms.sponge.service.model.LPSubjectCollection;
|
import me.lucko.luckperms.sponge.service.model.LPSubjectCollection;
|
||||||
@ -208,60 +206,14 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
storage = StorageFactory.getInstance(this, StorageType.H2);
|
storage = StorageFactory.getInstance(this, StorageType.H2);
|
||||||
|
|
||||||
// initialise messaging
|
// initialise messaging
|
||||||
String messagingType = getConfiguration().get(ConfigKeys.MESSAGING_SERVICE).toLowerCase();
|
messagingService = new SpongeMessagingFactory(this).getInstance();
|
||||||
if (messagingType.equals("none") && getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
|
|
||||||
messagingType = "redis";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!messagingType.equals("none")) {
|
|
||||||
getLog().info("Loading messaging service... [" + messagingType.toUpperCase() + "]");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messagingType.equals("redis")) {
|
|
||||||
if (getConfiguration().get(ConfigKeys.REDIS_ENABLED)) {
|
|
||||||
RedisMessagingService redis = new RedisMessagingService(this);
|
|
||||||
try {
|
|
||||||
redis.init(getConfiguration().get(ConfigKeys.REDIS_ADDRESS), getConfiguration().get(ConfigKeys.REDIS_PASSWORD));
|
|
||||||
messagingService = redis;
|
|
||||||
} catch (Exception e) {
|
|
||||||
getLog().warn("Couldn't load redis...");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
getLog().warn("Messaging Service was set to redis, but redis is not enabled!");
|
|
||||||
}
|
|
||||||
} else if (messagingType.equals("bungee")) {
|
|
||||||
BungeeMessagingService bungeeMessaging = new BungeeMessagingService(this);
|
|
||||||
bungeeMessaging.init();
|
|
||||||
messagingService = bungeeMessaging;
|
|
||||||
} else if (!messagingType.equals("none")) {
|
|
||||||
getLog().warn("Messaging service '" + messagingType + "' not recognised.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messagingService == null) {
|
|
||||||
messagingService = new NoopMessagingService();
|
|
||||||
}
|
|
||||||
|
|
||||||
// setup the update task buffer
|
// setup the update task buffer
|
||||||
updateTaskBuffer = new BufferedRequest<Void>(1000L, this::doAsync) {
|
updateTaskBuffer = new UpdateTaskBuffer(this);
|
||||||
@Override
|
|
||||||
protected Void perform() {
|
|
||||||
new UpdateTask(LPSpongePlugin.this).run();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// load locale
|
// load locale
|
||||||
localeManager = new SimpleLocaleManager();
|
localeManager = new SimpleLocaleManager();
|
||||||
File locale = new File(getDataDirectory(), "lang.yml");
|
localeManager.tryLoad(this, new File(getDataDirectory(), "lang.yml"));
|
||||||
if (locale.exists()) {
|
|
||||||
getLog().info("Found lang.yml - loading messages...");
|
|
||||||
try {
|
|
||||||
localeManager.loadFromFile(locale);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// register commands
|
// register commands
|
||||||
CommandManager cmdService = game.getCommandManager();
|
CommandManager cmdService = game.getCommandManager();
|
||||||
@ -277,25 +229,10 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
calculatorFactory = new SpongeCalculatorFactory(this);
|
calculatorFactory = new SpongeCalculatorFactory(this);
|
||||||
cachedStateManager = new CachedStateManager();
|
cachedStateManager = new CachedStateManager();
|
||||||
|
|
||||||
contextManager = new ContextManager<Subject>() {
|
// setup context manager
|
||||||
@Override
|
contextManager = new SpongeContextManager(this);
|
||||||
public Contexts formContexts(Subject subject, ImmutableContextSet contextSet) {
|
|
||||||
return new Contexts(
|
|
||||||
contextSet,
|
|
||||||
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
|
|
||||||
getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
|
|
||||||
true,
|
|
||||||
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
|
||||||
getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
contextManager.registerCalculator(new WorldCalculator(this));
|
contextManager.registerCalculator(new WorldCalculator(this));
|
||||||
|
contextManager.registerCalculator(new LuckPermsCalculator<>(getConfiguration()), true);
|
||||||
LuckPermsCalculator<Subject> staticCalculator = new LuckPermsCalculator<>(getConfiguration());
|
|
||||||
contextManager.registerCalculator(staticCalculator, true);
|
|
||||||
|
|
||||||
// register the PermissionService with Sponge
|
// register the PermissionService with Sponge
|
||||||
getLog().info("Registering PermissionService...");
|
getLog().info("Registering PermissionService...");
|
||||||
@ -332,7 +269,6 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
|
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
|
||||||
scheduler.asyncRepeating(new CacheHousekeepingTask(this), 2400L);
|
scheduler.asyncRepeating(new CacheHousekeepingTask(this), 2400L);
|
||||||
scheduler.asyncRepeating(new ServiceCacheHousekeepingTask(service), 2400L);
|
scheduler.asyncRepeating(new ServiceCacheHousekeepingTask(service), 2400L);
|
||||||
// scheduler.asyncRepeating(() -> userManager.performCleanup(), 2400L);
|
|
||||||
|
|
||||||
getLog().info("Successfully enabled. (took " + (System.currentTimeMillis() - startTime) + "ms)");
|
getLog().info("Successfully enabled. (took " + (System.currentTimeMillis() - startTime) + "ms)");
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.sponge.contexts;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.api.Contexts;
|
||||||
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
|
import me.lucko.luckperms.common.contexts.ContextManager;
|
||||||
|
import me.lucko.luckperms.sponge.LPSpongePlugin;
|
||||||
|
|
||||||
|
import org.spongepowered.api.service.permission.Subject;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SpongeContextManager extends ContextManager<Subject> {
|
||||||
|
private final LPSpongePlugin plugin;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Contexts formContexts(Subject subject, ImmutableContextSet contextSet) {
|
||||||
|
return new Contexts(
|
||||||
|
contextSet,
|
||||||
|
plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_PERMS),
|
||||||
|
plugin.getConfiguration().get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS),
|
||||||
|
true,
|
||||||
|
plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_GROUPS),
|
||||||
|
plugin.getConfiguration().get(ConfigKeys.APPLYING_GLOBAL_WORLD_GROUPS),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.sponge.messaging;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.messaging.InternalMessagingService;
|
||||||
|
import me.lucko.luckperms.common.messaging.MessagingFactory;
|
||||||
|
import me.lucko.luckperms.sponge.LPSpongePlugin;
|
||||||
|
|
||||||
|
public class SpongeMessagingFactory extends MessagingFactory<LPSpongePlugin> {
|
||||||
|
public SpongeMessagingFactory(LPSpongePlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected InternalMessagingService getServiceFor(String messagingType) {
|
||||||
|
if (messagingType.equals("bungee")) {
|
||||||
|
BungeeMessagingService bungeeMessaging = new BungeeMessagingService(getPlugin());
|
||||||
|
bungeeMessaging.init();
|
||||||
|
return bungeeMessaging;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getServiceFor(messagingType);
|
||||||
|
}
|
||||||
|
}
|
@ -81,7 +81,7 @@ public class PersistedSubject implements LPSubject {
|
|||||||
.expireAfterAccess(20, TimeUnit.MINUTES)
|
.expireAfterAccess(20, TimeUnit.MINUTES)
|
||||||
.build(lookup -> lookupOptionValue(lookup.getContexts(), lookup.getKey()));
|
.build(lookup -> lookupOptionValue(lookup.getContexts(), lookup.getKey()));
|
||||||
|
|
||||||
private final BufferedRequest<Void> saveBuffer = new BufferedRequest<Void>(1000L, r -> PersistedSubject.this.service.getPlugin().doAsync(r)) {
|
private final BufferedRequest<Void> saveBuffer = new BufferedRequest<Void>(1000L, 500L, r -> PersistedSubject.this.service.getPlugin().doAsync(r)) {
|
||||||
@Override
|
@Override
|
||||||
protected Void perform() {
|
protected Void perform() {
|
||||||
service.getPlugin().doAsync(() -> {
|
service.getPlugin().doAsync(() -> {
|
||||||
|
Loading…
Reference in New Issue
Block a user