feat: error handling

This commit is contained in:
Skye 2023-05-14 21:47:21 +09:00
parent 017d5f88f0
commit dfb6935b7b
Signed by: me
GPG key ID: 0104BC05F41B77B8
3 changed files with 24 additions and 2 deletions

View file

@ -86,6 +86,26 @@ class E4mcRelayHandler: WebSocketClient(URI(System.getProperty("vg.skye.e4mc_min
override fun onError(ex: java.lang.Exception) { override fun onError(ex: java.lang.Exception) {
ex.printStackTrace() ex.printStackTrace()
//#if FABRIC==1
val isClient = FabricLoader.getInstance().environmentType.equals(EnvType.CLIENT)
//#else
//$$ val isClient = FMLLoader.getDist().isClient
//#endif
if (isClient) {
try {
MinecraftClient.getInstance().inGameHud.chatHud.addMessage(
//#if MC>=11900
Text.translatable("text.e4mc_minecraft.error")
//#elseif FABRIC==1
//$$ TranslatableText("text.e4mc_minecraft.error")
//#else
//$$ TranslatableComponent("text.e4mc_minecraft.error")
//#endif
)
} catch (e: Exception) {
e.printStackTrace()
}
}
} }
private fun handleDomainAssigned(json: JsonObject) { private fun handleDomainAssigned(json: JsonObject) {

View file

@ -2,5 +2,6 @@
"text.e4mc_minecraft.domainAssigned": "Local game hosted on domain [%s]", "text.e4mc_minecraft.domainAssigned": "Local game hosted on domain [%s]",
"text.e4mc_minecraft.closeServer": "Local game no longer publicly hosted", "text.e4mc_minecraft.closeServer": "Local game no longer publicly hosted",
"text.e4mc_minecraft.serverAlreadyClosed": "Local game not publicly hosted", "text.e4mc_minecraft.serverAlreadyClosed": "Local game not publicly hosted",
"text.e4mc_minecraft.clickToStop": " (Click here to stop)" "text.e4mc_minecraft.clickToStop": " (Click here to stop)",
"text.e4mc_minecraft.error": "An error occurred in e4mc"
} }

View file

@ -2,5 +2,6 @@
"text.e4mc_minecraft.domainAssigned": "로컬 게임을 도메인 [%s]에서 호스트합니다", "text.e4mc_minecraft.domainAssigned": "로컬 게임을 도메인 [%s]에서 호스트합니다",
"text.e4mc_minecraft.closeServer": "로컬 게임이 더이상 공개되지 않습니다", "text.e4mc_minecraft.closeServer": "로컬 게임이 더이상 공개되지 않습니다",
"text.e4mc_minecraft.serverAlreadyClosed": "로컬 게임이 이미 공개중이 아닙니다", "text.e4mc_minecraft.serverAlreadyClosed": "로컬 게임이 이미 공개중이 아닙니다",
"text.e4mc_minecraft.clickToStop": " (멉추려면 여기를 클릭하세요)" "text.e4mc_minecraft.clickToStop": " (멉추려면 여기를 클릭하세요)",
"text.e4mc_minecraft.error": "e4mc에서 오류가 발생했습니다."
} }