Исходник Notification spec/warp | Expensive 3.1

Начинающий
Статус
Оффлайн
Регистрация
21 Мар 2024
Сообщения
13
Реакции[?]
0
Поинты[?]
0
ну сливаю вам мой жоский селфкод с чатом гпт
Код:
import com.google.common.eventbus.Subscribe;
import im.arixxx.events.EventPacket;
import im.arixxx.functions.api.Category;
import im.arixxx.functions.api.Function;
import im.arixxx.functions.api.FunctionRegister;
import im.arixxx.functions.api.NotificationUtil;
import im.arixxx.ui.NotificationRender;
import net.minecraft.network.play.server.SChatPacket;
import net.minecraft.util.text.TextFormatting;

import java.util.*;

@FunctionRegister(name = "Notification", type = Category.Visuals, serverft = "", serverrw = "", serverhw = "", desc = "Уведомления")
public class Notification extends Function {

    private static final String[] SPECTEXTS = {"Spec", "Спек", "spec", "спек", "SPEC", "СПЕК", "Спек"};
    private static final String[] WARPTEXTS = {"/Warp", "/Варп", "warp", "варп", "WARP", "ВАРП", "Варп"};

    @Subscribe
    public void onEvent(EventPacket packetEvent) {
        if (packetEvent.isReceive() && packetEvent.getPacket() instanceof SChatPacket packetChat) {
            handleReceivePacket(packetChat);
        }
    }

    private void handleReceivePacket(SChatPacket packet) {
        String originalMessage = packet.getChatComponent().getString();
        String formattedMessage = TextFormatting.getTextWithoutFormattingCodes(originalMessage);

        String lowerCaseMessage = originalMessage.toLowerCase(Locale.ROOT);

        if (isSpecMessage(lowerCaseMessage)) {
            renderSpecNotification(formattedMessage);
        }
        if (isWarpMessage(lowerCaseMessage)) {
            renderWarpNotification(formattedMessage);
        }
    }

    private boolean isSpecMessage(String lowerCaseMessage) {
        return Arrays.stream(SPECTEXTS)
                .map(String::toLowerCase)
                .anyMatch(lowerCaseMessage::contains);
    }
    private boolean isWarpMessage(String lowerCaseMessage) {
        return Arrays.stream(WARPTEXTS)
                .map(String::toLowerCase)
                .anyMatch(lowerCaseMessage::contains);
    }


    private void renderSpecNotification(String lowerCaseMessage) {
        NotificationUtil.NOTIFICATION_MANAGER.add(lowerCaseMessage + " просит проследить за ним!", "", 2, NotificationRender.ImageType.SPEC_PHOTO);
    }
    private void renderWarpNotification(String lowerCaseMessage) {
        NotificationUtil.NOTIFICATION_MANAGER.add(lowerCaseMessage + " просит пропиарить его варп!", "", 2, NotificationRender.ImageType.WARP_PHOTO);
    }
}

ss - Посмотреть вложение 283554Посмотреть вложение 283555
а Notification render а NotoficationUtil если скинешь вот дс tipo4k_yes_blody
 
Сверху Снизу