mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 22:16:22 +00:00
Fix injection issue and cleanup CCProvider usage
This commit is contained in:
1 parent
2e280eb410
commit
85612eb94c
7 files changed
+53
-32
No files matched your search
@@ -125,7 +125,7 @@ public final class CarbonChatPaper extends CarbonChatInternal<CarbonPlayerPaper>
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("DiscordSRV")) {
|
||||
this.logger().info("DiscordSRV found! Enabling hook.");
|
||||
DiscordSRV.getPlugin().getPluginHooks().add(new DSRVChatHook());
|
||||
DiscordSRV.getPlugin().getPluginHooks().add(new DSRVChatHook(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ package net.draycia.carbon.paper.hooks;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.google.inject.Inject;
|
||||
import github.scarsz.discordsrv.Debug;
|
||||
import github.scarsz.discordsrv.DiscordSRV;
|
||||
import github.scarsz.discordsrv.api.Subscribe;
|
||||
@@ -29,7 +30,7 @@ import github.scarsz.discordsrv.dependencies.kyori.adventure.text.minimessage.Mi
|
||||
import github.scarsz.discordsrv.hooks.chat.ChatHook;
|
||||
import github.scarsz.discordsrv.util.PluginUtil;
|
||||
import java.time.Duration;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.event.events.CarbonChatEvent;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
@@ -45,12 +46,14 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class DSRVChatHook implements ChatHook {
|
||||
|
||||
public DSRVChatHook() {
|
||||
@Inject
|
||||
public DSRVChatHook(final CarbonChat carbonChat) {
|
||||
|
||||
final Cache<ImmutablePair<CarbonPlayer, ChatChannel>, Component> awaitingEvent = Caffeine.newBuilder()
|
||||
.expireAfterWrite(Duration.ofMillis(25))
|
||||
.build();
|
||||
|
||||
CarbonChatProvider.carbonChat().eventHandler().subscribe(CarbonChatEvent.class, event -> {
|
||||
carbonChat.eventHandler().subscribe(CarbonChatEvent.class, event -> {
|
||||
final ChatChannel chatChannel = event.chatChannel();
|
||||
final CarbonPlayer carbonPlayer = event.sender();
|
||||
final ImmutablePair<CarbonPlayer, ChatChannel> pair = new ImmutablePair<>(carbonPlayer, chatChannel);
|
||||
|
||||
Reference in new issue
Block a user