From d10b78ab467216432a60e14ecc1d5969a64e30f1 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Sat, 19 Jun 2021 13:01:47 +0100 Subject: [PATCH] Ignore hyperlink suffixes in spaceless languages, fixes #620 There's no real way to do this other than hardcoding which languages are exceptions (currently only the two Chinese locales) --- .../wizardry/client/gui/handbook/Section.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/electroblob/wizardry/client/gui/handbook/Section.java b/src/main/java/electroblob/wizardry/client/gui/handbook/Section.java index 6fea7d7c..495a4f39 100644 --- a/src/main/java/electroblob/wizardry/client/gui/handbook/Section.java +++ b/src/main/java/electroblob/wizardry/client/gui/handbook/Section.java @@ -1,5 +1,6 @@ package electroblob.wizardry.client.gui.handbook; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Streams; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -35,6 +36,8 @@ import java.util.*; // be a non-static inner class class Section { + private static final Set SPACELESS_LANGUAGES = ImmutableSet.of("zh_cn", "zh_tw"); + // Final fields are mandatory (none here though), the rest are optional String title; private String[] rawText; @@ -293,7 +296,12 @@ class Section { String linkRaw = paragraph.substring(linkStart, linkEnd + 1); String[] arguments = paragraph.substring(linkStart + 1, linkEnd).split("\\s", 2); - String suffix = paragraph.substring(linkEnd).split("\\s", 2)[0].substring(1); // substring(1) to remove the @ + String suffix = ""; + + // Account for trailing punctuation, except in languages that don't use spaces such as Chinese + if(!SPACELESS_LANGUAGES.contains(Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode())){ + paragraph.substring(linkEnd).split("\\s", 2)[0].substring(1); // substring(1) to remove the @ + } // The index of the single page currently being formatted, relative to the section int pageRelative = (lines.size() + upToLink.size() - 1) / maxLineNumber;