Compare commits
3 Commits
9b13460152
...
2422c86d59
Author | SHA1 | Date |
---|---|---|
lucko | 2422c86d59 | |
Jason Penilla | d74a4dcb7e | |
Luck | 28477ff638 |
|
@ -6,11 +6,13 @@ repositories {
|
|||
maven { url 'https://repo.papermc.io/repository/maven-public/' }
|
||||
}
|
||||
|
||||
disableAutoTargetJvm()
|
||||
|
||||
dependencies {
|
||||
implementation project(':common')
|
||||
compileOnly project(':common:loader-utils')
|
||||
|
||||
compileOnly 'com.destroystokyo.paper:paper-api:1.15.2-R0.1-SNAPSHOT'
|
||||
compileOnly 'dev.folia:folia-api:1.20.2-R0.1-SNAPSHOT'
|
||||
compileOnly('net.kyori:adventure-platform-bukkit:4.1.0') {
|
||||
exclude(module: 'adventure-bom')
|
||||
exclude(module: 'adventure-api')
|
||||
|
|
|
@ -25,6 +25,10 @@ shadowJar {
|
|||
from {
|
||||
project(':bukkit').tasks.shadowJar.archiveFile
|
||||
}
|
||||
|
||||
manifest {
|
||||
attributes(["paperweight-mappings-namespace": "mojang"])
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
|
|
|
@ -10,6 +10,7 @@ load: STARTUP
|
|||
# remapping when the plugin is loaded. Note that despite what this setting might otherwise imply,
|
||||
# LP is still compatible with pre-1.13 releases.
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
|
||||
# Load LuckPerms before Vault. This means that all plugins that (soft-)depend
|
||||
# on Vault depend on LuckPerms too.
|
||||
|
|
|
@ -25,22 +25,32 @@
|
|||
|
||||
package me.lucko.luckperms.bukkit;
|
||||
|
||||
import me.lucko.luckperms.common.plugin.scheduler.AbstractJavaScheduler;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.JavaSchedulerAdapter;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public class BukkitSchedulerAdapter extends AbstractJavaScheduler implements SchedulerAdapter {
|
||||
private final Executor sync;
|
||||
public class BukkitSchedulerAdapter extends JavaSchedulerAdapter implements SchedulerAdapter {
|
||||
private final Executor syncExecutor;
|
||||
|
||||
public BukkitSchedulerAdapter(LPBukkitBootstrap bootstrap) {
|
||||
super(bootstrap);
|
||||
this.sync = r -> bootstrap.getServer().getScheduler().scheduleSyncDelayedTask(bootstrap.getLoader(), r);
|
||||
this.syncExecutor = r -> bootstrap.getServer().getScheduler().scheduleSyncDelayedTask(bootstrap.getLoader(), r);
|
||||
}
|
||||
|
||||
public void sync(Runnable task) {
|
||||
this.syncExecutor.execute(task);
|
||||
}
|
||||
|
||||
public void sync(CommandSender ctx, Runnable task) {
|
||||
this.syncExecutor.execute(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor sync() {
|
||||
return this.sync;
|
||||
public void sync(Sender ctx, Runnable task) {
|
||||
this.syncExecutor.execute(task);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class BukkitSenderFactory extends SenderFactory<LPBukkitPlugin, CommandSe
|
|||
if (sender instanceof Player || sender instanceof ConsoleCommandSender || sender instanceof RemoteConsoleCommandSender) {
|
||||
this.audiences.sender(sender).sendMessage(message);
|
||||
} else {
|
||||
getPlugin().getBootstrap().getScheduler().executeSync(() -> this.audiences.sender(sender).sendMessage(message));
|
||||
getPlugin().getBootstrap().getScheduler().sync(sender, () -> this.audiences.sender(sender).sendMessage(message));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import io.papermc.paper.threadedregions.scheduler.RegionScheduler;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
|
||||
import me.lucko.luckperms.common.sender.AbstractSender;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.command.ProxiedCommandSender;
|
||||
import org.bukkit.command.RemoteConsoleCommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class FoliaSchedulerAdapter extends BukkitSchedulerAdapter implements SchedulerAdapter {
|
||||
private final JavaPlugin loader;
|
||||
private final Server server;
|
||||
|
||||
public FoliaSchedulerAdapter(LPBukkitBootstrap bootstrap) {
|
||||
super(bootstrap);
|
||||
this.loader = bootstrap.getLoader();
|
||||
this.server = bootstrap.getServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync(Runnable task) {
|
||||
this.server.getGlobalRegionScheduler().execute(this.loader, task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync(Sender ctx, Runnable task) {
|
||||
sync(unwrapSender(ctx), task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync(CommandSender ctx, Runnable task) {
|
||||
if (ctx instanceof Entity) {
|
||||
((Entity) ctx).getScheduler().execute(this.loader, task, null, 0);
|
||||
} else if (ctx instanceof BlockCommandSender) {
|
||||
RegionScheduler scheduler = this.server.getRegionScheduler();
|
||||
scheduler.execute(this.loader, ((BlockCommandSender) ctx).getBlock().getLocation(), task);
|
||||
} else if (ctx instanceof ConsoleCommandSender || ctx instanceof RemoteConsoleCommandSender) {
|
||||
this.server.getGlobalRegionScheduler().execute(this.loader, task);
|
||||
} else if (ctx instanceof ProxiedCommandSender) {
|
||||
sync(((ProxiedCommandSender) ctx).getCallee(), task);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown command sender type: " + ctx.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static CommandSender unwrapSender(Sender sender) {
|
||||
if (sender instanceof AbstractSender) {
|
||||
return ((AbstractSender<CommandSender>) sender).getSender();
|
||||
} else {
|
||||
throw new IllegalArgumentException("unknown sender type: " + sender.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -102,7 +102,9 @@ public class LPBukkitBootstrap implements LuckPermsBootstrap, LoaderBootstrap, B
|
|||
this.loader = loader;
|
||||
|
||||
this.logger = new JavaPluginLogger(loader.getLogger());
|
||||
this.schedulerAdapter = new BukkitSchedulerAdapter(this);
|
||||
this.schedulerAdapter = isFolia()
|
||||
? new FoliaSchedulerAdapter(this)
|
||||
: new BukkitSchedulerAdapter(this);
|
||||
this.classPathAppender = new JarInJarClassPathAppender(getClass().getClassLoader());
|
||||
this.console = new NullSafeConsoleCommandSender(getServer());
|
||||
this.plugin = new LPBukkitPlugin(this);
|
||||
|
@ -175,7 +177,7 @@ public class LPBukkitBootstrap implements LuckPermsBootstrap, LoaderBootstrap, B
|
|||
this.plugin.enable();
|
||||
|
||||
// schedule a task to update the 'serverStarting' flag
|
||||
getServer().getScheduler().runTask(this.loader, () -> this.serverStarting = false);
|
||||
this.schedulerAdapter.sync(() -> this.serverStarting = false);
|
||||
} finally {
|
||||
this.enableLatch.countDown();
|
||||
}
|
||||
|
@ -311,4 +313,13 @@ public class LPBukkitBootstrap implements LuckPermsBootstrap, LoaderBootstrap, B
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isFolia() {
|
||||
try {
|
||||
Class.forName("io.papermc.paper.threadedregions.scheduler.RegionScheduler");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
|||
|
||||
// schedule another injection after all plugins have loaded
|
||||
// the entire pluginmanager instance is replaced by some plugins :(
|
||||
this.bootstrap.getServer().getScheduler().runTaskLaterAsynchronously(this.bootstrap.getLoader(), injector, 1);
|
||||
this.bootstrap.getScheduler().sync(injector);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -268,7 +268,7 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
|||
|
||||
// remove all operators on startup if they're disabled
|
||||
if (!getConfiguration().get(ConfigKeys.OPS_ENABLED)) {
|
||||
this.bootstrap.getServer().getScheduler().runTaskAsynchronously(this.bootstrap.getLoader(), () -> {
|
||||
this.bootstrap.getScheduler().sync(() -> {
|
||||
for (OfflinePlayer player : this.bootstrap.getServer().getOperators()) {
|
||||
player.setOp(false);
|
||||
}
|
||||
|
@ -287,11 +287,11 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
|||
|
||||
// Load any online users (in the case of a reload)
|
||||
for (Player player : this.bootstrap.getServer().getOnlinePlayers()) {
|
||||
this.bootstrap.getScheduler().executeAsync(() -> {
|
||||
this.bootstrap.getScheduler().async(() -> {
|
||||
try {
|
||||
User user = this.connectionListener.loadUser(player.getUniqueId(), player.getName());
|
||||
if (user != null) {
|
||||
this.bootstrap.getScheduler().executeSync(() -> {
|
||||
this.bootstrap.getScheduler().sync(player, () -> {
|
||||
try {
|
||||
LuckPermsPermissible lpPermissible = new LuckPermsPermissible(player, user, this);
|
||||
PermissibleInjector.inject(player, lpPermissible, getLogger());
|
||||
|
|
|
@ -83,7 +83,7 @@ public class BukkitAutoOpListener implements LuckPermsEventListener {
|
|||
if (callerIsSync) {
|
||||
player.setOp(value);
|
||||
} else {
|
||||
this.plugin.getBootstrap().getScheduler().executeSync(() -> player.setOp(value));
|
||||
this.plugin.getBootstrap().getScheduler().sync(player, () -> player.setOp(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
package me.lucko.luckperms.bukkit.listeners;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import me.lucko.luckperms.bukkit.LPBukkitBootstrap;
|
||||
import me.lucko.luckperms.bukkit.LPBukkitPlugin;
|
||||
import me.lucko.luckperms.common.cache.BufferedRequest;
|
||||
import me.lucko.luckperms.common.event.LuckPermsEventListener;
|
||||
|
@ -90,12 +91,15 @@ public class BukkitCommandListUpdater implements LuckPermsEventListener {
|
|||
|
||||
// Called when the buffer times out.
|
||||
private void sendUpdate(UUID uniqueId) {
|
||||
if (this.plugin.getBootstrap().isServerStopping()) {
|
||||
LPBukkitBootstrap bootstrap = this.plugin.getBootstrap();
|
||||
if (bootstrap.isServerStopping()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.plugin.getBootstrap().getScheduler().sync()
|
||||
.execute(() -> this.plugin.getBootstrap().getPlayer(uniqueId).ifPresent(Player::updateCommands));
|
||||
|
||||
Player player = bootstrap.getPlayer(uniqueId).orElse(null);
|
||||
if (player != null) {
|
||||
bootstrap.getScheduler().sync(player, player::updateCommands);
|
||||
}
|
||||
}
|
||||
|
||||
private final class SendBuffer extends BufferedRequest<Void> {
|
||||
|
|
|
@ -240,7 +240,7 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
|
|||
|
||||
// perform unhooking from bukkit objects 1 tick later.
|
||||
// this allows plugins listening after us on MONITOR to still have intact permissions data
|
||||
this.plugin.getBootstrap().getServer().getScheduler().runTaskLater(this.plugin.getLoader(), () -> {
|
||||
this.plugin.getBootstrap().getScheduler().sync(player, () -> {
|
||||
// Remove the custom permissible
|
||||
try {
|
||||
PermissibleInjector.uninject(player, true);
|
||||
|
@ -256,7 +256,7 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
|
|||
|
||||
// remove their contexts cache
|
||||
this.plugin.getContextManager().onPlayerQuit(player);
|
||||
}, 1L);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class LilyPadMessenger implements Messenger {
|
|||
|
||||
@EventListener
|
||||
public void onMessage(MessageEvent event) {
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
||||
this.plugin.getBootstrap().getScheduler().async(() -> {
|
||||
String channel = event.getChannel();
|
||||
if (!channel.equals(CHANNEL)) {
|
||||
return;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
package me.lucko.luckperms.bukkit.util;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
|
@ -35,9 +36,12 @@ import org.bukkit.permissions.PermissionAttachment;
|
|||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The {@link Server#getConsoleSender()} method returns null during onEnable
|
||||
|
@ -109,12 +113,16 @@ public class NullSafeConsoleCommandSender implements ConsoleCommandSender {
|
|||
|
||||
// just throw UnsupportedOperationException - we never use any of these methods
|
||||
@Override public @NonNull Spigot spigot() { throw new UnsupportedOperationException(); }
|
||||
@Override public void sendMessage(@Nullable UUID uuid, @NotNull String s) { throw new UnsupportedOperationException(); }
|
||||
@Override public void sendMessage(@Nullable UUID uuid, @NotNull String... strings) { throw new UnsupportedOperationException(); }
|
||||
@Override public @NotNull Component name() { throw new UnsupportedOperationException(); }
|
||||
@Override public boolean isConversing() { throw new UnsupportedOperationException(); }
|
||||
@Override public void acceptConversationInput(@NonNull String s) { throw new UnsupportedOperationException(); }
|
||||
@Override public boolean beginConversation(@NonNull Conversation conversation) { throw new UnsupportedOperationException(); }
|
||||
@Override public void abandonConversation(@NonNull Conversation conversation) { throw new UnsupportedOperationException(); }
|
||||
@Override public void abandonConversation(@NonNull Conversation conversation, @NonNull ConversationAbandonedEvent conversationAbandonedEvent) { throw new UnsupportedOperationException(); }
|
||||
@Override public void sendRawMessage(@NonNull String s) { throw new UnsupportedOperationException(); }
|
||||
@Override public void sendRawMessage(@Nullable UUID uuid, @NotNull String s) { throw new UnsupportedOperationException(); }
|
||||
@Override public @NonNull PermissionAttachment addAttachment(@NonNull Plugin plugin, @NonNull String s, boolean b) { throw new UnsupportedOperationException(); }
|
||||
@Override public @NonNull PermissionAttachment addAttachment(@NonNull Plugin plugin) { throw new UnsupportedOperationException(); }
|
||||
@Override public PermissionAttachment addAttachment(@NonNull Plugin plugin, @NonNull String s, boolean b, int i) { throw new UnsupportedOperationException(); }
|
||||
|
|
|
@ -52,11 +52,6 @@ public class BungeeSchedulerAdapter implements SchedulerAdapter {
|
|||
return this.executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor sync() {
|
||||
return this.executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchedulerTask asyncLater(Runnable task, long delay, TimeUnit unit) {
|
||||
ScheduledTask t = this.bootstrap.getProxy().getScheduler().schedule(this.bootstrap.getLoader(), task, delay, unit);
|
||||
|
|
|
@ -77,7 +77,7 @@ public class BungeeConnectionListener extends AbstractConnectionListener impleme
|
|||
this will prevent the event from completing until we're finished handling. */
|
||||
e.registerIntent(this.plugin.getLoader());
|
||||
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
||||
this.plugin.getBootstrap().getScheduler().async(() -> {
|
||||
/* Actually process the login for the connection.
|
||||
We do this here to delay the login until the data is ready.
|
||||
If the login gets cancelled later on, then this will be cleaned up.
|
||||
|
|
|
@ -83,7 +83,7 @@ public class PluginMessageMessenger extends AbstractPluginMessageMessenger imple
|
|||
|
||||
if (handleIncomingMessage(buf)) {
|
||||
// Forward to other servers
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(() -> sendOutgoingMessage(buf));
|
||||
this.plugin.getBootstrap().getScheduler().async(() -> sendOutgoingMessage(buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ public class ExportCommand extends SingleCommand {
|
|||
}
|
||||
|
||||
// Run the exporter in its own thread.
|
||||
plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
||||
plugin.getBootstrap().getScheduler().async(() -> {
|
||||
try {
|
||||
exporter.run();
|
||||
} finally {
|
||||
|
|
|
@ -133,7 +133,7 @@ public class ImportCommand extends SingleCommand {
|
|||
Importer importer = new Importer(plugin, sender, data, !args.contains("--replace"));
|
||||
|
||||
// Run the importer in its own thread.
|
||||
plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
||||
plugin.getBootstrap().getScheduler().async(() -> {
|
||||
try {
|
||||
importer.run();
|
||||
} finally {
|
||||
|
|
|
@ -94,7 +94,7 @@ public class VerboseCommand extends SingleCommand {
|
|||
String commandWithSlash = String.join(" ", args.subList(2, args.size()));
|
||||
String command = commandWithSlash.charAt(0) == '/' ? commandWithSlash.substring(1) : commandWithSlash;
|
||||
|
||||
plugin.getBootstrap().getScheduler().sync().execute(() -> {
|
||||
plugin.getBootstrap().getScheduler().sync(executor, () -> {
|
||||
Message.VERBOSE_ON_COMMAND.send(sender, executor.getName(), command);
|
||||
|
||||
verboseHandler.registerListener(sender, VerboseFilter.acceptAll(), true);
|
||||
|
|
|
@ -140,7 +140,7 @@ public final class EventDispatcher {
|
|||
}
|
||||
|
||||
// async: generate an event class and post it
|
||||
this.eventBus.getPlugin().getBootstrap().getScheduler().executeAsync(() -> post(eventClass, params));
|
||||
this.eventBus.getPlugin().getBootstrap().getScheduler().async(() -> post(eventClass, params));
|
||||
}
|
||||
|
||||
private void postSync(Class<? extends LuckPermsEvent> eventClass, Object... params) {
|
||||
|
|
|
@ -88,7 +88,7 @@ public class TranslationRepository {
|
|||
return; // skip
|
||||
}
|
||||
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
||||
this.plugin.getBootstrap().getScheduler().async(() -> {
|
||||
// cleanup old translation files
|
||||
clearDirectory(this.plugin.getTranslationManager().getTranslationsDirectory(), Files::isRegularFile);
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ public class LuckPermsMessagingService implements InternalMessagingService, Inco
|
|||
|
||||
@Override
|
||||
public void pushUpdate() {
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
||||
this.plugin.getBootstrap().getScheduler().async(() -> {
|
||||
UUID requestId = generatePingId();
|
||||
this.plugin.getLogger().info("[Messaging] Sending ping with id: " + requestId);
|
||||
this.messenger.sendOutgoingMessage(new UpdateMessageImpl(requestId));
|
||||
|
@ -117,7 +117,7 @@ public class LuckPermsMessagingService implements InternalMessagingService, Inco
|
|||
|
||||
@Override
|
||||
public void pushUserUpdate(User user) {
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
||||
this.plugin.getBootstrap().getScheduler().async(() -> {
|
||||
UUID requestId = generatePingId();
|
||||
this.plugin.getLogger().info("[Messaging] Sending user ping for '" + user.getPlainDisplayName() + "' with id: " + requestId);
|
||||
this.messenger.sendOutgoingMessage(new UserUpdateMessageImpl(requestId, user.getUniqueId()));
|
||||
|
@ -126,7 +126,7 @@ public class LuckPermsMessagingService implements InternalMessagingService, Inco
|
|||
|
||||
@Override
|
||||
public void pushLog(Action logEntry) {
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
||||
this.plugin.getBootstrap().getScheduler().async(() -> {
|
||||
UUID requestId = generatePingId();
|
||||
|
||||
if (this.plugin.getEventDispatcher().dispatchLogNetworkPublish(!this.plugin.getConfiguration().get(ConfigKeys.PUSH_LOG_ENTRIES), requestId, logEntry)) {
|
||||
|
|
|
@ -113,7 +113,7 @@ public class PostgresMessenger implements Messenger {
|
|||
|
||||
try {
|
||||
this.listener = new NotificationListener();
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
||||
this.plugin.getBootstrap().getScheduler().async(() -> {
|
||||
this.listener.listenAndBind();
|
||||
if (!firstStartup) {
|
||||
this.plugin.getLogger().info("Postgres listen/notify connection re-established");
|
||||
|
|
|
@ -73,7 +73,7 @@ public class RedisMessenger implements Messenger {
|
|||
private void init(UnifiedJedis jedis) {
|
||||
this.jedis = jedis;
|
||||
this.sub = new Subscription(this);
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(this.sub);
|
||||
this.plugin.getBootstrap().getScheduler().async(this.sub);
|
||||
}
|
||||
|
||||
private static JedisClientConfig jedisConfig(String username, String password, boolean ssl) {
|
||||
|
|
|
@ -228,7 +228,7 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
|
|||
this.apiProvider = new LuckPermsApiProvider(this);
|
||||
this.apiProvider.ensureApiWasLoadedByPlugin();
|
||||
this.eventDispatcher = new EventDispatcher(provideEventBus(this.apiProvider));
|
||||
getBootstrap().getScheduler().executeAsync(GeneratedEventClass::preGenerate);
|
||||
getBootstrap().getScheduler().async(GeneratedEventClass::preGenerate);
|
||||
ApiRegistrationUtil.registerProvider(this.apiProvider);
|
||||
registerApiOnPlatform(this.apiProvider);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ import java.util.stream.Collectors;
|
|||
/**
|
||||
* Abstract implementation of {@link SchedulerAdapter} using a {@link ScheduledExecutorService}.
|
||||
*/
|
||||
public abstract class AbstractJavaScheduler implements SchedulerAdapter {
|
||||
public class JavaSchedulerAdapter implements SchedulerAdapter {
|
||||
private static final int PARALLELISM = 16;
|
||||
|
||||
private final LuckPermsBootstrap bootstrap;
|
||||
|
@ -52,7 +52,7 @@ public abstract class AbstractJavaScheduler implements SchedulerAdapter {
|
|||
private final ScheduledThreadPoolExecutor scheduler;
|
||||
private final ForkJoinPool worker;
|
||||
|
||||
public AbstractJavaScheduler(LuckPermsBootstrap bootstrap) {
|
||||
public JavaSchedulerAdapter(LuckPermsBootstrap bootstrap) {
|
||||
this.bootstrap = bootstrap;
|
||||
|
||||
this.scheduler = new ScheduledThreadPoolExecutor(1, r -> {
|
||||
|
@ -133,7 +133,7 @@ public abstract class AbstractJavaScheduler implements SchedulerAdapter {
|
|||
private final class ExceptionHandler implements UncaughtExceptionHandler {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
AbstractJavaScheduler.this.bootstrap.getPluginLogger().warn("Thread " + t.getName() + " threw an uncaught exception", e);
|
||||
JavaSchedulerAdapter.this.bootstrap.getPluginLogger().warn("Thread " + t.getName() + " threw an uncaught exception", e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
package me.lucko.luckperms.common.plugin.scheduler;
|
||||
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -33,6 +35,15 @@ import java.util.concurrent.TimeUnit;
|
|||
*/
|
||||
public interface SchedulerAdapter {
|
||||
|
||||
/**
|
||||
* Executes a task sync
|
||||
*
|
||||
* @param task the task
|
||||
*/
|
||||
default void sync(Sender ctx, Runnable task) {
|
||||
async(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an async executor instance
|
||||
*
|
||||
|
@ -40,31 +51,15 @@ public interface SchedulerAdapter {
|
|||
*/
|
||||
Executor async();
|
||||
|
||||
/**
|
||||
* Gets a sync executor instance
|
||||
*
|
||||
* @return a sync executor instance
|
||||
*/
|
||||
Executor sync();
|
||||
|
||||
/**
|
||||
* Executes a task async
|
||||
*
|
||||
* @param task the task
|
||||
*/
|
||||
default void executeAsync(Runnable task) {
|
||||
default void async(Runnable task) {
|
||||
async().execute(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a task sync
|
||||
*
|
||||
* @param task the task
|
||||
*/
|
||||
default void executeSync(Runnable task) {
|
||||
sync().execute(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the given task with a delay.
|
||||
*
|
||||
|
@ -95,7 +90,7 @@ public interface SchedulerAdapter {
|
|||
/**
|
||||
* Shuts down the executor instance.
|
||||
*
|
||||
* <p>{@link #async()} and {@link #executeAsync(Runnable)}.</p>
|
||||
* <p>{@link #async()} and {@link #async(Runnable)}.</p>
|
||||
*/
|
||||
void shutdownExecutor();
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ public abstract class AbstractConnectionListener {
|
|||
this.plugin.getUserManager().getHouseKeeper().registerUsage(uniqueId);
|
||||
|
||||
// force a clear of transient nodes
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
||||
this.plugin.getBootstrap().getScheduler().async(() -> {
|
||||
User user = this.plugin.getUserManager().getIfLoaded(uniqueId);
|
||||
if (user != null) {
|
||||
user.clearNodes(DataType.TRANSIENT, null, false);
|
||||
|
|
|
@ -66,6 +66,10 @@ public final class AbstractSender<T> implements Sender {
|
|||
return this.plugin;
|
||||
}
|
||||
|
||||
public T getSender() {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return this.uniqueId;
|
||||
|
|
|
@ -57,7 +57,7 @@ public class FileWatcher extends AbstractFileWatcher {
|
|||
this.basePath = basePath;
|
||||
|
||||
super.registerRecursively(basePath);
|
||||
plugin.getBootstrap().getScheduler().executeAsync(super::runEventProcessingLoop);
|
||||
plugin.getBootstrap().getScheduler().async(super::runEventProcessingLoop);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -66,7 +66,7 @@ public class HandlerChangeRequest implements Handler {
|
|||
}
|
||||
|
||||
// send "change-accepted" response
|
||||
this.socket.getPlugin().getBootstrap().getScheduler().executeAsync(() ->
|
||||
this.socket.getPlugin().getBootstrap().getScheduler().async(() ->
|
||||
this.socket.send(SocketMessageType.CHANGE_RESPONSE.builder()
|
||||
.add("state", STATE_ACCEPTED)
|
||||
.toJson()
|
||||
|
|
|
@ -80,7 +80,7 @@ public class WebEditorSocketListener extends WebSocketListener {
|
|||
|
||||
@Override
|
||||
public void onMessage(@NonNull WebSocket webSocket, @NonNull String msg) {
|
||||
this.socket.getPlugin().getBootstrap().getScheduler().executeAsync(() -> {
|
||||
this.socket.getPlugin().getBootstrap().getScheduler().async(() -> {
|
||||
this.lock.lock();
|
||||
try {
|
||||
if (shouldIgnoreMessages()) {
|
||||
|
|
|
@ -25,20 +25,25 @@
|
|||
|
||||
package me.lucko.luckperms.fabric;
|
||||
|
||||
import me.lucko.luckperms.common.plugin.scheduler.AbstractJavaScheduler;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.JavaSchedulerAdapter;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public class FabricSchedulerAdapter extends AbstractJavaScheduler {
|
||||
private final Executor sync;
|
||||
public class FabricSchedulerAdapter extends JavaSchedulerAdapter {
|
||||
private final Executor syncExecutor;
|
||||
|
||||
public FabricSchedulerAdapter(LPFabricBootstrap bootstrap) {
|
||||
super(bootstrap);
|
||||
this.sync = r -> bootstrap.getServer().orElseThrow(() -> new IllegalStateException("Server not ready")).submitAndJoin(r);
|
||||
this.syncExecutor = r -> bootstrap.getServer().orElseThrow(() -> new IllegalStateException("Server not ready")).submitAndJoin(r);
|
||||
}
|
||||
|
||||
public void sync(Runnable task) {
|
||||
this.syncExecutor.execute(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor sync() {
|
||||
return this.sync;
|
||||
public void sync(Sender ctx, Runnable task) {
|
||||
this.syncExecutor.execute(task);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import me.lucko.luckperms.common.plugin.bootstrap.LuckPermsBootstrap;
|
|||
import me.lucko.luckperms.common.plugin.classpath.ClassPathAppender;
|
||||
import me.lucko.luckperms.common.plugin.logging.Log4jPluginLogger;
|
||||
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
|
||||
import net.fabricmc.api.DedicatedServerModInitializer;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
@ -73,7 +72,7 @@ public final class LPFabricBootstrap implements LuckPermsBootstrap, DedicatedSer
|
|||
/**
|
||||
* A scheduler adapter for the platform
|
||||
*/
|
||||
private final SchedulerAdapter schedulerAdapter;
|
||||
private final FabricSchedulerAdapter schedulerAdapter;
|
||||
|
||||
/**
|
||||
* The plugin class path appender
|
||||
|
@ -116,7 +115,7 @@ public final class LPFabricBootstrap implements LuckPermsBootstrap, DedicatedSer
|
|||
}
|
||||
|
||||
@Override
|
||||
public SchedulerAdapter getScheduler() {
|
||||
public FabricSchedulerAdapter getScheduler() {
|
||||
return this.schedulerAdapter;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public class FabricAutoOpListener implements LuckPermsEventListener {
|
|||
if (callerIsSync) {
|
||||
setOp(player, value);
|
||||
} else {
|
||||
this.plugin.getBootstrap().getScheduler().executeSync(() -> setOp(player, value));
|
||||
this.plugin.getBootstrap().getScheduler().sync(() -> setOp(player, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import net.luckperms.api.event.EventBus;
|
|||
import net.luckperms.api.event.context.ContextUpdateEvent;
|
||||
import net.luckperms.api.event.group.GroupDataRecalculateEvent;
|
||||
import net.luckperms.api.event.user.UserDataRecalculateEvent;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -89,14 +90,15 @@ public class FabricCommandListUpdater implements LuckPermsEventListener {
|
|||
|
||||
// Called when the buffer times out.
|
||||
private void sendUpdate(UUID uniqueId) {
|
||||
this.plugin.getBootstrap().getScheduler().sync()
|
||||
.execute(() -> this.plugin.getBootstrap().getPlayer(uniqueId)
|
||||
.ifPresent(player -> this.plugin.getBootstrap().getServer()
|
||||
.ifPresent(server -> {
|
||||
server.getPlayerManager().sendCommandTree(player);
|
||||
})
|
||||
)
|
||||
);
|
||||
this.plugin.getBootstrap().getScheduler().sync(() -> {
|
||||
ServerPlayerEntity player = this.plugin.getBootstrap().getPlayer(uniqueId).orElse(null);
|
||||
if (player != null) {
|
||||
MinecraftServer server = player.getServer();
|
||||
if (server != null) {
|
||||
server.getPlayerManager().sendCommandTree(player);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private final class SendBuffer extends BufferedRequest<Void> {
|
||||
|
|
|
@ -25,21 +25,26 @@
|
|||
|
||||
package me.lucko.luckperms.forge;
|
||||
|
||||
import me.lucko.luckperms.common.plugin.scheduler.AbstractJavaScheduler;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.JavaSchedulerAdapter;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public class ForgeSchedulerAdapter extends AbstractJavaScheduler {
|
||||
private final Executor sync;
|
||||
public class ForgeSchedulerAdapter extends JavaSchedulerAdapter {
|
||||
private final Executor syncExecutor;
|
||||
|
||||
public ForgeSchedulerAdapter(LPForgeBootstrap bootstrap) {
|
||||
super(bootstrap);
|
||||
this.sync = r -> bootstrap.getServer().orElseThrow(() -> new IllegalStateException("Server not ready")).executeBlocking(r);
|
||||
this.syncExecutor = r -> bootstrap.getServer().orElseThrow(() -> new IllegalStateException("Server not ready")).executeBlocking(r);
|
||||
}
|
||||
|
||||
public void sync(Runnable task) {
|
||||
this.syncExecutor.execute(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor sync() {
|
||||
return this.sync;
|
||||
public void sync(Sender ctx, Runnable task) {
|
||||
this.syncExecutor.execute(task);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import me.lucko.luckperms.common.plugin.classpath.ClassPathAppender;
|
|||
import me.lucko.luckperms.common.plugin.classpath.JarInJarClassPathAppender;
|
||||
import me.lucko.luckperms.common.plugin.logging.Log4jPluginLogger;
|
||||
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
|
||||
import me.lucko.luckperms.forge.util.ForgeEventBusFacade;
|
||||
import net.luckperms.api.platform.Platform;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
@ -80,7 +79,7 @@ public final class LPForgeBootstrap implements LuckPermsBootstrap, LoaderBootstr
|
|||
/**
|
||||
* A scheduler adapter for the platform
|
||||
*/
|
||||
private final SchedulerAdapter schedulerAdapter;
|
||||
private final ForgeSchedulerAdapter schedulerAdapter;
|
||||
|
||||
/**
|
||||
* The plugin class path appender
|
||||
|
@ -133,7 +132,7 @@ public final class LPForgeBootstrap implements LuckPermsBootstrap, LoaderBootstr
|
|||
}
|
||||
|
||||
@Override
|
||||
public SchedulerAdapter getScheduler() {
|
||||
public ForgeSchedulerAdapter getScheduler() {
|
||||
return this.schedulerAdapter;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public class ForgeAutoOpListener implements LuckPermsEventListener {
|
|||
if (callerIsSync) {
|
||||
setOp(player, value);
|
||||
} else {
|
||||
this.plugin.getBootstrap().getScheduler().executeSync(() -> setOp(player, value));
|
||||
this.plugin.getBootstrap().getScheduler().sync(() -> setOp(player, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,13 +91,14 @@ public class ForgeCommandListUpdater implements LuckPermsEventListener {
|
|||
|
||||
// Called when the buffer times out.
|
||||
private void sendUpdate(UUID uniqueId) {
|
||||
this.plugin.getBootstrap().getScheduler().sync().execute(() -> {
|
||||
this.plugin.getBootstrap().getPlayer(uniqueId).ifPresent(player -> {
|
||||
this.plugin.getBootstrap().getScheduler().sync(() -> {
|
||||
ServerPlayer player = this.plugin.getBootstrap().getPlayer(uniqueId).orElse(null);
|
||||
if (player != null) {
|
||||
MinecraftServer server = player.getServer();
|
||||
if (server != null) {
|
||||
server.getPlayerList().sendPlayerPermissionLevel(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public class AsyncConfigurationTask implements ConfigurationTask {
|
|||
this.plugin.getLogger().warn("Configuration task threw an exception", e);
|
||||
}
|
||||
ctx.finish(type());
|
||||
}, this.plugin.getBootstrap().getScheduler().sync()); // do we need to call this sync?
|
||||
}, this.plugin.getBootstrap().getScheduler()::sync); // do we need to call this sync?
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -202,11 +202,11 @@ public class LPNukkitPlugin extends AbstractLuckPermsPlugin {
|
|||
|
||||
// Load any online users (in the case of a reload)
|
||||
for (Player player : this.bootstrap.getServer().getOnlinePlayers().values()) {
|
||||
this.bootstrap.getScheduler().executeAsync(() -> {
|
||||
this.bootstrap.getScheduler().async(() -> {
|
||||
try {
|
||||
User user = this.connectionListener.loadUser(player.getUniqueId(), player.getName());
|
||||
if (user != null) {
|
||||
this.bootstrap.getScheduler().executeSync(() -> {
|
||||
this.bootstrap.getScheduler().sync(() -> {
|
||||
try {
|
||||
LuckPermsPermissible lpPermissible = new LuckPermsPermissible(player, user, this);
|
||||
PermissibleInjector.inject(player, lpPermissible);
|
||||
|
|
|
@ -25,22 +25,27 @@
|
|||
|
||||
package me.lucko.luckperms.nukkit;
|
||||
|
||||
import me.lucko.luckperms.common.plugin.scheduler.AbstractJavaScheduler;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.JavaSchedulerAdapter;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public class NukkitSchedulerAdapter extends AbstractJavaScheduler implements SchedulerAdapter {
|
||||
private final Executor sync;
|
||||
public class NukkitSchedulerAdapter extends JavaSchedulerAdapter implements SchedulerAdapter {
|
||||
private final Executor syncExecutor;
|
||||
|
||||
public NukkitSchedulerAdapter(LPNukkitBootstrap bootstrap) {
|
||||
super(bootstrap);
|
||||
this.sync = r -> bootstrap.getServer().getScheduler().scheduleTask(bootstrap.getLoader(), r, false);
|
||||
this.syncExecutor = r -> bootstrap.getServer().getScheduler().scheduleTask(bootstrap.getLoader(), r, false);
|
||||
}
|
||||
|
||||
public void sync(Runnable task) {
|
||||
this.syncExecutor.execute(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor sync() {
|
||||
return this.sync;
|
||||
public void sync(Sender ctx, Runnable task) {
|
||||
this.syncExecutor.execute(task);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.sponge;
|
|||
import com.google.common.base.Suppliers;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.SchedulerTask;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Iterators;
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.scheduler.ScheduledTask;
|
||||
|
@ -64,20 +65,24 @@ public class SpongeSchedulerAdapter implements SchedulerAdapter {
|
|||
this.sync = Suppliers.memoize(() -> getSyncScheduler().executor(this.pluginContainer));
|
||||
}
|
||||
|
||||
public Scheduler getSyncScheduler() {
|
||||
return this.game.server().scheduler();
|
||||
}
|
||||
|
||||
public void sync(Runnable task) {
|
||||
this.sync.get().execute(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync(Sender ctx, Runnable task) {
|
||||
this.sync.get().execute(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor async() {
|
||||
return this.async;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor sync() {
|
||||
return this.sync.get();
|
||||
}
|
||||
|
||||
public Scheduler getSyncScheduler() {
|
||||
return this.game.server().scheduler();
|
||||
}
|
||||
|
||||
private SchedulerTask submitAsyncTask(Runnable runnable, Consumer<Task.Builder> config) {
|
||||
Task.Builder builder = Task.builder();
|
||||
config.accept(builder);
|
||||
|
|
|
@ -79,7 +79,7 @@ public class SpongeCommandListUpdater implements LuckPermsEventListener {
|
|||
|
||||
// Called when the buffer times out.
|
||||
private void sendUpdate(UUID uniqueId) {
|
||||
this.plugin.getBootstrap().getScheduler().sync().execute(() -> {
|
||||
this.plugin.getBootstrap().getScheduler().sync(() -> {
|
||||
ServerPlayer player = this.plugin.getBootstrap().getPlayer(uniqueId).orElse(null);
|
||||
if (player != null) {
|
||||
CommandManager commandManager = this.plugin.getBootstrap().getGame().server().commandManager();
|
||||
|
|
|
@ -246,7 +246,7 @@ public class LuckPermsService implements LPPermissionService {
|
|||
|
||||
@Override
|
||||
public void fireUpdateEvent(LPSubjectData subjectData) {
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
||||
this.plugin.getBootstrap().getScheduler().async(() -> {
|
||||
SubjectDataUpdateEvent event = new SubjectDataUpdateEventImpl(this.plugin, subjectData);
|
||||
this.plugin.getBootstrap().getGame().eventManager().post(event);
|
||||
});
|
||||
|
|
|
@ -32,6 +32,8 @@ import me.lucko.luckperms.common.plugin.classpath.ClassPathAppender;
|
|||
import me.lucko.luckperms.common.plugin.classpath.JarInJarClassPathAppender;
|
||||
import me.lucko.luckperms.common.plugin.logging.Log4jPluginLogger;
|
||||
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.JavaSchedulerAdapter;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
|
||||
import me.lucko.luckperms.standalone.app.LuckPermsApplication;
|
||||
import net.luckperms.api.platform.Platform;
|
||||
|
||||
|
@ -51,7 +53,7 @@ public class LPStandaloneBootstrap implements LuckPermsBootstrap, LoaderBootstra
|
|||
private final LuckPermsApplication loader;
|
||||
|
||||
private final PluginLogger logger;
|
||||
private final StandaloneSchedulerAdapter schedulerAdapter;
|
||||
private final SchedulerAdapter schedulerAdapter;
|
||||
private final ClassPathAppender classPathAppender;
|
||||
private final LPStandalonePlugin plugin;
|
||||
|
||||
|
@ -63,7 +65,7 @@ public class LPStandaloneBootstrap implements LuckPermsBootstrap, LoaderBootstra
|
|||
this.loader = loader;
|
||||
|
||||
this.logger = new Log4jPluginLogger(LuckPermsApplication.LOGGER);
|
||||
this.schedulerAdapter = new StandaloneSchedulerAdapter(this);
|
||||
this.schedulerAdapter = new JavaSchedulerAdapter(this);
|
||||
this.classPathAppender = new JarInJarClassPathAppender(getClass().getClassLoader());
|
||||
this.plugin = new LPStandalonePlugin(this);
|
||||
}
|
||||
|
@ -73,7 +75,7 @@ public class LPStandaloneBootstrap implements LuckPermsBootstrap, LoaderBootstra
|
|||
this.loader = loader;
|
||||
|
||||
this.logger = new Log4jPluginLogger(LuckPermsApplication.LOGGER);
|
||||
this.schedulerAdapter = new StandaloneSchedulerAdapter(this);
|
||||
this.schedulerAdapter = new JavaSchedulerAdapter(this);
|
||||
this.classPathAppender = classPathAppender;
|
||||
this.plugin = createTestPlugin();
|
||||
}
|
||||
|
@ -96,7 +98,7 @@ public class LPStandaloneBootstrap implements LuckPermsBootstrap, LoaderBootstra
|
|||
}
|
||||
|
||||
@Override
|
||||
public StandaloneSchedulerAdapter getScheduler() {
|
||||
public SchedulerAdapter getScheduler() {
|
||||
return this.schedulerAdapter;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* 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.standalone;
|
||||
|
||||
import me.lucko.luckperms.common.plugin.scheduler.AbstractJavaScheduler;
|
||||
import me.lucko.luckperms.common.plugin.scheduler.SchedulerAdapter;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public class StandaloneSchedulerAdapter extends AbstractJavaScheduler implements SchedulerAdapter {
|
||||
|
||||
public StandaloneSchedulerAdapter(LPStandaloneBootstrap bootstrap) {
|
||||
super(bootstrap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor sync() {
|
||||
return this.async();
|
||||
}
|
||||
|
||||
}
|
|
@ -52,11 +52,6 @@ public class VelocitySchedulerAdapter implements SchedulerAdapter {
|
|||
return this.executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor sync() {
|
||||
return this.executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchedulerTask asyncLater(Runnable task, long delay, TimeUnit unit) {
|
||||
ScheduledTask t = this.bootstrap.getProxy().getScheduler().buildTask(this.bootstrap, task)
|
||||
|
|
|
@ -77,7 +77,7 @@ public class VelocityConnectionListener extends AbstractConnectionListener {
|
|||
this.plugin.getLogger().info("Processing pre-login for " + p.getUniqueId() + " - " + p.getUsername());
|
||||
}
|
||||
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
||||
this.plugin.getBootstrap().getScheduler().async(() -> {
|
||||
/* Actually process the login for the connection.
|
||||
We do this here to delay the login until the data is ready.
|
||||
If the login gets cancelled later on, then this will be cleaned up.
|
||||
|
|
|
@ -90,7 +90,7 @@ public class PluginMessageMessenger extends AbstractPluginMessageMessenger {
|
|||
|
||||
if (handleIncomingMessage(buf)) {
|
||||
// Forward to other servers
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(() -> sendOutgoingMessage(buf));
|
||||
this.plugin.getBootstrap().getScheduler().async(() -> sendOutgoingMessage(buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue