mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
Expand chat event
This commit is contained in:
1 parent
6a5ae84d3f
commit
73c7f3f78f
7 files changed
+107
-84
No files matched your search
@@ -3,19 +3,41 @@ package net.draycia.carbon.common;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.events.CarbonEventHandler;
|
||||
import net.draycia.carbon.api.util.ChatComponentRenderer;
|
||||
import net.draycia.carbon.common.command.Commander;
|
||||
import net.draycia.carbon.common.command.PlayerCommander;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import static net.kyori.adventure.text.Component.empty;
|
||||
import static net.kyori.adventure.text.Component.text;
|
||||
import static net.kyori.adventure.text.Component.translatable;
|
||||
import static net.kyori.adventure.text.format.NamedTextColor.DARK_GRAY;
|
||||
import static net.kyori.adventure.text.format.TextDecoration.BOLD;
|
||||
|
||||
public abstract class CarbonChatCommon implements CarbonChat {
|
||||
|
||||
// Mimics vanilla chat, should be *visually* identical but without the hover stuff.
|
||||
// Temporary: This will be removed in the future.
|
||||
@Deprecated(forRemoval = true)
|
||||
public final @NonNull ChatComponentRenderer vanillaChatRenderer =
|
||||
(sender, recipient, message, originalMessage) -> {
|
||||
final var clickEvent = ClickEvent.suggestCommand("/msg " + sender.username());
|
||||
final var hoverEvent = HoverEvent.showEntity(Key.key("player"),
|
||||
sender.uuid(), text(sender.username()));
|
||||
|
||||
final var name = sender.displayName()
|
||||
.clickEvent(clickEvent)
|
||||
.hoverEvent(hoverEvent)
|
||||
.insertion(sender.username());
|
||||
|
||||
return translatable("chat.type.text", name, message);
|
||||
};
|
||||
|
||||
private final CarbonEventHandler eventHandler = new CarbonEventHandler();
|
||||
|
||||
public final void initialize() {
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
// TODO: remove
|
||||
public final class Injector {
|
||||
|
||||
private Injector() {
|
||||
@@ -13,10 +14,12 @@ public final class Injector {
|
||||
|
||||
private static final Map<Class<?>, Object> providers = new HashMap<>();
|
||||
|
||||
public static <T> T byInject(final @NonNull Class<T> clazz) {
|
||||
return (T) providers.get(clazz);
|
||||
@Deprecated(forRemoval = true)
|
||||
public static <T, S extends T> S byInject(final @NonNull Class<T> clazz) {
|
||||
return (S) providers.get(clazz);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static <T> void provide(final @NonNull Class<T> clazz, final @NonNull T provider) {
|
||||
providers.put(clazz, provider);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user