HEX: Nearest Color For Old Versions

This commit is contained in:
LinsaFTW 2023-01-15 12:17:48 -03:00
parent 6cc983ea54
commit 2737ae35ab
4 changed files with 507 additions and 85 deletions

View File

@ -1,39 +1,9 @@
From 08d4b15bc1b46c26b895563b19d9e2b3991bff5e Mon Sep 17 00:00:00 2001
From 2deed84f7aa7722cb648f94f46df605ce33ee912 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Thu, 7 Oct 2021 21:37:24 -0300
Subject: [PATCH] Custom motd system
diff --git a/flamecord/pom.xml b/flamecord/pom.xml
index 20edd9001..d1e8291e2 100644
--- a/flamecord/pom.xml
+++ b/flamecord/pom.xml
@@ -17,6 +17,13 @@
<name>Waterfall-FlameCord</name>
<description>FlameCord adds security essentials and new configuration options</description>
+ <repositories>
+ <repository>
+ <id>iridiumdevelopment</id>
+ <url>https://nexus.iridiumdevelopment.net/repository/maven-releases/</url>
+ </repository>
+ </repositories>
+
<dependencies>
<dependency>
<groupId>io.github.waterfallmc</groupId>
@@ -30,6 +37,11 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>com.iridium</groupId>
+ <artifactId>IridiumColorAPI</artifactId>
+ <version>LATEST</version>
+ </dependency>
</dependencies>
<build>
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
index 5589ce1b7..1e928197c 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
@ -50,10 +20,10 @@ index 5589ce1b7..1e928197c 100644
return (boolean) setIfUnexistant(arg1, (Object) arg2, configuration);
}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
index aac41c8b2..3c2129d28 100644
index aac41c8b2..a80a9eae3 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -3,15 +3,90 @@ package dev._2lstudios.flamecord.configuration;
@@ -3,15 +3,76 @@ package dev._2lstudios.flamecord.configuration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@ -63,41 +33,27 @@ index aac41c8b2..3c2129d28 100644
import java.util.HashSet;
+import java.util.List;
+import java.util.Random;
+
+import com.iridium.iridiumcolorapi.IridiumColorAPI;
+import dev._2lstudios.flamecord.utils.ColorUtil;
import lombok.Getter;
+import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration extends FlameConfig {
+ private List<String> color(final List<String> strings) {
+ for (int i = 0; i < strings.size(); i++) {
+ String text = strings.get(i);
+ public String getMOTD(int maxPlayers, int onlinePlayers, int protocol) {
+ String motd = motds.get(new Random().nextInt(motds.size()));
+
+ if (text != null) {
+ String coloredText = ChatColor.translateAlternateColorCodes('&', text);
+ motd = motd.replace("%maxplayers%", String.valueOf(maxPlayers)).replace("%onlineplayers%", String.valueOf(onlinePlayers));
+
+ if (coloredText != null) {
+ strings.set(i, IridiumColorAPI.process(coloredText));
+ }
+ }
+ }
+
+ return strings;
+ return ColorUtil.hex(motd, protocol);
+ }
+
+ public String getMOTD(final int maxPlayers, final int onlinePlayers) {
+ final String motd = motds.get(new Random().nextInt(motds.size()));
+ public String[] getSample(int maxPlayers, int onlinePlayers, int protocol) {
+ String sample = samples.get(new Random().nextInt(samples.size()));
+
+ return motd.replace("%maxplayers%", String.valueOf(maxPlayers)).replace("%onlineplayers%", String.valueOf(onlinePlayers));
+ }
+ sample = sample.replace("%maxplayers%", String.valueOf(maxPlayers)).replace("%onlineplayers%", String.valueOf(onlinePlayers));
+
+ public String[] getSample(final int maxPlayers, final int onlinePlayers) {
+ final String sample = samples.get(new Random().nextInt(samples.size()));
+
+ return sample.replace("%maxplayers%", String.valueOf(maxPlayers)).replace("%onlineplayers%", String.valueOf(onlinePlayers)).split("\n");
+ return ColorUtil.hex(sample, protocol).split("\n");
+ }
+
+ public int getFakePlayersAmount(final int players) {
@ -116,12 +72,12 @@ index aac41c8b2..3c2129d28 100644
+ @Getter
+ private boolean motdEnabled = false;
+ @Getter
+ private List<String> motds = Collections.singletonList("&eDefault &cFlameCord&e server\n&eEdit this on &cflamecord.yml&e file &7(IridiumColorAPI HEX Support)");
+ private List<String> motds = Collections.singletonList("&eDefault &cFlameCord&e server &7(%onlineplayers%/%maxplayers%)\n&eEdit on &cflamecord.yml&7 (IridiumColorAPI HEX)");
+
+ @Getter
+ private boolean sampleEnabled = false;
+ @Getter
+ private List<String> samples = Collections.singletonList("&eDefault &cFlameCord&e server\n&eEdit this on &cflamecord.yml&e file &7(IridiumColorAPI HEX Support)");
+ private List<String> samples = Collections.singletonList("&eDefault &cFlameCord&e server &7(%onlineplayers%/%maxplayers%)\n&eEdit on &cflamecord.yml&7 (IridiumColorAPI HEX)");
+
+ @Getter
+ private boolean protocolEnabled = false;
@ -144,14 +100,14 @@ index aac41c8b2..3c2129d28 100644
@Getter
private boolean loggerInitialhandler = false;
@Getter
@@ -36,6 +111,19 @@ public class FlameCordConfiguration extends FlameConfig {
@@ -36,6 +97,19 @@ public class FlameCordConfiguration extends FlameConfig {
configuration = configurationProvider.load(configurationFile);
}
+ this.motdEnabled = setIfUnexistant("custom-motd.motd.enabled", this.motdEnabled, configuration);
+ this.motds = color(new ArrayList<>(setIfUnexistant("custom-motd.motd.motds", this.motds, configuration)));
+ this.motds = ColorUtil.color(new ArrayList<>(setIfUnexistant("custom-motd.motd.motds", this.motds, configuration)));
+ this.sampleEnabled = setIfUnexistant("custom-motd.sample.enabled", this.sampleEnabled, configuration);
+ this.samples = color(new ArrayList<>(setIfUnexistant("custom-motd.sample.samples", this.samples, configuration)));
+ this.samples = ColorUtil.color(new ArrayList<>(setIfUnexistant("custom-motd.sample.samples", this.samples, configuration)));
+ this.protocolEnabled = setIfUnexistant("custom-motd.protocol.enabled", this.protocolEnabled, configuration);
+ this.protocolName = setIfUnexistant("custom-motd.protocol.name", this.protocolName, configuration);
+ this.maxPlayersEnabled = setIfUnexistant("custom-motd.maxplayers.enabled", this.maxPlayersEnabled, configuration);
@ -164,8 +120,474 @@ index aac41c8b2..3c2129d28 100644
this.loggerInitialhandler = setIfUnexistant("logger.initialhandler", this.loggerInitialhandler, configuration);
this.loggerExceptions = setIfUnexistant("logger.exceptions", this.loggerExceptions, configuration);
this.loggerDump = setIfUnexistant("logger.dump", this.loggerDump, configuration);
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/ColorUtil.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/ColorUtil.java
new file mode 100644
index 000000000..9587bccda
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/ColorUtil.java
@@ -0,0 +1,48 @@
+package dev._2lstudios.flamecord.utils;
+
+import java.util.List;
+
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.IridiumColorAPI;
+import net.md_5.bungee.api.ChatColor;
+
+public class ColorUtil {
+ public static String color(String text) {
+ return ChatColor.translateAlternateColorCodes('&', text);
+ }
+
+ public static List<String> color(final List<String> texts) {
+ for (int i = 0; i < texts.size(); i++) {
+ texts.set(i, color(texts.get(i)));
+ }
+
+ return texts;
+ }
+
+ public static String hex(String text, int protocol) {
+ if (text == null) {
+ return text;
+ }
+
+ return IridiumColorAPI.process(text, protocol);
+ }
+
+ public static String hexColor(String text, int protocol) {
+ if (text != null) {
+ text = color(text);
+
+ if (text != null) {
+ text = hex(text, protocol);
+ }
+ }
+
+ return text;
+ }
+
+ public static List<String> hexColor(final List<String> texts, int protocol) {
+ for (int i = 0; i < texts.size(); i++) {
+ texts.set(i, hexColor(texts.get(i), protocol));
+ }
+
+ return texts;
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/IridiumColorAPI.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/IridiumColorAPI.java
new file mode 100644
index 000000000..6c386e16f
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/IridiumColorAPI.java
@@ -0,0 +1,275 @@
+package dev._2lstudios.flamecord.utils.iridiumcolorapi;
+
+import java.awt.Color;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import javax.annotation.Nonnull;
+
+import com.google.common.collect.ImmutableMap;
+
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns.GradientPattern;
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns.Pattern;
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns.RainbowPattern;
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns.SolidPattern;
+import net.md_5.bungee.api.ChatColor;
+
+public class IridiumColorAPI {
+
+ /**
+ * Cached result if the server version is after the v1.16 RGB update.
+ *
+ * @since 1.0.0
+ */
+ private static final boolean SUPPORTS_RGB(int protocol) {
+ return protocol >= 735;
+ }
+
+ private static final List<String> SPECIAL_COLORS = Arrays.asList("&l", "&n", "&o", "&k", "&m", "§l", "§n", "§o", "§k", "§m");
+
+ /**
+ * Cached result of all legacy colors.
+ *
+ * @since 1.0.0
+ */
+ private static final Map<Color, ChatColor> COLORS = ImmutableMap.<Color, ChatColor>builder()
+ .put(new Color(0), ChatColor.getByChar('0'))
+ .put(new Color(170), ChatColor.getByChar('1'))
+ .put(new Color(43520), ChatColor.getByChar('2'))
+ .put(new Color(43690), ChatColor.getByChar('3'))
+ .put(new Color(11141120), ChatColor.getByChar('4'))
+ .put(new Color(11141290), ChatColor.getByChar('5'))
+ .put(new Color(16755200), ChatColor.getByChar('6'))
+ .put(new Color(11184810), ChatColor.getByChar('7'))
+ .put(new Color(5592405), ChatColor.getByChar('8'))
+ .put(new Color(5592575), ChatColor.getByChar('9'))
+ .put(new Color(5635925), ChatColor.getByChar('a'))
+ .put(new Color(5636095), ChatColor.getByChar('b'))
+ .put(new Color(16733525), ChatColor.getByChar('c'))
+ .put(new Color(16733695), ChatColor.getByChar('d'))
+ .put(new Color(16777045), ChatColor.getByChar('e'))
+ .put(new Color(16777215), ChatColor.getByChar('f')).build();
+
+ /**
+ * Cached result of patterns.
+ *
+ * @since 1.0.2
+ */
+ private static final List<Pattern> PATTERNS = Arrays.asList(new GradientPattern(), new SolidPattern(), new RainbowPattern());
+
+ /**
+ * Processes a string to add color to it.
+ * Thanks to Distressing for helping with the regex <3
+ *
+ * @param string The string we want to process
+ * @since 1.0.0
+ */
+ @Nonnull
+ public static String process(@Nonnull String string, int protocol) {
+ for (Pattern pattern : PATTERNS) {
+ string = pattern.process(string, protocol);
+ }
+
+ string = ChatColor.translateAlternateColorCodes('&', string);
+ return string;
+ }
+
+ /**
+ * Processes multiple strings in a collection.
+ *
+ * @param strings The collection of the strings we are processing
+ * @return The list of processed strings
+ * @since 1.0.3
+ */
+ @Nonnull
+ public static List<String> process(@Nonnull Collection<String> strings, int protocol) {
+ return strings.stream()
+ .map(s -> IridiumColorAPI.process(s, protocol))
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Colors a String.
+ *
+ * @param string The string we want to color
+ * @param color The color we want to set it to
+ * @since 1.0.0
+ */
+ @Nonnull
+ public static String color(@Nonnull String string, @Nonnull Color color, int protocol) {
+ return (SUPPORTS_RGB(protocol) ? ChatColor.of(color) : getClosestColor(color)) + string;
+ }
+
+ /**
+ * Colors a String with a gradiant.
+ *
+ * @param string The string we want to color
+ * @param start The starting gradiant
+ * @param end The ending gradiant
+ * @since 1.0.0
+ */
+ @Nonnull
+ public static String color(@Nonnull String string, @Nonnull Color start, @Nonnull Color end, int protocol) {
+ String originalString = string;
+
+ ChatColor[] colors = createGradient(start, end, withoutSpecialChar(string).length(), protocol);
+ return apply(originalString, colors);
+ }
+
+ /**
+ * Colors a String with rainbow colors.
+ *
+ * @param string The string which should have rainbow colors
+ * @param saturation The saturation of the rainbow colors
+ * @since 1.0.3
+ */
+ @Nonnull
+ public static String rainbow(@Nonnull String string, float saturation, int protocol) {
+ String originalString = string;
+
+ ChatColor[] colors = createRainbow(withoutSpecialChar(string).length(), saturation, protocol);
+ return apply(originalString, colors);
+ }
+
+ /**
+ * Gets a color from hex code.
+ *
+ * @param string The hex code of the color
+ * @since 1.0.0
+ */
+ @Nonnull
+ public static ChatColor getColor(@Nonnull String string, int protocol) {
+ return SUPPORTS_RGB(protocol) ? ChatColor.of(new Color(Integer.parseInt(string, 16)))
+ : getClosestColor(new Color(Integer.parseInt(string, 16)));
+ }
+
+ /**
+ * Removes all color codes from the provided String, including IridiumColorAPI
+ * patterns.
+ *
+ * @param string The String which should be stripped
+ * @return The stripped string without color codes
+ * @since 1.0.5
+ */
+ @Nonnull
+ public static String stripColorFormatting(@Nonnull String string) {
+ return string.replaceAll("<#[0-9A-F]{6}>|[&§][a-f0-9lnokm]|<[/]?[A-Z]{5,8}(:[0-9A-F]{6})?[0-9]*>", "");
+ }
+
+ @Nonnull
+ private static String apply(@Nonnull String source, ChatColor[] colors) {
+ StringBuilder specialColors = new StringBuilder();
+ StringBuilder stringBuilder = new StringBuilder();
+ String[] characters = source.split("");
+ int outIndex = 0;
+ for (int i = 0; i < characters.length; i++) {
+ if (characters[i].equals("&") || characters[i].equals("§")) {
+ if (i + 1 < characters.length) {
+ if (characters[i + 1].equals("r")) {
+ specialColors.setLength(0);
+ } else {
+ specialColors.append(characters[i]);
+ specialColors.append(characters[i + 1]);
+ }
+ i++;
+ } else
+ stringBuilder.append(colors[outIndex++]).append(specialColors).append(characters[i]);
+ } else
+ stringBuilder.append(colors[outIndex++]).append(specialColors).append(characters[i]);
+ }
+ return stringBuilder.toString();
+ }
+
+ @Nonnull
+ private static String withoutSpecialChar(@Nonnull String source) {
+ String workingString = source;
+ for (String color : SPECIAL_COLORS) {
+ if (workingString.contains(color)) {
+ workingString = workingString.replace(color, "");
+ }
+ }
+ return workingString;
+ }
+
+ /**
+ * Returns a rainbow array of chat colors.
+ *
+ * @param step How many colors we return
+ * @param saturation The saturation of the rainbow
+ * @return The array of colors
+ * @since 1.0.3
+ */
+ @Nonnull
+ private static ChatColor[] createRainbow(int step, float saturation, int protocol) {
+ ChatColor[] colors = new ChatColor[step];
+ double colorStep = (1.00 / step);
+
+ for (int i = 0; i < step; i++) {
+ Color color = Color.getHSBColor((float) (colorStep * i), saturation, saturation);
+ if (SUPPORTS_RGB(protocol)) {
+ colors[i] = ChatColor.of(color);
+ } else {
+ colors[i] = getClosestColor(color);
+ }
+ }
+
+ return colors;
+ }
+
+ /**
+ * Returns a gradient array of chat colors.
+ *
+ * @param start The starting color.
+ * @param end The ending color.
+ * @param step How many colors we return.
+ * @author TheViperShow
+ * @since 1.0.0
+ */
+ @Nonnull
+ private static ChatColor[] createGradient(@Nonnull Color start, @Nonnull Color end, int step, int protocol) {
+ ChatColor[] colors = new ChatColor[step];
+ int stepR = Math.abs(start.getRed() - end.getRed()) / (step - 1);
+ int stepG = Math.abs(start.getGreen() - end.getGreen()) / (step - 1);
+ int stepB = Math.abs(start.getBlue() - end.getBlue()) / (step - 1);
+ int[] direction = new int[] {
+ start.getRed() < end.getRed() ? +1 : -1,
+ start.getGreen() < end.getGreen() ? +1 : -1,
+ start.getBlue() < end.getBlue() ? +1 : -1
+ };
+
+ for (int i = 0; i < step; i++) {
+ Color color = new Color(start.getRed() + ((stepR * i) * direction[0]), start.getGreen() + ((stepG * i) * direction[1]), start.getBlue() + ((stepB * i) * direction[2]));
+ if (SUPPORTS_RGB(protocol)) {
+ colors[i] = ChatColor.of(color);
+ } else {
+ colors[i] = getClosestColor(color);
+ }
+ }
+
+ return colors;
+ }
+
+ /**
+ * Returns the closest legacy color from an rgb color
+ *
+ * @param color The color we want to transform
+ * @since 1.0.0
+ */
+ @Nonnull
+ private static ChatColor getClosestColor(Color color) {
+ Color nearestColor = null;
+ double nearestDistance = Integer.MAX_VALUE;
+
+ for (Color constantColor : COLORS.keySet()) {
+ double distance = Math.pow(color.getRed() - constantColor.getRed(), 2) + Math.pow(color.getGreen() - constantColor.getGreen(), 2) + Math.pow(color.getBlue() - constantColor.getBlue(), 2);
+ if (nearestDistance > distance) {
+ nearestColor = constantColor;
+ nearestDistance = distance;
+ }
+ }
+ return COLORS.get(nearestColor);
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/GradientPattern.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/GradientPattern.java
new file mode 100644
index 000000000..c1f05cd0a
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/GradientPattern.java
@@ -0,0 +1,33 @@
+package dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns;
+
+import java.awt.*;
+import java.util.regex.Matcher;
+
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.IridiumColorAPI;
+
+/**
+ * Represents a gradient color pattern which can be applied to a String.
+ */
+public class GradientPattern implements Pattern {
+
+ java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("<GRADIENT:([0-9A-Fa-f]{6})>(.*?)</GRADIENT:([0-9A-Fa-f]{6})>");
+
+ /**
+ * Applies a gradient pattern to the provided String.
+ * Output might me the same as the input if this pattern is not present.
+ *
+ * @param string The String to which this pattern should be applied to
+ * @return The new String with applied pattern
+ */
+ public String process(String string, int protocol) {
+ Matcher matcher = pattern.matcher(string);
+ while (matcher.find()) {
+ String start = matcher.group(1);
+ String end = matcher.group(3);
+ String content = matcher.group(2);
+ string = string.replace(matcher.group(), IridiumColorAPI.color(content, new Color(Integer.parseInt(start, 16)), new Color(Integer.parseInt(end, 16)), protocol));
+ }
+ return string;
+ }
+
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/Pattern.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/Pattern.java
new file mode 100644
index 000000000..5457ead64
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/Pattern.java
@@ -0,0 +1,17 @@
+package dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns;
+
+/**
+ * Represents a color pattern which can be applied to a String.
+ */
+public interface Pattern {
+
+ /**
+ * Applies this pattern to the provided String.
+ * Output might me the same as the input if this pattern is not present.
+ *
+ * @param string The String to which this pattern should be applied to
+ * @return The new String with applied pattern
+ */
+ String process(String string, int protocol);
+
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/RainbowPattern.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/RainbowPattern.java
new file mode 100644
index 000000000..792e9f987
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/RainbowPattern.java
@@ -0,0 +1,28 @@
+package dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns;
+
+import java.util.regex.Matcher;
+
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.IridiumColorAPI;
+
+public class RainbowPattern implements Pattern {
+
+ java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("<RAINBOW([0-9]{1,3})>(.*?)</RAINBOW>");
+
+ /**
+ * Applies a rainbow pattern to the provided String.
+ * Output might me the same as the input if this pattern is not present.
+ *
+ * @param string The String to which this pattern should be applied to
+ * @return The new String with applied pattern
+ */
+ public String process(String string, int protocol) {
+ Matcher matcher = pattern.matcher(string);
+ while (matcher.find()) {
+ String saturation = matcher.group(1);
+ String content = matcher.group(2);
+ string = string.replace(matcher.group(), IridiumColorAPI.rainbow(content, Float.parseFloat(saturation), protocol));
+ }
+ return string;
+ }
+
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/SolidPattern.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/SolidPattern.java
new file mode 100644
index 000000000..0b039c797
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/utils/iridiumcolorapi/patterns/SolidPattern.java
@@ -0,0 +1,29 @@
+package dev._2lstudios.flamecord.utils.iridiumcolorapi.patterns;
+
+import java.util.regex.Matcher;
+
+import dev._2lstudios.flamecord.utils.iridiumcolorapi.IridiumColorAPI;
+
+public class SolidPattern implements Pattern {
+
+ java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("<SOLID:([0-9A-Fa-f]{6})>|#\\{([0-9A-Fa-f]{6})}");
+
+ /**
+ * Applies a solid RGB color to the provided String.
+ * Output might me the same as the input if this pattern is not present.
+ *
+ * @param string The String to which this pattern should be applied to
+ * @return The new String with applied pattern
+ */
+ public String process(String string, int protocol) {
+ Matcher matcher = pattern.matcher(string);
+ while (matcher.find()) {
+ String color = matcher.group(1);
+ if (color == null) color = matcher.group(2);
+
+ string = string.replace(matcher.group(), IridiumColorAPI.getColor(color, protocol) + "");
+ }
+ return string;
+ }
+
+}
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
index 8fb36e37d..b340c7a55 100644
index 8fb36e37d..bfefdf822 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
@@ -23,6 +23,8 @@ import javax.crypto.spec.SecretKeySpec;
@ -210,7 +632,7 @@ index 8fb36e37d..b340c7a55 100644
+ }
+
+ if (config.isMotdEnabled()) {
+ motd = config.getMOTD(maxPlayers, onlinePlayers);
+ motd = config.getMOTD(maxPlayers, onlinePlayers, protocol);
+ } else {
+ motd = ( forced != null ) ? forced.getMotd() : listener.getMotd();
+ }
@ -223,7 +645,7 @@ index 8fb36e37d..b340c7a55 100644
+
+ if (config.isSampleEnabled()) {
+ final UUID fakeUuid = new UUID(0, 0);
+ final String[] sampleString = config.getSample(maxPlayers, onlinePlayers);
+ final String[] sampleString = config.getSample(maxPlayers, onlinePlayers, protocol);
+
+ sample = new ServerPing.PlayerInfo[sampleString.length];
+

View File

@ -1,14 +1,14 @@
From dde3fd93db29113d7f296b0c05df86080336b3b1 Mon Sep 17 00:00:00 2001
From 5cb2916ba8f22c74e10427554ce253e89d2a0291 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Thu, 24 Feb 2022 23:41:57 -0300
Subject: [PATCH] TCP Fast Open
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
index d902feeba..1fd11f501 100644
index a80a9eae3..aa1c8eb24 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -18,6 +18,10 @@ import net.md_5.bungee.config.Configuration;
@@ -16,6 +16,10 @@ import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration extends FlameConfig {
@ -16,10 +16,10 @@ index d902feeba..1fd11f501 100644
+ @Getter
+ private int tcpFastOpen = 3;
+
private List<String> color(final List<String> strings) {
for (int i = 0; i < strings.size(); i++) {
String text = strings.get(i);
@@ -123,6 +127,7 @@ public class FlameCordConfiguration extends FlameConfig {
public String getMOTD(int maxPlayers, int onlinePlayers, int protocol) {
String motd = motds.get(new Random().nextInt(motds.size()));
@@ -109,6 +113,7 @@ public class FlameCordConfiguration extends FlameConfig {
this.fakePlayersEnabled = setIfUnexistant("custom-motd.fakeplayers.enabled", this.fakePlayersEnabled, configuration);
this.fakePlayersAmount = setIfUnexistant("custom-motd.fakeplayers.amount", this.fakePlayersAmount, configuration);
this.fakePlayersMode = setIfUnexistant("custom-motd.fakeplayers.mode", this.fakePlayersMode, configuration);

View File

@ -1,16 +1,16 @@
From 5f58554e02332e3985f19083f90c7e548a27d90f Mon Sep 17 00:00:00 2001
From 4cd6feb0cf58cb1028f8cac63cf4524b2a03e6c5 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 4 Mar 2022 13:35:53 -0300
Subject: [PATCH] Antibot System
diff --git a/flamecord/pom.xml b/flamecord/pom.xml
index d1e8291e2..0085c7398 100644
index 20edd9001..f48f1e60b 100644
--- a/flamecord/pom.xml
+++ b/flamecord/pom.xml
@@ -42,6 +42,17 @@
<artifactId>IridiumColorAPI</artifactId>
<version>LATEST</version>
@@ -30,6 +30,17 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>com.maxmind.db</groupId>
@ -1101,10 +1101,10 @@ index 000000000..44d773abe
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
index 1fd11f501..8cfb197e8 100644
index aa1c8eb24..aa26af32d 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -18,6 +18,166 @@ import net.md_5.bungee.config.Configuration;
@@ -16,6 +16,166 @@ import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration extends FlameConfig {
@ -1271,7 +1271,7 @@ index 1fd11f501..8cfb197e8 100644
// FlameCord - TCP Fast Open
@Getter
private int tcpFastOpen = 3;
@@ -127,6 +287,8 @@ public class FlameCordConfiguration extends FlameConfig {
@@ -113,6 +273,8 @@ public class FlameCordConfiguration extends FlameConfig {
this.fakePlayersEnabled = setIfUnexistant("custom-motd.fakeplayers.enabled", this.fakePlayersEnabled, configuration);
this.fakePlayersAmount = setIfUnexistant("custom-motd.fakeplayers.amount", this.fakePlayersAmount, configuration);
this.fakePlayersMode = setIfUnexistant("custom-motd.fakeplayers.mode", this.fakePlayersMode, configuration);
@ -1513,7 +1513,7 @@ index cc76325b2..05cf5b953 100644
}
}
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
index c00ab4b6a..86021b71b 100644
index f6681e240..c530c8b2c 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
@@ -22,7 +22,8 @@ import javax.crypto.SecretKey;

View File

@ -1,14 +1,14 @@
From f93a1b115b200c18866a60acab830073caa3a3a8 Mon Sep 17 00:00:00 2001
From 878971d7cb3640202811677aa8e54b34cea4393e Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 4 Mar 2022 14:09:35 -0300
Subject: [PATCH] Allow Invalid Names
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
index 8cfb197e8..7c534400c 100644
index aa26af32d..e2315e83f 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -18,6 +18,10 @@ import net.md_5.bungee.config.Configuration;
@@ -16,6 +16,10 @@ import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration extends FlameConfig {
@ -19,7 +19,7 @@ index 8cfb197e8..7c534400c 100644
// FlameCord start - Antibot System
@Getter
private boolean antibotAccountsEnabled = true;
@@ -287,6 +291,8 @@ public class FlameCordConfiguration extends FlameConfig {
@@ -273,6 +277,8 @@ public class FlameCordConfiguration extends FlameConfig {
this.fakePlayersEnabled = setIfUnexistant("custom-motd.fakeplayers.enabled", this.fakePlayersEnabled, configuration);
this.fakePlayersAmount = setIfUnexistant("custom-motd.fakeplayers.amount", this.fakePlayersAmount, configuration);
this.fakePlayersMode = setIfUnexistant("custom-motd.fakeplayers.mode", this.fakePlayersMode, configuration);
@ -29,7 +29,7 @@ index 8cfb197e8..7c534400c 100644
this.tcpFastOpen = setIfUnexistant("tcp-fast-open", this.tcpFastOpen, configuration);
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
index 86021b71b..c2733d6e3 100644
index c530c8b2c..9978b9db1 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
@@ -521,7 +521,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection