mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Fix compilation and style issues
This commit is contained in:
1 parent
f6479214e8
commit
e9e91e1681
15 files changed
+23
-32
No files matched your search
@@ -51,6 +51,7 @@ dependencies {
|
||||
compile 'net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT'
|
||||
compile 'net.kyori:adventure-text-minimessage:4.0.0-SNAPSHOT'
|
||||
compile 'net.kyori:adventure-text-serializer-plain:4.0.0-SNAPSHOT'
|
||||
compile 'net.kyori:adventure-text-serializer-gson:4.0.0-SNAPSHOT'
|
||||
compile 'de.themoep:minedown-adventure:1.6.1-SNAPSHOT'
|
||||
|
||||
compile 'net.kyori:event-api:3.0.0'
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.craftbukkit.BukkitComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -320,7 +321,7 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
public void sendMessageToBungee(@NonNull final Player player, @NonNull final Component component) {
|
||||
this.carbonChat.messageManager().sendMessage("channel-component", player.getUniqueId(), byteArray -> {
|
||||
byteArray.writeUTF(this.key());
|
||||
byteArray.writeUTF(this.carbonChat.adventureManager().audiences().gsonSerializer().serialize(component));
|
||||
byteArray.writeUTF(BukkitComponentSerializer.gson().serialize(component));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class ChannelListCommand {
|
||||
}
|
||||
|
||||
public void executeOther(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final Audience cmdSender = this.carbonChat.adventureManager().audiences().audience(sender);
|
||||
final Audience cmdSender = this.carbonChat.adventureManager().audiences().sender(sender);
|
||||
final ChatUser user = (ChatUser) args[0];
|
||||
|
||||
if (!user.online()) {
|
||||
@@ -102,7 +102,7 @@ public class ChannelListCommand {
|
||||
Component availableComponent = this.carbonChat.adventureManager().processMessage(availableFormat, "br", "\n");
|
||||
availableComponent = availableComponent.replaceFirstText(Pattern.compile(Pattern.quote("<list>")), ac -> availableList);
|
||||
|
||||
final Audience audience = this.carbonChat.adventureManager().audiences().audience(sender);
|
||||
final Audience audience = this.carbonChat.adventureManager().audiences().sender(sender);
|
||||
|
||||
audience.sendMessage(availableComponent);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ChatReloadCommand {
|
||||
final Component message = this.carbonChat.adventureManager()
|
||||
.processMessage(this.carbonChat.language().getString("reloaded"), "br", "\n");
|
||||
|
||||
this.carbonChat.adventureManager().audiences().audience(sender).sendMessage(message);
|
||||
this.carbonChat.adventureManager().audiences().sender(sender).sendMessage(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class MuteCommand {
|
||||
|
||||
private void execute(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser user = (ChatUser) args[0];
|
||||
final Audience audience = this.carbonChat.adventureManager().audiences().audience(sender);
|
||||
final Audience audience = this.carbonChat.adventureManager().audiences().sender(sender);
|
||||
|
||||
if (user.shadowMuted()) {
|
||||
user.muted(false);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class NicknameCommand {
|
||||
}
|
||||
|
||||
private void executeOther(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final Audience user = this.carbonChat.adventureManager().audiences().audience(sender);
|
||||
final Audience user = this.carbonChat.adventureManager().audiences().sender(sender);
|
||||
final ChatUser target = (ChatUser) args[0];
|
||||
String nickname = (String) args[1];
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ShadowMuteCommand {
|
||||
|
||||
private void execute(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser user = (ChatUser) args[0];
|
||||
final Audience audience = this.carbonChat.adventureManager().audiences().audience(sender);
|
||||
final Audience audience = this.carbonChat.adventureManager().audiences().sender(sender);
|
||||
|
||||
if (user.shadowMuted()) {
|
||||
user.shadowMuted(false);
|
||||
|
||||
@@ -67,7 +67,7 @@ public class SudoChannelCommand {
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessage(message, "br", "\n",
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name()));
|
||||
|
||||
this.carbonChat.adventureManager().audiences().audience(sender).sendMessage(
|
||||
this.carbonChat.adventureManager().audiences().sender(sender).sendMessage(
|
||||
this.carbonChat.adventureManager().processMessage(otherMessage, "br", "\n",
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name(),
|
||||
"player", user.offlinePlayer().getName()));
|
||||
|
||||
@@ -96,7 +96,7 @@ public class ToggleCommand {
|
||||
user.sendMessage(this.carbonChat.adventureManager().processMessage(message, "br", "\n",
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name()));
|
||||
|
||||
this.carbonChat.adventureManager().audiences().audience(sender).sendMessage(
|
||||
this.carbonChat.adventureManager().audiences().sender(sender).sendMessage(
|
||||
this.carbonChat.adventureManager().processMessage(otherMessage,
|
||||
"br", "\n", "color", "<color:" + channel.channelColor(user).toString() + ">",
|
||||
"channel", channel.name(), "player", user.offlinePlayer().getName()));
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.draycia.carbon.events.CarbonEvent;
|
||||
import net.draycia.carbon.storage.ChatUser;
|
||||
import net.kyori.event.Cancellable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class PreChatFormatEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
|
||||
@@ -3,23 +3,10 @@ package net.draycia.carbon.listeners.events;
|
||||
import net.draycia.carbon.events.CarbonEvents;
|
||||
import net.draycia.carbon.events.api.PreChatFormatEvent;
|
||||
import net.draycia.carbon.util.CarbonUtils;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyFormat;
|
||||
import net.kyori.event.PostOrders;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class LegacyFormatHandler {
|
||||
|
||||
private final @NonNull Pattern pattern =
|
||||
Pattern.compile("[§&]x[§&]([0-9a-f])[§&]([0-9a-f])[§&]([0-9a-f])[§&]([0-9a-f])[§&]([0-9a-f])[§&]([0-9a-f])");
|
||||
|
||||
private final @NonNull Pattern altPattern =
|
||||
Pattern.compile("[§&]#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])");
|
||||
|
||||
public LegacyFormatHandler() {
|
||||
CarbonEvents.register(PreChatFormatEvent.class, PostOrders.FIRST, false, event -> {
|
||||
event.format(CarbonUtils.translateAlternateColors(event.format()));
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.craftbukkit.BukkitComponentSerializer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@@ -41,7 +42,7 @@ public class AdventureManager {
|
||||
return TextComponent.empty();
|
||||
}
|
||||
|
||||
String format = CarbonUtils.translateAlternateColors(input);
|
||||
final String format = CarbonUtils.translateAlternateColors(input);
|
||||
|
||||
switch (this.carbonChat.language().getString("formatting.type", "minimessage").toLowerCase()) {
|
||||
case "minedown":
|
||||
@@ -67,7 +68,7 @@ public class AdventureManager {
|
||||
input = input.replace("<" + placeholder + ">", replacement);
|
||||
}
|
||||
|
||||
return this.audiences().gsonSerializer().deserialize(input);
|
||||
return BukkitComponentSerializer.gson().deserialize(input);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.draycia.carbon.messaging.impl.RedisMessageService;
|
||||
import net.draycia.carbon.storage.ChatUser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.serializer.craftbukkit.BukkitComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@@ -28,7 +29,7 @@ public class MessageManager {
|
||||
|
||||
public MessageManager(@NonNull final CarbonChat carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.gsonSerializer = this.carbonChat.adventureManager().audiences().gsonSerializer();
|
||||
this.gsonSerializer = BukkitComponentSerializer.gson();
|
||||
|
||||
String messageSystem = this.carbonChat.getConfig().getString("message-system", "none");
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.craftbukkit.BukkitComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -376,7 +377,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
this.carbonChat.messageManager().sendMessage("whisper-component", sender.uuid(), byteArray -> {
|
||||
byteArray.writeLong(this.uuid().getMostSignificantBits());
|
||||
byteArray.writeLong(this.uuid().getLeastSignificantBits());
|
||||
byteArray.writeUTF(this.carbonChat.adventureManager().audiences().gsonSerializer().serialize(fromPlayerComponent));
|
||||
byteArray.writeUTF(BukkitComponentSerializer.gson().serialize(fromPlayerComponent));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeCordComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyFormat;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
@@ -61,7 +61,7 @@ public final class CarbonUtils {
|
||||
static {
|
||||
final List<String> colorList = new ArrayList<>();
|
||||
|
||||
for (final NamedTextColor color : NamedTextColor.values()) {
|
||||
for (final NamedTextColor color : NamedTextColor.NAMES.values()) {
|
||||
colorList.add(color.toString());
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public final class CarbonUtils {
|
||||
|
||||
component.color(ChatColor.WHITE).append("]");
|
||||
|
||||
return BungeeCordComponentSerializer.get().deserialize(component.create());
|
||||
return BungeeComponentSerializer.get().deserialize(component.create());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -117,7 +117,7 @@ public final class CarbonUtils {
|
||||
input = PlaceholderAPI.setPlaceholders(user.player(), input);
|
||||
}
|
||||
|
||||
for (final NamedTextColor namedColor : NamedTextColor.values()) {
|
||||
for (final NamedTextColor namedColor : NamedTextColor.NAMES.values()) {
|
||||
if (namedColor.toString().equalsIgnoreCase(input)) {
|
||||
return namedColor;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public final class CarbonUtils {
|
||||
Pattern.compile("[§&]#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])");
|
||||
|
||||
@NonNull
|
||||
public static String translateAlternateColors(@NonNull String input) {
|
||||
public static String translateAlternateColors(@NonNull final String input) {
|
||||
// TODO: check if MiniMessage or MineDown
|
||||
String output = input;
|
||||
|
||||
|
||||
Reference in new issue
Block a user