mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Update moonshine, add auto-nickname (#155)
This commit is contained in:
1 parent
74e83a08a0
commit
3b1987b5a2
71 files changed
+1022
-829
No files matched your search
@@ -12,12 +12,12 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class CarbonChatProvider {
|
||||
|
||||
private static @Nullable CarbonChat instance;
|
||||
|
||||
private CarbonChatProvider() {
|
||||
|
||||
}
|
||||
|
||||
private static @Nullable CarbonChat instance;
|
||||
|
||||
/**
|
||||
* Registers the {@link CarbonChat} implementation.
|
||||
*
|
||||
|
||||
@@ -52,7 +52,7 @@ public interface ChatChannel extends Keyed, ChatComponentRenderer {
|
||||
/**
|
||||
* Filters the given recipients and removes entries that may not see messages in this channel.
|
||||
*
|
||||
* @param sender the sender of messages
|
||||
* @param sender the sender of messages
|
||||
* @param recipients the recipients
|
||||
* @return the recipients that may receive messages
|
||||
* @since 2.0.0
|
||||
|
||||
@@ -21,8 +21,8 @@ public class CarbonChatEvent implements ResultedCarbonEvent<CarbonChatEvent.Resu
|
||||
private final List<KeyedRenderer> renderers;
|
||||
private final CarbonPlayer sender;
|
||||
private final Component originalMessage;
|
||||
private Component message;
|
||||
private final List<? extends Audience> recipients;
|
||||
private Component message;
|
||||
private Result result = Result.ALLOWED;
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
public final class CarbonEventHandler {
|
||||
|
||||
private final EventBus<CarbonEvent> eventBus = EventBus.create(CarbonEvent.class, (type, event, subscriber) -> {
|
||||
if (event instanceof ResultedCarbonEvent<?> rce) {
|
||||
if (event instanceof ResultedCarbonEvent<@NonNull ?> rce) {
|
||||
return !rce.result().cancelled();
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -33,7 +33,7 @@ public interface CarbonPlayer extends Audience, Identified {
|
||||
* @return the player's display name
|
||||
* @since 2.0.0
|
||||
*/
|
||||
Component displayName();
|
||||
@Nullable Component displayName();
|
||||
|
||||
/**
|
||||
* Sets the player's display name.<br>
|
||||
|
||||
@@ -23,8 +23,8 @@ public interface ChatComponentRenderer {
|
||||
* may be a player, console, or other Audience implementations
|
||||
* @param message the message being sent
|
||||
* @param originalMessage the original message that was sent
|
||||
* @return the component to be shown to the recipient,
|
||||
* or empty if the recipient should not receive the message
|
||||
* @return the component to be shown to the recipient,
|
||||
* or empty if the recipient should not receive the message
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@NonNull
|
||||
|
||||
@@ -18,6 +18,12 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class ColorUtils {
|
||||
|
||||
private static final Pattern spigotLegacyRGB =
|
||||
Pattern.compile("[§&]x[§&]([0-9a-fA-F])[§&]([0-9a-fA-F])[§&]([0-9a-fA-F])[§&]([0-9a-fA-F])[§&]([0-9a-fA-F])[§&]([0-9a-fA-F])");
|
||||
private static final Pattern pluginRGB =
|
||||
Pattern.compile("[§&]#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])");
|
||||
private static final String hexReplacement = "<#$1$2$3$4$5$6>";
|
||||
|
||||
private ColorUtils() {
|
||||
|
||||
}
|
||||
@@ -50,14 +56,6 @@ public final class ColorUtils {
|
||||
return TextColor.fromCSSHexString(input);
|
||||
}
|
||||
|
||||
private static final Pattern spigotLegacyRGB =
|
||||
Pattern.compile("[§&]x[§&]([0-9a-fA-F])[§&]([0-9a-fA-F])[§&]([0-9a-fA-F])[§&]([0-9a-fA-F])[§&]([0-9a-fA-F])[§&]([0-9a-fA-F])");
|
||||
|
||||
private static final Pattern pluginRGB =
|
||||
Pattern.compile("[§&]#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])");
|
||||
|
||||
private static final String hexReplacement = "<#$1$2$3$4$5$6>";
|
||||
|
||||
/**
|
||||
* Converts the input legacy, legacy rgb, and alternate color formats to MiniMessage color tags.
|
||||
*
|
||||
|
||||
@@ -6,9 +6,7 @@ import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.key.Keyed;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A chat renderer that's identifiable by key.
|
||||
@@ -21,7 +19,7 @@ public interface KeyedRenderer extends Keyed, ChatComponentRenderer {
|
||||
/**
|
||||
* Creates a new renderer with the corresponding key.
|
||||
*
|
||||
* @param key the renderer's key
|
||||
* @param key the renderer's key
|
||||
* @param renderer the chat renderer
|
||||
* @return the keyed renderer
|
||||
* @since 2.0.0
|
||||
@@ -35,15 +33,14 @@ public interface KeyedRenderer extends Keyed, ChatComponentRenderer {
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
record Impl(@NonNull Key key, ChatComponentRenderer renderer) implements KeyedRenderer {
|
||||
record Impl(Key key, ChatComponentRenderer renderer) implements KeyedRenderer {
|
||||
|
||||
@Override
|
||||
public @Nullable @NotNull
|
||||
Component render(
|
||||
final CarbonPlayer sender,
|
||||
final Audience recipient,
|
||||
final Component message,
|
||||
final Component originalMessage
|
||||
public Component render(
|
||||
final CarbonPlayer sender,
|
||||
final Audience recipient,
|
||||
final Component message,
|
||||
final Component originalMessage
|
||||
) {
|
||||
return this.renderer.render(sender, recipient, message, originalMessage);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user