Визуальная часть ColorizeMessages Module [Fabric/1.21.1]

Забаненный
Забаненный
Статус
Оффлайн
Регистрация
13 Фев 2025
Сообщения
7
Реакции
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Выберите загрузчик игры
  1. Fabric

Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:

  • бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
  • маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
  • приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
  • обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.

Спасибо!

Сливаю нахер никому не нужный фановый модуль на цветовые сообщения.
Пример показан на создании клан тэга.

ColorizeMessage.java:
Expand Collapse Copy
package ru.itskekoff.client.components.modules.impl.misc;

import com.google.gson.annotations.Expose;
import lombok.RequiredArgsConstructor;
import ru.itskekoff.client.components.modules.BaseModule;
import ru.itskekoff.client.core.config.setting.types.RequiredField;
import ru.itskekoff.client.core.config.setting.types.Setting;
import ru.itskekoff.client.core.event.EventBus;
import ru.itskekoff.client.core.event.impl.network.ChatMessageEvent;
import ru.itskekoff.client.core.utils.text.string.StringUtils;

import java.awt.*;

/**
[LIST]
[*][USER=35246]@Author[/USER] itskekoff
[*][USER=30931]@since[/USER] 23:25 of 01.01.2025
[/LIST]
*/

@BaseModule.ModuleInfo(name = "ColorizeMessage", category = BaseModule.ModuleCategory.MISC)
public class ColorizeMessageModule extends BaseModule {
    @Expose
    @Setting(description = "this.setting.colorMode")
    private ColorMode colorMode = ColorMode.SINGLE;

    @Expose
    @Setting(description = "this.setting.singleColor", requiredField = @RequiredField(name = "colorMode", state = "SINGLE"))
    private Color singleColor = new Color(255, 255, 255);
    @Expose
    @Setting(description = "this.setting.gradientStartColor", requiredField = @RequiredField(name = "colorMode", state = "GRADIENT"))
    private Color gradientStartColor = new Color(255, 0, 0);
    @Expose
    @Setting(description = "this.setting.gradientEndColor", requiredField = @RequiredField(name = "colorMode", state = "GRADIENT"))
    private Color gradientEndColor = new Color(0, 0, 255);
    @Expose
    @Setting(description = "this.setting.rainbowSpeed", min = 0.01f, max = 2.0f, requiredField = @RequiredField(name = "colorMode", state = "RAINBOW"))
    private float rainbowSpeed = 0.5f;

    @Expose
    @Setting(description = "this.setting.useWithGlobalChat")
    private boolean useWithGlobalChat = true;
    @Expose
    @Setting(description = "this.setting.globalCharacters",
            requiredField = @RequiredField(name = "useWithGlobalChat", checked = true))
    private String globalCharacters = "!";

    @Expose
    @Setting(description = "this.setting.useBold")
    private boolean useBold = false;
    @Expose
    @Setting(description = "this.setting.useItalic")
    private boolean useItalic = false;
    @Expose
    @Setting(description = "this.setting.useUnderline")
    private boolean useUnderline = false;
    @Expose
    @Setting(description = "this.setting.useStrikethrough")
    private boolean useStrikethrough = false;
    @Expose
    @Setting(description = "this.setting.useObfuscated")
    private boolean useObfuscated = false;

    private float hue = 0f;

    @EventBus.Listener(events = ChatMessageEvent.class)
    private void onMessage(ChatMessageEvent event) {
        if (event.getType() != ChatMessageEvent.MessageType.OUTGOING) return;

        StringBuilder coloredMessage = new StringBuilder();
        String originalMessage = event.getMessage();

        if (originalMessage.startsWith(this.globalCharacters) && this.useWithGlobalChat) {
            originalMessage = originalMessage.substring(this.globalCharacters.length());
            coloredMessage.append(this.globalCharacters);
        }

        StringBuilder result = switch (this.colorMode) {
            case ColorMode.SINGLE -> this.applySingleColor(originalMessage, this.singleColor);
            case ColorMode.GRADIENT -> this.applyGradient(originalMessage, this.gradientStartColor, this.gradientEndColor);
            case ColorMode.RAINBOW -> this.applyRainbow(originalMessage);
        };
        coloredMessage.append(this.applyFormatting()).append(result);

        event.setMessage(coloredMessage.toString());
    }

    private StringBuilder applyFormatting() {
        StringBuilder builder = new StringBuilder();

        if (this.useBold) builder.append("&l");
        if (this.useItalic) builder.append("&o");
        if (this.useUnderline) builder.append("&n");
        if (this.useStrikethrough) builder.append("&m");
        if (this.useObfuscated) builder.append("&k");

        return builder;
    }

