Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b43549fe1c | ||
|
|
1ac3ab0a72 |
@@ -0,0 +1,49 @@
|
|||||||
|
package org.examp.john.mixin.client;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.Font;
|
||||||
|
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||||
|
import net.minecraft.client.gui.components.PlayerTabOverlay;
|
||||||
|
import net.minecraft.client.multiplayer.PlayerInfo;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.world.level.GameType;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Прибирає курсив та сірий колір для spectator у таб-листі.
|
||||||
|
*/
|
||||||
|
@Mixin(PlayerTabOverlay.class)
|
||||||
|
public class PlayerTabOverlayMixin {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Прибирає курсив з назви spectator в табі.
|
||||||
|
*/
|
||||||
|
@Inject(method = "getNameForDisplay", at = @At("RETURN"), cancellable = true)
|
||||||
|
private void removeSpectatorItalic(PlayerInfo playerInfo, CallbackInfoReturnable<Component> cir) {
|
||||||
|
if (playerInfo.getGameMode() == GameType.SPECTATOR) {
|
||||||
|
Component original = cir.getReturnValue();
|
||||||
|
cir.setReturnValue(original.copy().withStyle(original.getStyle().withItalic(false)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Перехоплюємо виклик text(Font, Component, x, y, color) в extractRenderState.
|
||||||
|
* Якщо колір = -1862270977 (сірий для spectator), замінюємо на -1 (білий).
|
||||||
|
*/
|
||||||
|
@Redirect(
|
||||||
|
method = "extractRenderState",
|
||||||
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;text(Lnet/minecraft/client/gui/Font;Lnet/minecraft/network/chat/Component;III)V"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
private void forceWhiteText(GuiGraphicsExtractor instance, Font font, Component text, int x, int y, int color) {
|
||||||
|
if (color == -1862270977) {
|
||||||
|
color = -1; // білий
|
||||||
|
}
|
||||||
|
instance.text(font, text, x, y, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
"package": "org.examp.john.mixin.client",
|
"package": "org.examp.john.mixin.client",
|
||||||
"compatibilityLevel": "JAVA_25",
|
"compatibilityLevel": "JAVA_25",
|
||||||
"client": [
|
"client": [
|
||||||
|
"PlayerTabOverlayMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class AntiAbuse {
|
public class AntiAbuse {
|
||||||
|
|
||||||
|
|
||||||
private static final int REPEAT_THRESHOLD = 5;
|
private static final int REPEAT_THRESHOLD = 5;
|
||||||
private static final double DISTANCE_THRESHOLD = 50.0;
|
private static final double DISTANCE_THRESHOLD = 50.0;
|
||||||
private static final long TIME_WINDOW_MS = 5 * 60 * 1000;
|
private static final long TIME_WINDOW_MS = 5 * 60 * 1000;
|
||||||
@@ -65,7 +66,7 @@ public class AntiAbuse {
|
|||||||
double spread = Math.max(b[1] - b[0], b[3] - b[2]);
|
double spread = Math.max(b[1] - b[0], b[3] - b[2]);
|
||||||
|
|
||||||
if (spread > DISTANCE_THRESHOLD) {
|
if (spread > DISTANCE_THRESHOLD) {
|
||||||
Localchat.magicModLog.warn(
|
MSNexus.magicModLog.warn(
|
||||||
"[ANTI-ABUSE] Гравець {} ймовірно шукає інших: "
|
"[ANTI-ABUSE] Гравець {} ймовірно шукає інших: "
|
||||||
+ "'{}' ×{} разів, переміщення ~{} блоків",
|
+ "'{}' ×{} разів, переміщення ~{} блоків",
|
||||||
player.getName().getString(),
|
player.getName().getString(),
|
||||||
|
|||||||
@@ -5,8 +5,11 @@ import net.luckperms.api.LuckPerms;
|
|||||||
import net.luckperms.api.LuckPermsProvider;
|
import net.luckperms.api.LuckPermsProvider;
|
||||||
import net.luckperms.api.model.user.User;
|
import net.luckperms.api.model.user.User;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.network.chat.ClickEvent;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.chat.HoverEvent;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
|
import net.minecraft.network.chat.Style;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import org.examp.john.stealth.StealthStorage;
|
import org.examp.john.stealth.StealthStorage;
|
||||||
@@ -126,8 +129,8 @@ public class ChatHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Component createMentionComponent(ServerPlayer player) {
|
private static Component createMentionComponent(ServerPlayer player) {
|
||||||
String prefix = getLuckPermsPrefix(player);
|
String lpPrefix = getLuckPermsPrefix(player);
|
||||||
String formattedPrefix = prefix.replace("&", "\u00a7");
|
String formattedPrefix = lpPrefix.replace("&", "\u00a7");
|
||||||
String name = player.getName().getString();
|
String name = player.getName().getString();
|
||||||
|
|
||||||
return Component.literal(formattedPrefix + name)
|
return Component.literal(formattedPrefix + name)
|
||||||
@@ -140,21 +143,31 @@ public class ChatHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static MutableComponent buildFormattedName(ServerPlayer player) {
|
private static MutableComponent buildFormattedName(ServerPlayer player) {
|
||||||
String prefix = "";
|
String lpPrefix = getLuckPermsPrefix(player);
|
||||||
|
String playerName = player.getName().getString();
|
||||||
|
String formattedPrefix = lpPrefix.replace("&", "\u00a7");
|
||||||
|
|
||||||
|
Style clickStyle = Style.EMPTY
|
||||||
|
.withClickEvent(new ClickEvent.SuggestCommand("/msg " + playerName + " "))
|
||||||
|
.withHoverEvent(new HoverEvent.ShowText(
|
||||||
|
Component.literal("Натисніть щоб написати " + playerName)
|
||||||
|
.withStyle(ChatFormatting.GRAY)));
|
||||||
|
|
||||||
|
return Component.literal(formattedPrefix + playerName).withStyle(clickStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getLuckPermsPrefix(ServerPlayer player) {
|
||||||
try {
|
try {
|
||||||
LuckPerms luckPerms = LuckPermsProvider.get();
|
LuckPerms luckPerms = LuckPermsProvider.get();
|
||||||
User user = luckPerms.getUserManager().getUser(player.getUUID());
|
User user = luckPerms.getUserManager().getUser(player.getUUID());
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
String metaPrefix = user.getCachedData().getMetaData().getPrefix();
|
String metaPrefix = user.getCachedData().getMetaData().getPrefix();
|
||||||
if (metaPrefix != null) {
|
if (metaPrefix != null) {
|
||||||
prefix = metaPrefix;
|
return metaPrefix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
return Component.empty()
|
|
||||||
.append(Component.literal(prefix.replace("&", "§")))
|
|
||||||
.append(player.getDisplayName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package org.examp.john.stealth;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
import org.examp.john.Localchat;
|
import org.examp.john.MSNexus;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
@@ -45,7 +45,7 @@ public class StealthStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException | JsonSyntaxException | IllegalArgumentException e) {
|
} catch (IOException | JsonSyntaxException | IllegalArgumentException e) {
|
||||||
Localchat.magicModLog.warn("Не вдалося прочитати stealth.json: {}", e.getMessage());
|
MSNexus.magicModLog.warn("Не вдалося прочитати stealth.json: {}", e.getMessage());
|
||||||
data = new HashMap<>();
|
data = new HashMap<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ public class StealthStorage {
|
|||||||
GSON.toJson(raw, writer);
|
GSON.toJson(raw, writer);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Localchat.magicModLog.error("Не вдалося зберегти stealth.json: {}", e.getMessage());
|
MSNexus.magicModLog.error("Не вдалося зберегти stealth.json: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,gi
|
"schemaVersion": 1,
|
||||||
"id": "msnexus",
|
"id": "msnexus",
|
||||||
"version": "${version}",
|
"version": "${version}",
|
||||||
"name": "msnexus",
|
"name": "msnexus",
|
||||||
|
|||||||
Reference in New Issue
Block a user