mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-10-31 08:32:18 +01:00
Fix order some stuff is loaded, update Commodore
This commit is contained in:
parent
56af07e1e8
commit
4e4b21ae7c
@ -179,12 +179,6 @@ public class BukkitDiscordSRV extends ServerDiscordSRV<DiscordSRVBukkitBootstrap
|
||||
// Command handler
|
||||
commandHandler = AbstractBukkitCommandHandler.get(this);
|
||||
|
||||
// Register listeners
|
||||
server().getPluginManager().registerEvents(BukkitAwardForwarder.get(this), plugin());
|
||||
server().getPluginManager().registerEvents(BukkitChatForwarder.get(this), plugin());
|
||||
server().getPluginManager().registerEvents(new BukkitDeathListener(this), plugin());
|
||||
server().getPluginManager().registerEvents(new BukkitStatusMessageListener(this), plugin());
|
||||
|
||||
// Modules
|
||||
registerModule(MinecraftToDiscordChatModule::new);
|
||||
registerModule(BukkitRequiredLinkingModule::new);
|
||||
@ -203,6 +197,12 @@ public class BukkitDiscordSRV extends ServerDiscordSRV<DiscordSRVBukkitBootstrap
|
||||
|
||||
super.enable();
|
||||
|
||||
// Register listeners
|
||||
server().getPluginManager().registerEvents(BukkitAwardForwarder.get(this), plugin());
|
||||
server().getPluginManager().registerEvents(BukkitChatForwarder.get(this), plugin());
|
||||
server().getPluginManager().registerEvents(new BukkitDeathListener(this), plugin());
|
||||
server().getPluginManager().registerEvents(new BukkitStatusMessageListener(this), plugin());
|
||||
|
||||
// Connection listener
|
||||
server().getPluginManager().registerEvents(new BukkitConnectionListener(this), plugin());
|
||||
}
|
||||
|
@ -92,11 +92,12 @@ public abstract class AbstractBukkitCommandHandler implements ICommandHandler {
|
||||
String label = gameCommand.getLabel();
|
||||
PluginCommand pluginCommand = discordSRV.plugin().getCommand(label);
|
||||
if (pluginCommand != null) {
|
||||
logger.debug("PluginCommand available for \"" + label + "\"");
|
||||
return pluginCommand;
|
||||
}
|
||||
|
||||
if (COMMAND_MAP_HANDLE == null) {
|
||||
// CommandMap unusable, can't get the command from it
|
||||
logger.debug("Unable to get command from command map");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -107,8 +108,16 @@ public abstract class AbstractBukkitCommandHandler implements ICommandHandler {
|
||||
command = (PluginCommand) constructor.newInstance(label, discordSRV.plugin());
|
||||
|
||||
CommandMap commandMap = (CommandMap) COMMAND_MAP_HANDLE.invokeExact(discordSRV.server());
|
||||
commandMap.register(label, discordSRV.plugin().getName().toLowerCase(Locale.ROOT), command);
|
||||
} catch (Throwable ignored) {}
|
||||
boolean result = commandMap.register(label, discordSRV.plugin().getName().toLowerCase(Locale.ROOT), command);
|
||||
|
||||
if (result) {
|
||||
logger.debug("Registered command \"" + label + "\" in CommandMap successfully");
|
||||
} else {
|
||||
logger.debug("Registered command \"" + label + "\" into CommandMap but with fallback prefix");
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.debug("Failed to register command \"" + label + "\" to CommandMap", t);
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
|
@ -48,16 +48,18 @@ public class BukkitBasicCommandHandler extends AbstractBukkitCommandExecutor imp
|
||||
|
||||
@Override
|
||||
public void registerCommand(GameCommand command) {
|
||||
PluginCommand pluginCommand = command(command);
|
||||
if (pluginCommand == null) {
|
||||
logger.error("Failed to create command " + command.getLabel());
|
||||
return;
|
||||
}
|
||||
discordSRV.scheduler().runOnMainThread(() -> {
|
||||
PluginCommand pluginCommand = command(command);
|
||||
if (pluginCommand == null) {
|
||||
logger.error("Failed to create command " + command.getLabel());
|
||||
return;
|
||||
}
|
||||
|
||||
logger.debug("Registering command " + command.getLabel() + " with basic handler");
|
||||
logger.debug("Registering command " + command.getLabel() + " with basic handler");
|
||||
|
||||
handler.registerCommand(command);
|
||||
pluginCommand.setExecutor(this);
|
||||
pluginCommand.setTabCompleter(this);
|
||||
handler.registerCommand(command);
|
||||
pluginCommand.setExecutor(this);
|
||||
pluginCommand.setTabCompleter(this);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import com.discordsrv.common.command.game.sender.ICommandSender;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import me.lucko.commodore.Commodore;
|
||||
import me.lucko.commodore.CommodoreProvider;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -43,7 +44,7 @@ public class CommodoreHandler extends AbstractBukkitCommandExecutor {
|
||||
public CommodoreHandler(BukkitDiscordSRV discordSRV) {
|
||||
super(discordSRV);
|
||||
this.commodore = CommodoreProvider.getCommodore(discordSRV.plugin());
|
||||
this.senderFunction = wrapper -> sender(commodore.getBukkitSender(wrapper));
|
||||
this.senderFunction = wrapper -> sender((CommandSender) wrapper); // This is probably wrong...
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -553,9 +553,6 @@ public abstract class AbstractDiscordSRV<B extends IBootstrap, C extends MainCon
|
||||
// Logging
|
||||
DependencyLoggerAdapter.setAppender(new DependencyLoggingHandler(this));
|
||||
|
||||
// Register PlayerProvider listeners
|
||||
playerProvider().subscribe();
|
||||
|
||||
// Placeholder result stringifiers & global contexts
|
||||
placeholderService().addResultMapper(new ComponentResultStringifier(this));
|
||||
placeholderService().addGlobalContext(new GlobalTextHandlingContext(this));
|
||||
@ -584,6 +581,9 @@ public abstract class AbstractDiscordSRV<B extends IBootstrap, C extends MainCon
|
||||
} catch (ExecutionException e) {
|
||||
throw e.getCause();
|
||||
}
|
||||
|
||||
// Register PlayerProvider listeners
|
||||
playerProvider().subscribe();
|
||||
}
|
||||
|
||||
protected final void startedMessage() {
|
||||
@ -610,6 +610,13 @@ public abstract class AbstractDiscordSRV<B extends IBootstrap, C extends MainCon
|
||||
this.status.set(Status.SHUTTING_DOWN);
|
||||
eventBus().publish(new DiscordSRVShuttingDownEvent());
|
||||
eventBus().shutdown();
|
||||
try {
|
||||
if (storage != null) {
|
||||
storage.close();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger().error("Failed to close storage connection", t);
|
||||
}
|
||||
this.status.set(Status.SHUTDOWN);
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ dependencyResolutionManagement {
|
||||
|
||||
// Brigadier & Commodore
|
||||
library('brigadier', 'com.mojang', 'brigadier').version('1.0.18')
|
||||
library('commodore', 'me.lucko', 'commodore').version('1.13')
|
||||
library('commodore', 'me.lucko', 'commodore').version('2.2')
|
||||
|
||||
// Integrations
|
||||
library('luckperms', 'net.luckperms', 'api').version('5.4')
|
||||
|
Loading…
Reference in New Issue
Block a user