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
|
// Command handler
|
||||||
commandHandler = AbstractBukkitCommandHandler.get(this);
|
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
|
// Modules
|
||||||
registerModule(MinecraftToDiscordChatModule::new);
|
registerModule(MinecraftToDiscordChatModule::new);
|
||||||
registerModule(BukkitRequiredLinkingModule::new);
|
registerModule(BukkitRequiredLinkingModule::new);
|
||||||
@ -203,6 +197,12 @@ public class BukkitDiscordSRV extends ServerDiscordSRV<DiscordSRVBukkitBootstrap
|
|||||||
|
|
||||||
super.enable();
|
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
|
// Connection listener
|
||||||
server().getPluginManager().registerEvents(new BukkitConnectionListener(this), plugin());
|
server().getPluginManager().registerEvents(new BukkitConnectionListener(this), plugin());
|
||||||
}
|
}
|
||||||
|
@ -92,11 +92,12 @@ public abstract class AbstractBukkitCommandHandler implements ICommandHandler {
|
|||||||
String label = gameCommand.getLabel();
|
String label = gameCommand.getLabel();
|
||||||
PluginCommand pluginCommand = discordSRV.plugin().getCommand(label);
|
PluginCommand pluginCommand = discordSRV.plugin().getCommand(label);
|
||||||
if (pluginCommand != null) {
|
if (pluginCommand != null) {
|
||||||
|
logger.debug("PluginCommand available for \"" + label + "\"");
|
||||||
return pluginCommand;
|
return pluginCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (COMMAND_MAP_HANDLE == null) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,8 +108,16 @@ public abstract class AbstractBukkitCommandHandler implements ICommandHandler {
|
|||||||
command = (PluginCommand) constructor.newInstance(label, discordSRV.plugin());
|
command = (PluginCommand) constructor.newInstance(label, discordSRV.plugin());
|
||||||
|
|
||||||
CommandMap commandMap = (CommandMap) COMMAND_MAP_HANDLE.invokeExact(discordSRV.server());
|
CommandMap commandMap = (CommandMap) COMMAND_MAP_HANDLE.invokeExact(discordSRV.server());
|
||||||
commandMap.register(label, discordSRV.plugin().getName().toLowerCase(Locale.ROOT), command);
|
boolean result = commandMap.register(label, discordSRV.plugin().getName().toLowerCase(Locale.ROOT), command);
|
||||||
} catch (Throwable ignored) {}
|
|
||||||
|
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;
|
return command;
|
||||||
}
|
}
|
||||||
|
@ -48,16 +48,18 @@ public class BukkitBasicCommandHandler extends AbstractBukkitCommandExecutor imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCommand(GameCommand command) {
|
public void registerCommand(GameCommand command) {
|
||||||
PluginCommand pluginCommand = command(command);
|
discordSRV.scheduler().runOnMainThread(() -> {
|
||||||
if (pluginCommand == null) {
|
PluginCommand pluginCommand = command(command);
|
||||||
logger.error("Failed to create command " + command.getLabel());
|
if (pluginCommand == null) {
|
||||||
return;
|
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);
|
handler.registerCommand(command);
|
||||||
pluginCommand.setExecutor(this);
|
pluginCommand.setExecutor(this);
|
||||||
pluginCommand.setTabCompleter(this);
|
pluginCommand.setTabCompleter(this);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import com.discordsrv.common.command.game.sender.ICommandSender;
|
|||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
import me.lucko.commodore.Commodore;
|
import me.lucko.commodore.Commodore;
|
||||||
import me.lucko.commodore.CommodoreProvider;
|
import me.lucko.commodore.CommodoreProvider;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -43,7 +44,7 @@ public class CommodoreHandler extends AbstractBukkitCommandExecutor {
|
|||||||
public CommodoreHandler(BukkitDiscordSRV discordSRV) {
|
public CommodoreHandler(BukkitDiscordSRV discordSRV) {
|
||||||
super(discordSRV);
|
super(discordSRV);
|
||||||
this.commodore = CommodoreProvider.getCommodore(discordSRV.plugin());
|
this.commodore = CommodoreProvider.getCommodore(discordSRV.plugin());
|
||||||
this.senderFunction = wrapper -> sender(commodore.getBukkitSender(wrapper));
|
this.senderFunction = wrapper -> sender((CommandSender) wrapper); // This is probably wrong...
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -553,9 +553,6 @@ public abstract class AbstractDiscordSRV<B extends IBootstrap, C extends MainCon
|
|||||||
// Logging
|
// Logging
|
||||||
DependencyLoggerAdapter.setAppender(new DependencyLoggingHandler(this));
|
DependencyLoggerAdapter.setAppender(new DependencyLoggingHandler(this));
|
||||||
|
|
||||||
// Register PlayerProvider listeners
|
|
||||||
playerProvider().subscribe();
|
|
||||||
|
|
||||||
// Placeholder result stringifiers & global contexts
|
// Placeholder result stringifiers & global contexts
|
||||||
placeholderService().addResultMapper(new ComponentResultStringifier(this));
|
placeholderService().addResultMapper(new ComponentResultStringifier(this));
|
||||||
placeholderService().addGlobalContext(new GlobalTextHandlingContext(this));
|
placeholderService().addGlobalContext(new GlobalTextHandlingContext(this));
|
||||||
@ -584,6 +581,9 @@ public abstract class AbstractDiscordSRV<B extends IBootstrap, C extends MainCon
|
|||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
throw e.getCause();
|
throw e.getCause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register PlayerProvider listeners
|
||||||
|
playerProvider().subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void startedMessage() {
|
protected final void startedMessage() {
|
||||||
@ -610,6 +610,13 @@ public abstract class AbstractDiscordSRV<B extends IBootstrap, C extends MainCon
|
|||||||
this.status.set(Status.SHUTTING_DOWN);
|
this.status.set(Status.SHUTTING_DOWN);
|
||||||
eventBus().publish(new DiscordSRVShuttingDownEvent());
|
eventBus().publish(new DiscordSRVShuttingDownEvent());
|
||||||
eventBus().shutdown();
|
eventBus().shutdown();
|
||||||
|
try {
|
||||||
|
if (storage != null) {
|
||||||
|
storage.close();
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
logger().error("Failed to close storage connection", t);
|
||||||
|
}
|
||||||
this.status.set(Status.SHUTDOWN);
|
this.status.set(Status.SHUTDOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ dependencyResolutionManagement {
|
|||||||
|
|
||||||
// Brigadier & Commodore
|
// Brigadier & Commodore
|
||||||
library('brigadier', 'com.mojang', 'brigadier').version('1.0.18')
|
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
|
// Integrations
|
||||||
library('luckperms', 'net.luckperms', 'api').version('5.4')
|
library('luckperms', 'net.luckperms', 'api').version('5.4')
|
||||||
|
Loading…
Reference in New Issue
Block a user