mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Register DSRV hook earlier in the lifecycle
Fixes an issue where channel commands would send in multiple channels
This commit is contained in:
1 parent
90843e084c
commit
99aa026ec1
4 files changed
+6
-59
No files matched your search
@@ -23,6 +23,7 @@ import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import github.scarsz.discordsrv.DiscordSRV;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Set;
|
||||
@@ -37,8 +38,8 @@ import net.draycia.carbon.api.util.RenderedMessage;
|
||||
import net.draycia.carbon.bukkit.listeners.BukkitChatListener;
|
||||
import net.draycia.carbon.bukkit.listeners.BukkitPlayerJoinListener;
|
||||
import net.draycia.carbon.bukkit.listeners.DiscordMessageListener;
|
||||
import net.draycia.carbon.bukkit.listeners.DiscordSRVListener;
|
||||
import net.draycia.carbon.bukkit.util.BukkitMessageRenderer;
|
||||
import net.draycia.carbon.bukkit.util.CarbonChatHook;
|
||||
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
|
||||
import net.draycia.carbon.common.messages.CarbonMessageService;
|
||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||
@@ -138,7 +139,8 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
}
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("DiscordSRV")) {
|
||||
this.injector.getInstance(DiscordSRVListener.class);
|
||||
this.logger.info("DiscordSRV found! Enabling hook.");
|
||||
DiscordSRV.getPlugin().getPluginHooks().add(new CarbonChatHook());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* CarbonChat
|
||||
*
|
||||
* Copyright (c) 2021 Josua Parks (Vicarious)
|
||||
* Contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.draycia.carbon.bukkit.listeners;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import github.scarsz.discordsrv.DiscordSRV;
|
||||
import github.scarsz.discordsrv.api.Subscribe;
|
||||
import github.scarsz.discordsrv.api.events.DiscordReadyEvent;
|
||||
import github.scarsz.discordsrv.api.events.GameChatMessagePostProcessEvent;
|
||||
import net.draycia.carbon.bukkit.util.CarbonChatHook;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@Singleton
|
||||
public final class DiscordSRVListener {
|
||||
|
||||
private final Logger logger;
|
||||
|
||||
@Inject
|
||||
public DiscordSRVListener(final Logger logger) {
|
||||
this.logger = logger;
|
||||
|
||||
this.logger.info("DiscordSRV found! Enabling hook.");
|
||||
DiscordSRV.api.subscribe(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onDiscordReady(final DiscordReadyEvent event) {
|
||||
DiscordSRV.getPlugin().getPluginHooks().add(new CarbonChatHook());
|
||||
this.logger.info("Successfully enabled DiscordSRV hook!");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameChat(final GameChatMessagePostProcessEvent event) {
|
||||
//event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class CarbonChatHook implements ChatHook {
|
||||
|
||||
@Override
|
||||
public void broadcastMessageToChannel(final String channel, final github.scarsz.discordsrv.dependencies.kyori.adventure.text.Component message) {
|
||||
final String mmFormattedMessage = MiniMessage.get().serialize(message);
|
||||
final String mmFormattedMessage = MiniMessage.miniMessage().serialize(message);
|
||||
ChannelUtils.broadcastMessageToChannel(mmFormattedMessage, ChannelUtils.locateChannel(channel));
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ versions:
|
||||
adventurePlatformFabric: 5.2.0
|
||||
luckPermsApi: 5.3
|
||||
essentialsx: 2.19.3
|
||||
discordsrv: 1.25.0
|
||||
discordsrv: 1.26.0-SNAPSHOT
|
||||
|
||||
dependencies:
|
||||
adventureBom:
|
||||
|
||||
Reference in new issue
Block a user