Skip to content

Commit

Permalink
1.19.3 1.5.5 (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
SiongSng authored May 7, 2023
2 parents 18f07e2 + 5ccc9a8 commit 10f0bc2
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.rpmtw.rpmtw_platform_mod.command.CommandHandler
import com.rpmtw.rpmtw_platform_mod.config.RPMTWConfig
import com.rpmtw.rpmtw_platform_mod.handlers.EventHandler
import com.rpmtw.rpmtw_platform_mod.handlers.SentryHandler
import com.rpmtw.rpmtw_platform_mod.translation.GameLanguage
import dev.architectury.platform.Platform
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
Expand All @@ -21,6 +22,7 @@ object RPMTWPlatformMod {
@JvmStatic
fun init() {
LOGGER.info("Initializing RPMTW Platform Mod")
GameLanguage.initialize()
if (RPMTWConfig.get().advanced.sendExceptionToSentry) {
SentryHandler.init()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class ConfigObject : ConfigData {
val advanced = Advanced()

class Translate {
@ConfigEntry.Gui.Tooltip(count = 1)
@ConfigEntry.Gui.RequiresRestart
var loadTranslateResourcePack = GameLanguage.getSystem() == GameLanguage.TraditionalChinese

@ConfigEntry.Gui.Tooltip(count = 1)
@ConfigEntry.Gui.RequiresRestart
var machineTranslation = true
Expand All @@ -45,16 +49,6 @@ class ConfigObject : ConfigData {
}
}

@ConfigEntry.Gui.Tooltip(count = 1)
@ConfigEntry.Gui.RequiresRestart
var loadTranslateResourcePack = false
get() {
return if (GameLanguage.getSystem() == GameLanguage.TraditionalChinese) {
true
} else {
field
}
}

@ConfigEntry.Gui.Tooltip(count = 1)
@ConfigEntry.Gui.RequiresRestart
Expand Down Expand Up @@ -106,6 +100,8 @@ class ConfigObject : ConfigData {
var sendExceptionToSentry = true
}

@ConfigEntry.Gui.Excluded
var protocolVersion : Int? = null

@ConfigEntry.Gui.Excluded
var rpmtwAuthToken: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import java.util.*

object RPMTWConfig {
private var config: ConfigObject? = null
private const val PROTOCOL_VERSION = 1


private fun register() {
Expand All @@ -59,6 +60,8 @@ object RPMTWConfig {

val holder = AutoConfig.getConfigHolder(ConfigObject::class.java)
config = holder.config

checkProtocolVersion(holder, holder.config)
listenOnSave(holder, holder.config)

RPMTWPlatformMod.LOGGER.info("Registered config")
Expand Down Expand Up @@ -107,6 +110,18 @@ object RPMTWConfig {
}
}

private fun checkProtocolVersion(holder: ConfigHolder<ConfigObject>, config: ConfigObject) {
if (config.protocolVersion == null) {
config.protocolVersion = PROTOCOL_VERSION

if (!config.firstJoinLevel) {
holder.resetToDefault()
}

holder.save()
}
}

@JvmStatic
fun get(): ConfigObject {
if (config == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@ enum class GameLanguage(val code: String, val isO3Code: Set<String>) {
SimplifiedChinese("zh_cn", setOf("CHN"));

companion object {
private var systemLanguage: GameLanguage? = null

fun initialize() {
systemLanguage = getSystem()
}

fun getMinecraft(): GameLanguage {
val minecraftLanguage = Minecraft.getInstance().options.languageCode

return values().firstOrNull { it.code == minecraftLanguage } ?: English
}


fun getSystem(): GameLanguage? {
val systemCountry = Locale.getDefault().isO3Country
if (systemLanguage != null) return systemLanguage

val systemCountry = Locale.getDefault().isO3Country
return values().firstOrNull { it.isO3Code.contains(systemCountry) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"config.rpmtw_platform_mod.option.translate.unlocalized": "未本地化的内容",
"config.rpmtw_platform_mod.option.translate.unlocalized.@Tooltip": "额外显示未本地化的内容,若游戏语言为美国英语将不会起作用。",
"config.rpmtw_platform_mod.option.translate.loadTranslateResourcePack": "加载翻译资源包",
"config.rpmtw_platform_mod.option.translate.loadTranslateResourcePack.@Tooltip": "加载翻译资源包翻译模组和其他内容,只有在游戏语言是繁体中文时才会启用。",
"config.rpmtw_platform_mod.option.translate.autoToggleLanguage": "自动切换语言",
"config.rpmtw_platform_mod.option.translate.autoToggleLanguage.@Tooltip": "自动切换游戏语言到电脑系统使用的语言",
"config.rpmtw_platform_mod.option.advanced": "高级设置",
"config.rpmtw_platform_mod.option.advanced.sendExceptionToSentry": "發送本模組的例外錯誤至 Sentry",
"config.rpmtw_platform_mod.option.advanced.sendExceptionToSentry.@Tooltip": "发送本模组的例外错误至 Sentry 以协助我们改善本模组。(所有资料将会被去识别化并且我们不会将其用于其他用途。)",
Expand Down Expand Up @@ -75,8 +78,10 @@
"gui.rpmtw_platform_mod.self": "自己",
"gui.rpmtw_platform_mod.send": "发送",
"gui.rpmtw_platform_mod.close": "关闭",
"gui.rpmtw_platform_mod_open_link": "打开链接",
"machineTranslation.rpmtw_platform_mod.status.exception": "发生异常错误,状态码:%d。请稍后再试。",
"machineTranslation.rpmtw_platform_mod.status.failed": "翻译失败:%s",
"machineTranslation.rpmtw_platform_mod.status.rate_limit": "连接到Google翻译服务器已超过速率限制(429),请稍后再试。",
"machineTranslation.rpmtw_platform_mod.status.translating": "正在翻译..."
"machineTranslation.rpmtw_platform_mod.status.translating": "正在翻译...",
"messages.rpmtw_platform_mod.thanks": "§7-----------------------------------------------------\n§f感谢你使用RPMTW Platform Mod,若有任何问题或想和大家一起聊天欢迎加入我们的 Discord 社群。\n\n§f官方网址:%s\n§f官方 Discord 社群:%s\n\n§f此外,如要自定义此模组,可按下 %s 键进入设定界面。\n§7-----------------------------------------------------"
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"config.rpmtw_platform_mod.option.translate.unlocalized": "打開原文顯示",
"config.rpmtw_platform_mod.option.translate.unlocalized.@Tooltip": "額外顯示未本地化嘅內容,若遊戲語言為美國英語將不會起作用",
"config.rpmtw_platform_mod.option.translate.loadTranslateResourcePack": "載入翻譯資源包",
"config.rpmtw_platform_mod.option.translate.loadTranslateResourcePack.@Tooltip": "加載翻譯資源包翻譯模組同埋其他內容,只有在遊戲語言是繁體中文時先會啟用。",
"config.rpmtw_platform_mod.option.translate.autoToggleLanguage": "自動切換語言",
"config.rpmtw_platform_mod.option.translate.autoToggleLanguage.@Tooltip": "自動切換遊戲語言到電腦系統使用嘅語言",
"config.rpmtw_platform_mod.option.advanced": "進階設定",
"config.rpmtw_platform_mod.option.advanced.sendExceptionToSentry": "發送本 Mod 例外錯誤至 Sentry",
"config.rpmtw_platform_mod.option.advanced.sendExceptionToSentry.@Tooltip": "發送本 Mod 嘅例外錯誤至 Sentry 以協助我哋改善本 Mod。(所有資料將被去識別化,並且不會將其用於其他用途。)",
Expand Down Expand Up @@ -75,8 +78,10 @@
"gui.rpmtw_platform_mod.self": "自己",
"gui.rpmtw_platform_mod.send": "發送",
"gui.rpmtw_platform_mod.close": "關閉",
"gui.rpmtw_platform_mod_open_link": "開啓鏈結",
"machineTranslation.rpmtw_platform_mod.status.exception": "發生例外錯誤,狀態碼:%d,請稍候再試。",
"machineTranslation.rpmtw_platform_mod.status.failed": "翻譯失敗:%s",
"machineTranslation.rpmtw_platform_mod.status.rate_limit": "與 Google 翻譯伺服器嘅連接已超過速率限制(429)。請稍後再試。",
"machineTranslation.rpmtw_platform_mod.status.translating": "翻譯中..."
"machineTranslation.rpmtw_platform_mod.status.translating": "翻譯中...",
"messages.rpmtw_platform_mod.thanks": "§7-----------------------------------------------------\n§f感謝使用 RPMTW Platform Mod,如果你有任何問題,歡迎加入我地個 Discord 社群伺服器。\n\n§f官方網址:%s\n§f官方 Discord 社群:%s\n\n§f此外,如果你想要調整本模組的設定,按 %s 鍵能夠將其開啓。\n§7-----------------------------------------------------"
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minecraft_version=1.19.3
enabled_platforms=fabric,forge,quilt

archives_base_name=rpmtw-platform-mod-1.19.3
mod_version=1.5.4
mod_version=1.5.5
maven_group=com.rpmtw.rpmtw_platform_mod
architectury_version=7.0.64
# yarn_version=1.19.3+build.2
Expand Down

0 comments on commit 10f0bc2

Please sign in to comment.