CloudNetService / CloudNet

A modern application that can dynamically and easily deliver Minecraft oriented software
https://cloudnetservice.eu
Apache License 2.0
371 stars 115 forks source link

Gradinet Text #1327

Closed MarvinKeriaan closed 1 month ago

MarvinKeriaan commented 10 months ago

Describe the new feature

ENGLISH

As info I'm not sure if this idea has been around before, however I haven't found anything about it now. Okay it's a bit hard to describe, today it's standard that many servers use a gradient to design texts, it would be great if there was a simple way to do this. For this there is the possibility to use MiniMessages, or you can write your own code. I have posted a possible code below in the alternative. I have coded it with the help (of ChatGPT) and I know that it works in 1.20.

DEUTSCH

Als Info ich bin mir nicht sicher ob es diese Idee schon mal gab, jedoch habe ich jetzt nichts dazu gefunden. Okay es ist etwas schwer zu beschreiben, heute ist es standart das viele Server einen Gradienten nutzen um Texte zu Designen, es wäre Super wenn es hier für eine Einfache möglichkeit gäbe. Dafür gibt es zum einen die Möglichkeit MiniMessages nutzen zu können, oder man schreibt einen eigenen Code dazu. Ich habe einen möglichen Code unten in der Alternative gepostet, ich habe ihn mit Hilfe (von ChatGPT) gecodet und weiß das er in der 1.20 Funktioniert.

Why do you need this feature?

ENGLISH

Color gradients let everything shine in a new glow, and from today's perspective also look more modern. In addition, it is also not really difficult to implement it

DEUTSCH

Farbverläufe lassen alles in einen neuen glanz erstrahlen, und aus heutiger sich auch moderner wirken. Dazu ist es auch nicht wirklich schwer es zu Implementieren

Alternatives

Spigot/Bungeecorde Code

import net.md_5.bungee.api.ChatColor;
public class ColorTranslater {

    public String convertToMinecraftColor(String code) {

        if (code == null || code.isEmpty()) {
            return "";
        }

        StringBuilder converted = new StringBuilder();

        for (int i = 0; i < code.length(); i++) {
            if (i + 7 <= code.length() && code.charAt(i) == '&' && code.charAt(i + 1) == '#') {
                String hexSegment = code.substring(i + 2, i + 8); // Extrahiere den Hex-Teil des Segments
                converted.append(transformHexToMinecraftColor(hexSegment));
                i += 7; // Springe über das gesamte "&#RRGGBB" Segment
            } else {
                converted.append(code.charAt(i));
            }
        }

        return converted.toString();
    }

    private String transformHexToMinecraftColor(String hex) {
        StringBuilder mcColor = new StringBuilder("§x");
        for (char ch : hex.toCharArray()) {
            mcColor.append("§").append(ch);
        }
        return mcColor.toString();
    }
}

Other

gradient_1

Issue uniqueness

derklaro commented 10 months ago

You need to specific the places where that support is lacking. We already have code to convert these kinds of color codes, see https://github.com/CloudNetService/CloudNet-v3/blob/nightly/ext/adventure-helper/src/main/java/eu/cloudnetservice/ext/component/ComponentConverter.java