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.PlatformType;
|
||||
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.bukkit.calculators.BukkitCalculatorFactory;
|
||||
import me.lucko.luckperms.bukkit.contexts.BukkitContextManager;
|
||||
import me.lucko.luckperms.bukkit.contexts.WorldCalculator;
|
||||
import me.lucko.luckperms.bukkit.messaging.BungeeMessagingService;
|
||||
import me.lucko.luckperms.bukkit.messaging.LilyPadMessagingService;
|
||||
import me.lucko.luckperms.bukkit.messaging.BukkitMessagingFactory;
|
||||
import me.lucko.luckperms.bukkit.model.Injector;
|
||||
import me.lucko.luckperms.bukkit.model.LPPermissible;
|
||||
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.ApiProvider;
|
||||
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.calculators.CalculatorFactory;
|
||||
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.UserManager;
|
||||
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.plugin.LuckPermsPlugin;
|
||||
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.tasks.CacheHousekeepingTask;
|
||||
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.utils.LoginHelper;
|
||||
import me.lucko.luckperms.common.utils.UuidCache;
|
||||
@ -131,7 +128,6 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
private LocaleManager localeManager;
|
||||
private CachedStateManager cachedStateManager;
|
||||
private ContextManager<Player> contextManager;
|
||||
private WorldCalculator worldCalculator;
|
||||
private CalculatorFactory calculatorFactory;
|
||||
private BufferedRequest<Void> updateTaskBuffer;
|
||||
private boolean started = false;
|
||||
@ -227,68 +223,14 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
storage = StorageFactory.getInstance(this, StorageType.H2);
|
||||
|
||||
// initialise messaging
|
||||
String messagingType = getConfiguration().get(ConfigKeys.MESSAGING_SERVICE).toLowerCase();
|
||||
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();
|
||||
}
|
||||
messagingService = new BukkitMessagingFactory(this).getInstance();
|
||||
|
||||
// setup the update task buffer
|
||||
updateTaskBuffer = new BufferedRequest<Void>(1000L, this::doAsync) {
|
||||
@Override
|
||||
protected Void perform() {
|
||||
new UpdateTask(LPBukkitPlugin.this).run();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
updateTaskBuffer = new UpdateTaskBuffer(this);
|
||||
|
||||
// load locale
|
||||
localeManager = new SimpleLocaleManager();
|
||||
File locale = new File(getDataFolder(), "lang.yml");
|
||||
if (locale.exists()) {
|
||||
getLog().info("Found lang.yml - loading messages...");
|
||||
try {
|
||||
localeManager.loadFromFile(locale);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
localeManager.tryLoad(this, new File(getDataFolder(), "lang.yml"));
|
||||
|
||||
// register commands
|
||||
commandManager = new BukkitCommand(this);
|
||||
@ -307,26 +249,10 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
calculatorFactory = new BukkitCalculatorFactory(this);
|
||||
cachedStateManager = new CachedStateManager();
|
||||
|
||||
contextManager = new ContextManager<Player>() {
|
||||
@Override
|
||||
public Contexts formContexts(Player player, 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),
|
||||
player.isOp()
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
worldCalculator = new WorldCalculator(this);
|
||||
contextManager.registerCalculator(worldCalculator);
|
||||
|
||||
LuckPermsCalculator<Player> staticCalculator = new LuckPermsCalculator<>(getConfiguration());
|
||||
contextManager.registerCalculator(staticCalculator, true);
|
||||
// setup context manager
|
||||
contextManager = new BukkitContextManager(this);
|
||||
contextManager.registerCalculator(new WorldCalculator(this));
|
||||
contextManager.registerCalculator(new LuckPermsCalculator<>(getConfiguration()), true);
|
||||
|
||||
// Provide vault support
|
||||
tryVaultHook(false);
|
||||
@ -465,7 +391,6 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
localeManager = null;
|
||||
cachedStateManager = null;
|
||||
contextManager = null;
|
||||
worldCalculator = null;
|
||||
calculatorFactory = null;
|
||||
updateTaskBuffer = 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.bungee.calculators.BungeeCalculatorFactory;
|
||||
import me.lucko.luckperms.bungee.contexts.BackendServerCalculator;
|
||||
import me.lucko.luckperms.bungee.messaging.BungeeMessagingService;
|
||||
import me.lucko.luckperms.bungee.messaging.RedisBungeeMessagingService;
|
||||
import me.lucko.luckperms.bungee.contexts.BungeeContextManager;
|
||||
import me.lucko.luckperms.bungee.messaging.BungeeMessagingFactory;
|
||||
import me.lucko.luckperms.bungee.util.RedisBungeeUtil;
|
||||
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
||||
import me.lucko.luckperms.common.api.ApiHandler;
|
||||
import me.lucko.luckperms.common.api.ApiProvider;
|
||||
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.calculators.CalculatorFactory;
|
||||
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.UserManager;
|
||||
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.plugin.LuckPermsPlugin;
|
||||
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.tasks.CacheHousekeepingTask;
|
||||
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.utils.UuidCache;
|
||||
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
||||
@ -158,68 +156,14 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
||||
storage = StorageFactory.getInstance(this, StorageType.H2);
|
||||
|
||||
// initialise messaging
|
||||
String messagingType = getConfiguration().get(ConfigKeys.MESSAGING_SERVICE).toLowerCase();
|
||||
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();
|
||||
}
|
||||
messagingService = new BungeeMessagingFactory(this).getInstance();
|
||||
|
||||
// setup the update task buffer
|
||||
updateTaskBuffer = new BufferedRequest<Void>(1000L, this::doAsync) {
|
||||
@Override
|
||||
protected Void perform() {
|
||||
new UpdateTask(LPBungeePlugin.this).run();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
updateTaskBuffer = new UpdateTaskBuffer(this);
|
||||
|
||||
// load locale
|
||||
localeManager = new SimpleLocaleManager();
|
||||
File locale = new File(getDataFolder(), "lang.yml");
|
||||
if (locale.exists()) {
|
||||
getLog().info("Found lang.yml - loading messages...");
|
||||
try {
|
||||
localeManager.loadFromFile(locale);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
localeManager.tryLoad(this, new File(getDataFolder(), "lang.yml"));
|
||||
|
||||
// register commands
|
||||
commandManager = new CommandManager(this);
|
||||
@ -237,26 +181,10 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
||||
calculatorFactory = new BungeeCalculatorFactory(this);
|
||||
cachedStateManager = new CachedStateManager();
|
||||
|
||||
contextManager = new ContextManager<ProxiedPlayer>() {
|
||||
@Override
|
||||
public Contexts formContexts(ProxiedPlayer player, 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
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
BackendServerCalculator serverCalculator = new BackendServerCalculator(this);
|
||||
contextManager.registerCalculator(serverCalculator);
|
||||
|
||||
LuckPermsCalculator<ProxiedPlayer> staticCalculator = new LuckPermsCalculator<>(getConfiguration());
|
||||
contextManager.registerCalculator(staticCalculator, true);
|
||||
// setup context manager
|
||||
contextManager = new BungeeContextManager(this);
|
||||
contextManager.registerCalculator(new BackendServerCalculator(this));
|
||||
contextManager.registerCalculator(new LuckPermsCalculator<>(getConfiguration()), true);
|
||||
|
||||
// register with the LP API
|
||||
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
|
||||
public CompletableFuture<Boolean> logAction(@NonNull LogEntry entry) {
|
||||
return handle.force().logAction(entry);
|
||||
return handle.noBuffer().logAction(entry);
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
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
|
||||
public CompletableFuture<Boolean> saveUser(@NonNull User user) {
|
||||
return handle.force().saveUser(UserDelegate.cast(user));
|
||||
return handle.noBuffer().saveUser(UserDelegate.cast(user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> cleanupUsers() {
|
||||
return handle.force().cleanupUsers();
|
||||
return handle.noBuffer().cleanupUsers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Set<UUID>> getUniqueUsers() {
|
||||
return handle.force().getUniqueUsers();
|
||||
return handle.noBuffer().getUniqueUsers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List<HeldPermission<UUID>>> getUsersWithPermission(@NonNull String permission) {
|
||||
return handle.force().getUsersWithPermission(permission);
|
||||
return handle.noBuffer().getUsersWithPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> createAndLoadGroup(@NonNull String name) {
|
||||
return handle.force().createAndLoadGroup(checkName(name), CreationCause.API);
|
||||
return handle.noBuffer().createAndLoadGroup(checkName(name), CreationCause.API);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadGroup(@NonNull String name) {
|
||||
return handle.force().loadGroup(checkName(name));
|
||||
return handle.noBuffer().loadGroup(checkName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadAllGroups() {
|
||||
return handle.force().loadAllGroups();
|
||||
return handle.noBuffer().loadAllGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveGroup(@NonNull Group group) {
|
||||
return handle.force().saveGroup(GroupDelegate.cast(group));
|
||||
return handle.noBuffer().saveGroup(GroupDelegate.cast(group));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -137,51 +137,51 @@ public class StorageDelegate implements Storage {
|
||||
if (group.getName().equalsIgnoreCase(plugin.getConfiguration().get(ConfigKeys.DEFAULT_GROUP_NAME))) {
|
||||
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
|
||||
public CompletableFuture<List<HeldPermission<String>>> getGroupsWithPermission(@NonNull String permission) {
|
||||
return handle.force().getGroupsWithPermission(permission);
|
||||
return handle.noBuffer().getGroupsWithPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> createAndLoadTrack(@NonNull String name) {
|
||||
return handle.force().createAndLoadTrack(checkName(name), CreationCause.API);
|
||||
return handle.noBuffer().createAndLoadTrack(checkName(name), CreationCause.API);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadTrack(@NonNull String name) {
|
||||
return handle.force().loadTrack(checkName(name));
|
||||
return handle.noBuffer().loadTrack(checkName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> loadAllTracks() {
|
||||
return handle.force().loadAllTracks();
|
||||
return handle.noBuffer().loadAllTracks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveTrack(@NonNull Track track) {
|
||||
return handle.force().saveTrack(TrackDelegate.cast(track));
|
||||
return handle.noBuffer().saveTrack(TrackDelegate.cast(track));
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
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
|
||||
public CompletableFuture<UUID> getUUID(@NonNull String username) {
|
||||
return handle.force().getUUID(checkUsername(username));
|
||||
return handle.noBuffer().getUUID(checkUsername(username));
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
public abstract class BufferedRequest<T> {
|
||||
private final long bufferTimeMillis;
|
||||
private final long sleepInterval;
|
||||
private final Executor executor;
|
||||
|
||||
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);
|
||||
processor = new WeakReference<>(p);
|
||||
return p.get();
|
||||
@ -79,6 +80,7 @@ public abstract class BufferedRequest<T> {
|
||||
@RequiredArgsConstructor
|
||||
private static class Processor<R> implements Runnable {
|
||||
private final long delayMillis;
|
||||
private final long sleepMillis;
|
||||
private final Supplier<R> supplier;
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
private final CompletableFuture<R> future = new CompletableFuture<>();
|
||||
@ -108,7 +110,7 @@ public abstract class BufferedRequest<T> {
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(sleepMillis);
|
||||
} catch (InterruptedException e) {
|
||||
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) {
|
||||
boolean success = plugin.getStorage().force().saveUser(user).join();
|
||||
boolean success = plugin.getStorage().noBuffer().saveUser(user).join();
|
||||
|
||||
if (sender.isImport()) {
|
||||
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) {
|
||||
boolean success = plugin.getStorage().force().saveGroup(group).join();
|
||||
boolean success = plugin.getStorage().noBuffer().saveGroup(group).join();
|
||||
|
||||
if (sender.isImport()) {
|
||||
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) {
|
||||
boolean success = plugin.getStorage().force().saveTrack(track).join();
|
||||
boolean success = plugin.getStorage().noBuffer().saveTrack(track).join();
|
||||
|
||||
if (sender.isImport()) {
|
||||
plugin.getUpdateTaskBuffer().request();
|
||||
|
@ -78,7 +78,7 @@ public class LogNotify extends SubCommand<Log> {
|
||||
user.removeIf(n -> n.getPermission().equalsIgnoreCase("luckperms.log.notify.ignoring"));
|
||||
}
|
||||
|
||||
plugin.getStorage().force().saveUser(user).join();
|
||||
plugin.getStorage().noBuffer().saveUser(user).join();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
package me.lucko.luckperms.common.locale;
|
||||
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
@ -32,8 +34,27 @@ import java.io.File;
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Gets the size of loaded translations
|
||||
*
|
||||
* @return the size of the loaded translations
|
||||
*/
|
||||
int getSize();
|
||||
|
||||
/**
|
||||
|
@ -25,10 +25,17 @@
|
||||
|
||||
package me.lucko.luckperms.common.locale;
|
||||
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class NoopLocaleManager implements LocaleManager {
|
||||
|
||||
@Override
|
||||
public void tryLoad(LuckPermsPlugin plugin, File file) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFromFile(File file) throws Exception {
|
||||
|
||||
|
@ -27,6 +27,8 @@ package me.lucko.luckperms.common.locale;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -40,6 +42,17 @@ public class SimpleLocaleManager implements LocaleManager {
|
||||
private Map<Message, String> messages = 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")
|
||||
public void loadFromFile(File file) throws Exception {
|
||||
try (BufferedReader reader = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8)) {
|
||||
|
@ -26,7 +26,6 @@
|
||||
package me.lucko.luckperms.common.messaging;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
@ -47,9 +46,8 @@ import java.util.function.Consumer;
|
||||
/**
|
||||
* An abstract implementation of {@link me.lucko.luckperms.api.MessagingService}.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public abstract class AbstractMessagingService implements InternalMessagingService {
|
||||
public static final String CHANNEL = "lpuc";
|
||||
protected static final String CHANNEL = "lpuc";
|
||||
|
||||
@Getter
|
||||
private final LuckPermsPlugin plugin;
|
||||
@ -57,17 +55,19 @@ public abstract class AbstractMessagingService implements InternalMessagingServi
|
||||
@Getter
|
||||
private final String name;
|
||||
|
||||
private final Set<UUID> receivedMessages = Collections.synchronizedSet(new HashSet<>());
|
||||
private final Gson gson = new Gson();
|
||||
private final Set<UUID> receivedMessages;
|
||||
private final Gson gson;
|
||||
|
||||
@Getter
|
||||
private final BufferedRequest<Void> updateBuffer = new BufferedRequest<Void>(3000L, r -> getPlugin().doAsync(r)) {
|
||||
@Override
|
||||
protected Void perform() {
|
||||
pushUpdate();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
private final BufferedRequest<Void> updateBuffer;
|
||||
|
||||
public AbstractMessagingService(LuckPermsPlugin plugin, String name) {
|
||||
this.plugin = plugin;
|
||||
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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@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
|
||||
protected Void perform() {
|
||||
refreshPermissions();
|
||||
|
@ -58,8 +58,8 @@ import java.util.function.Supplier;
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class AbstractStorage implements Storage {
|
||||
public static Storage wrap(LuckPermsPlugin plugin, AbstractBacking backing) {
|
||||
BufferedOutputStorage bufferedDs = BufferedOutputStorage.wrap(PhasedStorage.wrap(new AbstractStorage(plugin, backing)), 1000L);
|
||||
plugin.getScheduler().asyncRepeating(bufferedDs, 5L);
|
||||
BufferedOutputStorage bufferedDs = BufferedOutputStorage.wrap(PhasedStorage.wrap(new AbstractStorage(plugin, backing)), 250L);
|
||||
plugin.getScheduler().asyncRepeating(bufferedDs, 2L);
|
||||
return bufferedDs;
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ public class AbstractStorage implements Storage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Storage force() {
|
||||
public Storage noBuffer() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public interface Storage {
|
||||
|
||||
void setAcceptingLogins(boolean acceptingLogins);
|
||||
|
||||
Storage force();
|
||||
Storage noBuffer();
|
||||
|
||||
void init();
|
||||
|
||||
|
@ -413,7 +413,7 @@ public class MongoDBBacking extends AbstractBacking {
|
||||
|
||||
@Override
|
||||
public boolean cleanupUsers() {
|
||||
return true; // TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -496,7 +496,7 @@ public class SQLBacking extends AbstractBacking {
|
||||
|
||||
@Override
|
||||
public boolean cleanupUsers() {
|
||||
return true; // TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
@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.Track;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.references.UserIdentifier;
|
||||
import me.lucko.luckperms.common.storage.Storage;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@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<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<UserIdentifier, Boolean> uuidDataOutputBuffer = Buffer.of(userIdentifier -> BufferedOutputStorage.this.backing.saveUUIDData(userIdentifier.getUsername().get(), userIdentifier.getUuid()).join());
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@ -70,11 +67,10 @@ public class BufferedOutputStorage implements Storage, Runnable {
|
||||
userOutputBuffer.flush(flushTime);
|
||||
groupOutputBuffer.flush(flushTime);
|
||||
trackOutputBuffer.flush(flushTime);
|
||||
userOutputBuffer.flush(flushTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Storage force() {
|
||||
public Storage noBuffer() {
|
||||
return backing;
|
||||
}
|
||||
|
||||
@ -99,17 +95,11 @@ public class BufferedOutputStorage implements Storage, Runnable {
|
||||
return trackOutputBuffer.enqueue(track);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> saveUUIDData(String username, UUID uuid) {
|
||||
return uuidDataOutputBuffer.enqueue(UserIdentifier.of(uuid, username));
|
||||
}
|
||||
|
||||
private interface Exclude {
|
||||
Storage force();
|
||||
Storage noBuffer();
|
||||
CompletableFuture<Void> shutdown();
|
||||
CompletableFuture<Boolean> saveUser(User user);
|
||||
CompletableFuture<Boolean> saveGroup(Group group);
|
||||
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();
|
||||
|
||||
@Override
|
||||
public Storage force() {
|
||||
public Storage noBuffer() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class PhasedStorage implements Storage {
|
||||
public void shutdown() {
|
||||
// Wait for other threads to finish.
|
||||
try {
|
||||
phaser.awaitAdvanceInterruptibly(phaser.getPhase(), 5, TimeUnit.SECONDS);
|
||||
phaser.awaitAdvanceInterruptibly(phaser.getPhase(), 10, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException | TimeoutException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -46,32 +46,32 @@ public class LoginHelper {
|
||||
|
||||
final UuidCache cache = plugin.getUuidCache();
|
||||
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) {
|
||||
cache.addToCache(u, uuid);
|
||||
} else {
|
||||
// No previous data for this player
|
||||
plugin.getApiProvider().getEventFactory().handleUserFirstLogin(u, username);
|
||||
cache.addToCache(u, u);
|
||||
CompletableFuture<Boolean> future = plugin.getStorage().force().saveUUIDData(username, u);
|
||||
CompletableFuture<Boolean> future = plugin.getStorage().noBuffer().saveUUIDData(username, u);
|
||||
if (joinUuidSave) {
|
||||
future.join();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String name = plugin.getStorage().force().getName(u).join();
|
||||
String name = plugin.getStorage().noBuffer().getName(u).join();
|
||||
if (name == null) {
|
||||
plugin.getApiProvider().getEventFactory().handleUserFirstLogin(u, username);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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));
|
||||
if (user == null) {
|
||||
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 (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.
|
||||
|
@ -32,12 +32,12 @@ import com.google.inject.Inject;
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.api.LuckPermsApi;
|
||||
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.api.ApiHandler;
|
||||
import me.lucko.luckperms.common.api.ApiProvider;
|
||||
import me.lucko.luckperms.common.backup.ImporterSender;
|
||||
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.calculators.CalculatorFactory;
|
||||
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.TrackManager;
|
||||
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.plugin.LuckPermsPlugin;
|
||||
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.tasks.CacheHousekeepingTask;
|
||||
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.utils.UuidCache;
|
||||
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
||||
import me.lucko.luckperms.sponge.calculators.SpongeCalculatorFactory;
|
||||
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.managers.SpongeGroupManager;
|
||||
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.model.LPPermissionService;
|
||||
import me.lucko.luckperms.sponge.service.model.LPSubjectCollection;
|
||||
@ -208,60 +206,14 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
||||
storage = StorageFactory.getInstance(this, StorageType.H2);
|
||||
|
||||
// initialise messaging
|
||||
String messagingType = getConfiguration().get(ConfigKeys.MESSAGING_SERVICE).toLowerCase();
|
||||
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();
|
||||
}
|
||||
messagingService = new SpongeMessagingFactory(this).getInstance();
|
||||
|
||||
// setup the update task buffer
|
||||
updateTaskBuffer = new BufferedRequest<Void>(1000L, this::doAsync) {
|
||||
@Override
|
||||
protected Void perform() {
|
||||
new UpdateTask(LPSpongePlugin.this).run();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
updateTaskBuffer = new UpdateTaskBuffer(this);
|
||||
|
||||
// load locale
|
||||
localeManager = new SimpleLocaleManager();
|
||||
File locale = new File(getDataDirectory(), "lang.yml");
|
||||
if (locale.exists()) {
|
||||
getLog().info("Found lang.yml - loading messages...");
|
||||
try {
|
||||
localeManager.loadFromFile(locale);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
localeManager.tryLoad(this, new File(getDataDirectory(), "lang.yml"));
|
||||
|
||||
// register commands
|
||||
CommandManager cmdService = game.getCommandManager();
|
||||
@ -277,25 +229,10 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
||||
calculatorFactory = new SpongeCalculatorFactory(this);
|
||||
cachedStateManager = new CachedStateManager();
|
||||
|
||||
contextManager = new ContextManager<Subject>() {
|
||||
@Override
|
||||
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
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// setup context manager
|
||||
contextManager = new SpongeContextManager(this);
|
||||
contextManager.registerCalculator(new WorldCalculator(this));
|
||||
|
||||
LuckPermsCalculator<Subject> staticCalculator = new LuckPermsCalculator<>(getConfiguration());
|
||||
contextManager.registerCalculator(staticCalculator, true);
|
||||
contextManager.registerCalculator(new LuckPermsCalculator<>(getConfiguration()), true);
|
||||
|
||||
// register the PermissionService with Sponge
|
||||
getLog().info("Registering PermissionService...");
|
||||
@ -332,7 +269,6 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
||||
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
|
||||
scheduler.asyncRepeating(new CacheHousekeepingTask(this), 2400L);
|
||||
scheduler.asyncRepeating(new ServiceCacheHousekeepingTask(service), 2400L);
|
||||
// scheduler.asyncRepeating(() -> userManager.performCleanup(), 2400L);
|
||||
|
||||
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)
|
||||
.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
|
||||
protected Void perform() {
|
||||
service.getPlugin().doAsync(() -> {
|
||||
|
Loading…
Reference in New Issue
Block a user