-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ban-sync-role
- Loading branch information
Showing
68 changed files
with
1,145 additions
and
501 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...pat/paper/src/main/java/com/discordsrv/bukkit/listener/PaperLegacyChatRenderListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.discordsrv.bukkit.listener; | ||
|
||
import com.discordsrv.api.component.MinecraftComponent; | ||
import com.discordsrv.api.events.message.render.GameChatRenderEvent; | ||
import com.discordsrv.bukkit.BukkitDiscordSRV; | ||
import com.discordsrv.bukkit.component.PaperComponentHandle; | ||
import com.discordsrv.common.abstraction.player.IPlayer; | ||
import com.discordsrv.common.core.logging.NamedLogger; | ||
import com.discordsrv.common.feature.channel.global.GlobalChannel; | ||
import io.papermc.paper.event.player.AsyncChatEvent; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class PaperLegacyChatRenderListener extends AbstractBukkitListener<AsyncChatEvent> { | ||
|
||
private static final PaperComponentHandle.Get<AsyncChatEvent> GET_MESSAGE_HANDLE | ||
= PaperComponentHandle.get(AsyncChatEvent.class, "message"); | ||
private static final PaperComponentHandle.Set<AsyncChatEvent> SET_MESSAGE_HANDLE | ||
= PaperComponentHandle.set(AsyncChatEvent.class, "message"); | ||
|
||
public PaperLegacyChatRenderListener(BukkitDiscordSRV discordSRV) { | ||
super(discordSRV, new NamedLogger(discordSRV, "CHAT_RENDER_LISTENER")); | ||
} | ||
|
||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) | ||
public void onAsyncChat(AsyncChatEvent event) { | ||
handleEventWithErrorHandling(event); | ||
} | ||
|
||
@Override | ||
protected void handleEvent(@NotNull AsyncChatEvent event, Void __) { | ||
Player bukkitPlayer = event.getPlayer(); | ||
|
||
IPlayer player = discordSRV.playerProvider().player(bukkitPlayer); | ||
MinecraftComponent message = GET_MESSAGE_HANDLE.getAPI(event); | ||
|
||
GameChatRenderEvent annotateEvent = new GameChatRenderEvent( | ||
event, | ||
player, | ||
new GlobalChannel(discordSRV), | ||
message | ||
); | ||
|
||
discordSRV.eventBus().publish(annotateEvent); | ||
|
||
MinecraftComponent annotatedMessage = annotateEvent.getAnnotatedMessage(); | ||
if (annotatedMessage != null) { | ||
SET_MESSAGE_HANDLE.call(event, annotatedMessage); | ||
} | ||
} | ||
|
||
// Already observed via normal chat listener | ||
@Override | ||
protected void observeEvents(boolean enable) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.