mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
Drop MineDown & Mojangson
This commit is contained in:
1 parent
dc09504bd3
commit
d7b3b01c2b
7 files changed
+20
-78
No files matched your search
@@ -1,8 +0,0 @@
|
|||||||
package net.draycia.carbon.api.adventure;
|
|
||||||
|
|
||||||
public enum FormatType {
|
|
||||||
MOJANG,
|
|
||||||
MINIMESSAGE_MARKDOWN,
|
|
||||||
MINIMESSAGE,
|
|
||||||
MINEDOWN
|
|
||||||
}
|
|
||||||
@@ -11,6 +11,4 @@ public interface MessageProcessor {
|
|||||||
|
|
||||||
@NonNull AudienceProvider audiences();
|
@NonNull AudienceProvider audiences();
|
||||||
|
|
||||||
@NonNull FormatType formatType();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package net.draycia.carbon.api.config;
|
package net.draycia.carbon.api.config;
|
||||||
|
|
||||||
import net.draycia.carbon.api.adventure.FormatType;
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||||
@@ -64,10 +63,6 @@ public final class CarbonSettings {
|
|||||||
" channel as well as this setting.")
|
" channel as well as this setting.")
|
||||||
private @NonNull MessagingType messagingType = MessagingType.NONE;
|
private @NonNull MessagingType messagingType = MessagingType.NONE;
|
||||||
|
|
||||||
@Setting
|
|
||||||
@Comment("Options: MOJANG, MINIMESSAGE_MARKDOWN, MINIMESSAGE, MINEDOWN")
|
|
||||||
private @NonNull FormatType formatType = FormatType.MINIMESSAGE;
|
|
||||||
|
|
||||||
@Setting
|
@Setting
|
||||||
@Comment("The credentials necessary to connect to your redis server")
|
@Comment("The credentials necessary to connect to your redis server")
|
||||||
private @NonNull RedisCredentials redisCredentials = new RedisCredentials();
|
private @NonNull RedisCredentials redisCredentials = new RedisCredentials();
|
||||||
@@ -136,8 +131,4 @@ public final class CarbonSettings {
|
|||||||
public @NonNull WhisperOptions whisperOptions() {
|
public @NonNull WhisperOptions whisperOptions() {
|
||||||
return this.whisperOptions;
|
return this.whisperOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NonNull FormatType formatType() {
|
|
||||||
return this.formatType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
|||||||
|
|
||||||
// Setup Adventure
|
// Setup Adventure
|
||||||
final BukkitAudiences audiences = BukkitAudiences.create(this);
|
final BukkitAudiences audiences = BukkitAudiences.create(this);
|
||||||
this.messageProcessor = new AdventureManager(audiences, this.carbonSettings.formatType());
|
this.messageProcessor = new AdventureManager(audiences);
|
||||||
|
|
||||||
// Initialize managers
|
// Initialize managers
|
||||||
this.channelManager = new ChannelManager(this);
|
this.channelManager = new ChannelManager(this);
|
||||||
|
|||||||
+2
-22
@@ -1,9 +1,7 @@
|
|||||||
package net.draycia.carbon.common.adventure;
|
package net.draycia.carbon.common.adventure;
|
||||||
|
|
||||||
import de.themoep.minedown.adventure.MineDown;
|
|
||||||
import net.draycia.carbon.api.CarbonChat;
|
import net.draycia.carbon.api.CarbonChat;
|
||||||
import net.draycia.carbon.api.CarbonChatProvider;
|
import net.draycia.carbon.api.CarbonChatProvider;
|
||||||
import net.draycia.carbon.api.adventure.FormatType;
|
|
||||||
import net.draycia.carbon.api.adventure.MessageProcessor;
|
import net.draycia.carbon.api.adventure.MessageProcessor;
|
||||||
import net.draycia.carbon.common.utils.ColorUtils;
|
import net.draycia.carbon.common.utils.ColorUtils;
|
||||||
import net.kyori.adventure.platform.AudienceProvider;
|
import net.kyori.adventure.platform.AudienceProvider;
|
||||||
@@ -18,11 +16,8 @@ public class AdventureManager implements MessageProcessor {
|
|||||||
|
|
||||||
private final @NonNull CarbonChat carbonChat;
|
private final @NonNull CarbonChat carbonChat;
|
||||||
|
|
||||||
private final @NonNull FormatType formatType;
|
public AdventureManager(final @NonNull AudienceProvider provider) {
|
||||||
|
|
||||||
public AdventureManager(final @NonNull AudienceProvider provider, final @NonNull FormatType formatType) {
|
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
this.formatType = formatType;
|
|
||||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,17 +34,7 @@ public class AdventureManager implements MessageProcessor {
|
|||||||
|
|
||||||
format = this.processPlaceholders(format, placeholders);
|
format = this.processPlaceholders(format, placeholders);
|
||||||
|
|
||||||
switch (this.formatType) {
|
return MiniMessage.get().parse(format);
|
||||||
case MINEDOWN:
|
|
||||||
return MineDown.parse(format);
|
|
||||||
case MOJANG:
|
|
||||||
return this.processMojang(format);
|
|
||||||
case MINIMESSAGE_MARKDOWN:
|
|
||||||
return MiniMessage.markdown().parse(format);
|
|
||||||
case MINIMESSAGE:
|
|
||||||
default:
|
|
||||||
return MiniMessage.get().parse(format);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NonNull Component processMojang(final @NonNull String input) {
|
private @NonNull Component processMojang(final @NonNull String input) {
|
||||||
@@ -67,11 +52,6 @@ public class AdventureManager implements MessageProcessor {
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NonNull FormatType formatType() {
|
|
||||||
return this.formatType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull AudienceProvider audiences() {
|
public @NonNull AudienceProvider audiences() {
|
||||||
return this.provider;
|
return this.provider;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
package net.draycia.carbon.common.utils;
|
package net.draycia.carbon.common.utils;
|
||||||
|
|
||||||
import net.draycia.carbon.api.CarbonChatProvider;
|
|
||||||
import net.draycia.carbon.api.adventure.MessageProcessor;
|
|
||||||
import net.draycia.carbon.api.users.CarbonUser;
|
import net.draycia.carbon.api.users.CarbonUser;
|
||||||
import net.draycia.carbon.api.users.PlayerUser;
|
import net.draycia.carbon.api.users.PlayerUser;
|
||||||
import net.draycia.carbon.common.adventure.AdventureManager;
|
|
||||||
import net.draycia.carbon.api.adventure.FormatType;
|
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import net.kyori.adventure.text.format.TextDecoration;
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
@@ -56,51 +52,39 @@ public final class ColorUtils {
|
|||||||
private static final @NonNull Pattern pluginRGB =
|
private static final @NonNull 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])");
|
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 @NonNull String hexReplacement = "<#$1$2$3$4$5$6>";
|
||||||
|
|
||||||
public static @NonNull String translateAlternateColors(final @NonNull String input) {
|
public static @NonNull String translateAlternateColors(final @NonNull String input) {
|
||||||
String output = input;
|
String output = input;
|
||||||
|
|
||||||
String hexReplacement = "<#$1$2$3$4$5$6>";
|
|
||||||
boolean legacyCapable = false;
|
|
||||||
|
|
||||||
final MessageProcessor messageProcessor = CarbonChatProvider.carbonChat().messageProcessor();
|
|
||||||
|
|
||||||
if (messageProcessor instanceof AdventureManager) {
|
|
||||||
if (messageProcessor.formatType() == FormatType.MINEDOWN) {
|
|
||||||
hexReplacement = "&#$1$2$3$4$5$6&";
|
|
||||||
legacyCapable = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Legacy RGB
|
// Legacy RGB
|
||||||
output = spigotLegacyRGB.matcher(output).replaceAll(hexReplacement);
|
output = spigotLegacyRGB.matcher(output).replaceAll(hexReplacement);
|
||||||
|
|
||||||
// Alternate RGB, TAB (neznamy) && KiteBoard
|
// Alternate RGB, TAB (neznamy) && KiteBoard
|
||||||
output = pluginRGB.matcher(output).replaceAll(hexReplacement);
|
output = pluginRGB.matcher(output).replaceAll(hexReplacement);
|
||||||
|
|
||||||
if (!legacyCapable) {
|
// Legacy Colors
|
||||||
// Legacy Colors
|
for (final char c : "0123456789abcdefABCDEF".toCharArray()) {
|
||||||
for (final char c : "0123456789abcdefABCDEF".toCharArray()) {
|
final LegacyFormat format = LegacyComponentSerializer.parseChar(Character.toLowerCase(c));
|
||||||
final LegacyFormat format = LegacyComponentSerializer.parseChar(Character.toLowerCase(c));
|
|
||||||
|
|
||||||
if (format != null) {
|
if (format != null) {
|
||||||
final TextColor color = format.color();
|
final TextColor color = format.color();
|
||||||
|
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
output = output.replaceAll("[§&]" + c, "<" + color.asHexString() + ">");
|
output = output.replaceAll("[§&]" + c, "<" + color.asHexString() + ">");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Legacy Formatting
|
// Legacy Formatting
|
||||||
for (final char c : "klmnoKLMNO".toCharArray()) {
|
for (final char c : "klmnoKLMNO".toCharArray()) {
|
||||||
final LegacyFormat format = LegacyComponentSerializer.parseChar(Character.toLowerCase(c));
|
final LegacyFormat format = LegacyComponentSerializer.parseChar(Character.toLowerCase(c));
|
||||||
|
|
||||||
if (format != null) {
|
if (format != null) {
|
||||||
final TextDecoration decoration = format.decoration();
|
final TextDecoration decoration = format.decoration();
|
||||||
|
|
||||||
if (decoration != null) {
|
if (decoration != null) {
|
||||||
output = output.replaceAll("[§&]" + c, "<" + decoration.name() + ">");
|
output = output.replaceAll("[§&]" + c, "<" + decoration.name() + ">");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,6 @@ channel-pings:
|
|||||||
pitch: 1
|
pitch: 1
|
||||||
source: PLAYER
|
source: PLAYER
|
||||||
volume: 10
|
volume: 10
|
||||||
|
|
||||||
# Options: MOJANG, MINIMESSAGE_MARKDOWN, MINIMESSAGE, MINEDOWN
|
|
||||||
format-type: MINIMESSAGE
|
|
||||||
|
|
||||||
# The list of regex patterns to show items in chat. '\\Q' and '\\E' just denote that the content isn't regex.
|
# The list of regex patterns to show items in chat. '\\Q' and '\\E' just denote that the content isn't regex.
|
||||||
item-link-patterns:
|
item-link-patterns:
|
||||||
|
|||||||
Reference in new issue
Block a user