diff options
| -rw-r--r-- | docs/changelog.html | 2 | ||||
| -rw-r--r-- | src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java | 35 | ||||
| -rw-r--r-- | src/main/java/com/aizistral/nochatreports/mixins/client/MixinOnlineServerEntry.java | 69 | ||||
| -rw-r--r-- | src/main/resources/assets/nochatreports/lang/en_us.json | 1 | ||||
| -rw-r--r-- | src/main/resources/assets/nochatreports/textures/gui/verified_server.png | bin | 0 -> 237 bytes | |||
| -rw-r--r-- | src/main/resources/nochatreports.mixins.json | 3 |
6 files changed, 105 insertions, 5 deletions
diff --git a/docs/changelog.html b/docs/changelog.html index a567d32..3b2df0b 100644 --- a/docs/changelog.html +++ b/docs/changelog.html @@ -4,7 +4,7 @@ <p> - Added reset button and default field value to whitelisted servers option in Mod Menu config integration (<a href="https://github.com/Aizistral-Studios/No-Chat-Reports/pull/162">thanks MODKILLER1001, #162</a>);<br/> - Updated Polish translation (<a href="https://github.com/Aizistral-Studios/No-Chat-Reports/pull/165">thanks GerbilPL, #165</a>);<br/> - - Added Simplified Chinese translation (thanks IlyaIvanovsky and MSDNicrosoft, <a href="https://github.com/Aizistral-Studios/No-Chat-Reports/pull/164">#164</a>/<a href="https://github.com/Aizistral-Studios/No-Chat-Reports/pull/166">#166</a>).<br/> + - Updated Simplified Chinese translation (thanks IlyaIvanovsky and MSDNicrosoft, <a href="https://github.com/Aizistral-Studios/No-Chat-Reports/pull/164">#164</a>/<a href="https://github.com/Aizistral-Studios/No-Chat-Reports/pull/166">#166</a>).<br/> <p/><br/><br/> diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java b/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java index 004ef83..0ab4db9 100644 --- a/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java +++ b/src/main/java/com/aizistral/nochatreports/config/NCRClientConfig.java @@ -17,7 +17,8 @@ public final class NCRClientConfig extends JSONConfig { protected boolean demandOnServer = false, showServerSafety = true, hideRedChatIndicators = true, hideYellowChatIndicators = true, hideGrayChatIndicators = true, hideWarningToast = true, alwaysHideReportButton = false, disableTelemetry = true, showReloadButton = true, - whitelistAllServers = false; + whitelistAllServers = false, verifiedIconEnabled = true; + protected int verifiedIconOffsetX = 0, verifiedIconOffsetY = 0; protected List<String> whitelistedServers = DEFAULT_WHITELISTED_SERVERS; protected NCRClientConfig() { @@ -155,8 +156,8 @@ public final class NCRClientConfig extends JSONConfig { /** * @return True if the full-screen warning should be skipped for servers that require chat signing, - * letting users simply join the server. Because of that, servers will no longer be added to the whitelist. - * <br><br> + * letting users simply join the server. Because of that, servers will no longer be added to the + * whitelist.<br><br> * * This is false by default. */ @@ -165,4 +166,32 @@ public final class NCRClientConfig extends JSONConfig { return this.whitelistAllServers; } + /** + * @return True if "Safe Server" icon should be displayed in multiplayer menu for servers that + * declare themselves as preventing chat reports.<br><br> + * + * This is true by default. + */ + + public boolean verifiedIconEnabled() { + return this.verifiedIconEnabled; + } + + + /** + * @return X offset for "Safe Server" icon in multiplayer menu. + */ + + public int getVerifiedIconOffsetX() { + return 16 + this.verifiedIconOffsetX; + } + + /** + * @return Y offset for "Safe Server" icon in multiplayer menu. + */ + + public int getVerifiedIconOffsetY() { + return 12 + this.verifiedIconOffsetY; + } + } diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinOnlineServerEntry.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinOnlineServerEntry.java new file mode 100644 index 0000000..9354e7e --- /dev/null +++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinOnlineServerEntry.java @@ -0,0 +1,69 @@ +package com.aizistral.nochatreports.mixins.client; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.aizistral.nochatreports.NoChatReports; +import com.aizistral.nochatreports.NoChatReportsClient; +import com.aizistral.nochatreports.config.NCRConfig; +import com.aizistral.nochatreports.core.ServerDataExtension; +import com.aizistral.nochatreports.gui.FontHelper; +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen; +import net.minecraft.client.gui.screens.multiplayer.ServerSelectionList; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.locale.Language; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Tuple; + +@Mixin(ServerSelectionList.OnlineServerEntry.class) +public abstract class MixinOnlineServerEntry extends ServerSelectionList.Entry { + private static final ResourceLocation VERIFIED_ICON = new ResourceLocation("nochatreports", "textures/gui/verified_server.png"); + + @Shadow @Final + private JoinMultiplayerScreen screen; + @Shadow @Final + private Minecraft minecraft; + @Shadow @Final + private ServerData serverData; + + @Inject(method = "render", at = @At("RETURN")) + private void onRender(PoseStack poseStack, int i, int j, int k, int l, int m, int n, int o, boolean bl, float f, CallbackInfo info) { + if (!NCRConfig.getClient().verifiedIconEnabled()) + return; + + if (this.serverData.ping > 0 && ((ServerDataExtension) this.serverData).preventsChatReports()) { + int xOffset = NCRConfig.getClient().getVerifiedIconOffsetX(), + yOffset = NCRConfig.getClient().getVerifiedIconOffsetY(); + + RenderSystem.setShaderTexture(0, VERIFIED_ICON); + RenderSystem.enableBlend(); + GuiComponent.blit(poseStack, k + l - 35 + xOffset, j - 1 + yOffset, 0.0f, 0.0f, 14, 14, 14, 14); + RenderSystem.disableBlend(); + + int t = n - k; + int u = o - j; + if (t >= l - 35 + xOffset && t <= l - 22 + xOffset && u >= 0 + yOffset && u <= 11 + yOffset) { + this.screen.setToolTip(FontHelper.wrap(this.minecraft.font, Language.getInstance() + .getOrDefault("gui.nochatreports.verified_server"), 250).stream() + .map(Component::literal).collect(Collectors.toCollection(() -> + new ArrayList<Component>()))); + } + } + } + +} diff --git a/src/main/resources/assets/nochatreports/lang/en_us.json b/src/main/resources/assets/nochatreports/lang/en_us.json index 2dac977..195e4ed 100644 --- a/src/main/resources/assets/nochatreports/lang/en_us.json +++ b/src/main/resources/assets/nochatreports/lang/en_us.json @@ -12,6 +12,7 @@ "gui.nochatreports.unsafe_server.contents": "This server requires all chat messages to be signed, which means they can be reported to Mojang, which may result in a ban from all multiplayer servers. This likely means that the server owner kept \"enforce-secure-profile\" enabled in the server.properties, which is the default since 1.19.1. You can choose to play anyway, but No Chat Reports will not be able to protect you.", "gui.nochatreports.unsafe_server.check": "Do not show again for this server", "gui.nochatrepords.reload_config_tooltip": "Reload No Chat Reports config. Use carefully.", + "gui.nochatreports.verified_server": "§a§lSafe Server§r\nWe could verify that this server has No Chat Reports installed, or prevents chat reports in some other known way. You can chat there safely.", "configuration.NoChatReports.config": "No Chat Reports", "configuration.NoChatReports.category.visual": "Visual", diff --git a/src/main/resources/assets/nochatreports/textures/gui/verified_server.png b/src/main/resources/assets/nochatreports/textures/gui/verified_server.png Binary files differnew file mode 100644 index 0000000..b8dcf7a --- /dev/null +++ b/src/main/resources/assets/nochatreports/textures/gui/verified_server.png diff --git a/src/main/resources/nochatreports.mixins.json b/src/main/resources/nochatreports.mixins.json index c4f4fd0..113959c 100644 --- a/src/main/resources/nochatreports.mixins.json +++ b/src/main/resources/nochatreports.mixins.json @@ -29,7 +29,8 @@ "client.MixinToastComponent", "client.MixinRealmsConnect", "client.MixinServerData", - "client.MixinServerStatusPinger$1" + "client.MixinServerStatusPinger$1", + "client.MixinOnlineServerEntry" ], "server": [ "server.MixinDedicatedServer" |