    private StringBuilder applySingleColor(String text, Color color) {
        StringBuilder builder = new StringBuilder();
        builder.append(StringUtils.colorToHEX(color, false));

        return builder.append(text);
    }

    private StringBuilder applyGradient(String text, Color startColor, Color endColor) {
        StringBuilder builder = new StringBuilder();
        int length = text.length();

        for (int i = 0; i < length; i++) {
            float progress = (float) i / (length - 1);
            Color interpolatedColor = interpolateColor(startColor, endColor, progress);
            builder.append(applySingleColor(String.valueOf(text.charAt(i)), interpolatedColor));
        }
        return builder;
    }

    private StringBuilder applyRainbow(String text) {
        StringBuilder builder = new StringBuilder();
        int length = text.length();

        for (int i = 0; i < length; i++) {
            float hueValue = (hue + (float) i / length) % 1f;
            Color color = Color.getHSBColor(hueValue, 1f, 1f);
            builder.append(applySingleColor(String.valueOf(text.charAt(i)), color));
        }
        hue = (hue + rainbowSpeed * 0.01f) % 1f;
        return builder;
    }

    private Color interpolateColor(Color startColor, Color endColor, float progress) {
        int red = (int) (startColor.getRed() + (endColor.getRed() - startColor.getRed()) * progress);
        int green = (int) (startColor.getGreen() + (endColor.getGreen() - startColor.getGreen()) * progress);
        int blue = (int) (startColor.getBlue() + (endColor.getBlue() - startColor.getBlue()) * progress);

        return new Color(red, green, blue);
    }

    @RequiredArgsConstructor
    public enum ColorMode {
        SINGLE("Single Color"),
        GRADIENT("Gradient"),
        RAINBOW("Rainbow");

        private final String displayName;

        [USER=1367676]@override[/USER]
        public String toString() {
            return this.displayName;
        }
    }
}
StringUtils.java:
Expand Collapse Copy
// ..........
public String colorToHEX(Color color, boolean useAlpha) {
    String rgbHex = "&#%02x%02x%02x".formatted(color.getRed(), color.getGreen(), color.getBlue());
    if (useAlpha) rgbHex += "%02x".formatted(color.getAlpha());

    return rgbHex;
}


1746899822772.png


1746902094338.png
 
Последнее редактирование:
пойдет мб
 
Сливаю нахер никому не нужный фановый модуль на цветовые сообщения.
Пример показан на создании клан тэга.

ColorizeMessage.java:
Expand Collapse Copy
package ru.itskekoff.client.components.modules.impl.misc;

import com.google.gson.annotations.Expose;
import lombok.RequiredArgsConstructor;
import ru.itskekoff.client.components.modules.BaseModule;
import ru.itskekoff.client.core.config.setting.types.RequiredField;
import ru.itskekoff.client.core.config.setting.types.Setting;
import ru.itskekoff.client.core.event.EventBus;
import ru.itskekoff.client.core.event.impl.network.ChatMessageEvent;
import ru.itskekoff.client.core.utils.text.string.StringUtils;

import java.awt.*;

/**
[LIST]
[*][USER=35246]@Author[/USER] itskekoff
[*][USER=30931]@since[/USER] 23:25 of 01.01.2025
[/LIST]
*/

@BaseModule.ModuleInfo(name = "ColorizeMessage", category = BaseModule.ModuleCategory.MISC)
public class ColorizeMessageModule extends BaseModule {
    @Expose
    @Setting(description = "this.setting.colorMode")
    private ColorMode colorMode = ColorMode.SINGLE;

    @Expose
    @Setting(description = "this.setting.singleColor", requiredField = @RequiredField(name = "colorMode", state = "SINGLE"))
    private Color singleColor = new Color(255, 255, 255);
    @Expose
    @Setting(description = "this.setting.gradientStartColor", requiredField = @RequiredField(name = "colorMode", state = "GRADIENT"))
    private Color gradientStartColor = new Color(255, 0, 0);
    @Expose
    @Setting(description = "this.setting.gradientEndColor", requiredField = @RequiredField(name = "colorMode", state = "GRADIENT"))
    private Color gradientEndColor = new Color(0, 0, 255);
    @Expose
    @Setting(description = "this.setting.rainbowSpeed", min = 0.01f, max = 2.0f, requiredField = @RequiredField(name = "colorMode", state = "RAINBOW"))
    private float rainbowSpeed = 0.5f;

