Skip to content

New CarbonChat integration#55

Open
OoLunar wants to merge 1 commit intoDiscordSRV:mainfrom
OoLunar:main
Open

New CarbonChat integration#55
OoLunar wants to merge 1 commit intoDiscordSRV:mainfrom
OoLunar:main

Conversation

@OoLunar
Copy link
Copy Markdown

@OoLunar OoLunar commented Mar 29, 2026

Lots of CarbonChat classes have been shimmed to avoid runtime NoSuchMethodException errors due to the Adventure API being relocated (as both DiscordSRV and Carbon use it). I am not too familiar with the DiscordSRV codebase so if there's a different way you'd prefer for this changes to be made, please either leave a PR review with detailed instructions of how to do so, or simply make edits to the PR directly.

Changes have been lightly tested and seem to work, however further testing is currently being done.

Copy link
Copy Markdown
Member

@Vankka Vankka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing this, I've left comments below

And I agree that dealing with relocated & unrelocated dependencies at the same time is a pain. Last time I checked shadowJar didn't have a way to exclude source files from having relocations applied to them, unfortunately (albeit this was a long time ago).

I'm fine with the unrelocate approach for now, but I will probably try to find a neater approach in the future (maybe just a separate paper artifact that doesn't relocate adventure dependencies)


if (PaperComponentCheck.IS_AVAILABLE) {
// Paper (Since 1.16)
registerIntegration("com.discordsrv.bukkit.integration.chat.CarbonChatIntegration");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to the BukkitDiscordSRV class to be together with the other integrations

Comment on lines +53 to +57
static MinecraftComponent message(CarbonChatEvent event) {
return MinecraftComponent.fromAdventure(
((com.discordsrv.unrelocate.net.draycia.carbon.api.event.events.CarbonChatEvent) (Object) event)
.message());
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be replaced by the PaperComponentHandle helper class,

private static final PaperComponentHandle.Get<CarbonChatEvent> MESSAGE_HANDLE = PaperComponentHandle.get(CarbonChatEvent.class, "message");

MinecraftComponent component = MESSAGE_HANDLE.getAPI(event);

Comment on lines +95 to +97
discordSRV.scheduler().run(() -> discordSRV.eventBus().publish(
new GameChatMessagePreProcessEvent(null, srvPlayer, component, new CarbonGameChannel(chatChannel),
false)));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
discordSRV.scheduler().run(() -> discordSRV.eventBus().publish(
new GameChatMessagePreProcessEvent(null, srvPlayer, component, new CarbonGameChannel(chatChannel),
false)));
discordSRV.scheduler().run(() -> discordSRV.eventBus().publish(
new GameChatMessagePreProcessEvent(null, srvPlayer, component, new CarbonGameChannel(chatChannel), false)
));

Comment on lines +41 to +43
if (key.value().equalsIgnoreCase(channelName) || channel.commandName().equalsIgnoreCase(channelName)) {
return channel;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the namespace on these keys constant? If not this should probably match the entire key as well as the value (if there are possible overlapping values)

I would prefer to drop the command name matching, or have it deprioritized so the all the keys are checked before any command names are checked (is the actual channel name hard to find for the user?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants