Added Hide Team Prefix/Suffix option to player right-click menu

This commit is contained in:
Moulberry committed 2025-02-11 18:31:04 +08:00
1 parent be840298ef
commit 7b9f11f60d
4 files changed
+102 -1

No files matched your search

@@ -2,6 +2,10 @@ package com.moulberry.flashback;
import com.moulberry.flashback.playback.ReplayServer;
import it.unimi.dsi.fastutil.objects.Object2FloatFunction;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.contents.PlainTextContents;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
@@ -160,6 +164,31 @@ public class Utils {
}
}
public static boolean isComponentEmpty(Component component) {
if (component == CommonComponents.EMPTY) {
return true;
}
boolean isSelfEmpty = false;
if (component.getContents() == PlainTextContents.EMPTY) {
isSelfEmpty = true;
} else if (component.getContents() instanceof PlainTextContents plainTextContents) {
isSelfEmpty = ChatFormatting.stripFormatting(plainTextContents.text()).isEmpty();
}
if (isSelfEmpty) {
for (Component sibling : component.getSiblings()) {
if (!isComponentEmpty(sibling)) {
return false;
}
}
return true;
}
return false;
}
public static int exportSequenceCount = 1;
public static String resolveFilenameTemplate(String template) {
LocalDateTime dateTime = LocalDateTime.now();