    @Expose
    @Setting(description = "this.setting.useWithGlobalChat")
    private boolean useWithGlobalChat = true;
    @Expose
    @Setting(description = "this.setting.globalCharacters",
            requiredField = @RequiredField(name = "useWithGlobalChat", checked = true))
    private String globalCharacters = "!";

    @Expose
    @Setting(description = "this.setting.useBold")
    private boolean useBold = false;
    @Expose
    @Setting(description = "this.setting.useItalic")
    private boolean useItalic = false;
    @Expose
    @Setting(description = "this.setting.useUnderline")
    private boolean useUnderline = false;
    @Expose
    @Setting(description = "this.setting.useStrikethrough")
    private boolean useStrikethrough = false;
    @Expose
    @Setting(description = "this.setting.useObfuscated")
    private boolean useObfuscated = false;

    private float hue = 0f;

    @EventBus.Listener(events = ChatMessageEvent.class)
    private void onMessage(ChatMessageEvent event) {
        if (event.getType() != ChatMessageEvent.MessageType.OUTGOING) return;

        StringBuilder coloredMessage = new StringBuilder();
        String originalMessage = event.getMessage();

        if (originalMessage.startsWith(this.globalCharacters) && this.useWithGlobalChat) {
            originalMessage = originalMessage.substring(this.globalCharacters.length());
            coloredMessage.append(this.globalCharacters);
        }

        StringBuilder result = switch (this.colorMode) {
            case ColorMode.SINGLE -> this.applySingleColor(originalMessage, this.singleColor);
            case ColorMode.GRADIENT -> this.applyGradient(originalMessage, this.gradientStartColor, this.gradientEndColor);
            case ColorMode.RAINBOW -> this.applyRainbow(originalMessage);
        };
        coloredMessage.append(this.applyFormatting()).append(result);

        event.setMessage(coloredMessage.toString());
    }

    private StringBuilder applyFormatting() {
        StringBuilder builder = new StringBuilder();

        if (this.useBold) builder.append("&l");
        if (this.useItalic) builder.append("&o");
        if (this.useUnderline) builder.append("&n");
        if (this.useStrikethrough) builder.append("&m");
        if (this.useObfuscated) builder.append("&k");

        return builder;
    }

    private StringBuilder applySingleColor(String text, Color color) {
        StringBuilder builder = new StringBuilder();
        builder.append(StringUtils.colorToHEX(color, false));

        return builder.append(text);
    }

    private StringBuilder applyGradient(String text, Color startColor, Color endColor) {
        StringBuilder builder = new StringBuilder();
        int length = text.length();

        for (int i = 0; i < length; i++) {
            float progress = (float) i / (length - 1);
            Color interpolatedColor = interpolateColor(startColor, endColor, progress);
            builder.append(applySingleColor(String.valueOf(text.charAt(i)), interpolatedColor));
        }
        return builder;
    }

    private StringBuilder applyRainbow(String text) {
        StringBuilder builder = new StringBuilder();
        int length = text.length();

        for (int i = 0; i < length; i++) {
            float hueValue = (hue + (float) i / length) % 1f;
            Color color = Color.getHSBColor(hueValue, 1f, 1f);
            builder.append(applySingleColor(String.valueOf(text.charAt(i)), color));
        }
        hue = (hue + rainbowSpeed * 0.01f) % 1f;
        return builder;
    }

    private Color interpolateColor(Color startColor, Color endColor, float progress) {
        int red = (int) (startColor.getRed() + (endColor.getRed() - startColor.getRed()) * progress);
        int green = (int) (startColor.getGreen() + (endColor.getGreen() - startColor.getGreen()) * progress);
        int blue = (int) (startColor.getBlue() + (endColor.getBlue() - startColor.getBlue()) * progress);

        return new Color(red, green, blue);
    }

    @RequiredArgsConstructor
    public enum ColorMode {
        SINGLE("Single Color"),
        GRADIENT("Gradient"),
        RAINBOW("Rainbow");

        private final String displayName;

        [USER=1367676]@override[/USER]
        public String toString() {
            return this.displayName;
        }
    }
}
StringUtils.java:
Expand Collapse Copy
// ..........
public String colorToHEX(Color color, boolean useAlpha) {
    String rgbHex = "&#%02x%02x%02x".formatted(color.getRed(), color.getGreen(), color.getBlue());
    if (useAlpha) rgbHex += "%02x".formatted(color.getAlpha());

    return rgbHex;
}


Посмотреть вложение 306030

Посмотреть вложение 306031


и да itskekoff жду кряка samoware client <3
 
Годно, пастить не кому, все на 1.16.5 и exp 3.1
 
Назад
Сверху Снизу