Skip to content

Commit

Permalink
Fix gamejointext not firing
Browse files Browse the repository at this point in the history
  • Loading branch information
sbxte committed Jan 5, 2024
1 parent ca0049e commit 953b772
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions core/src/mindustry/client/ClientLogic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package mindustry.client

import arc.*
import arc.Core.*
import arc.graphics.g2d.SortedSpriteBatch
import arc.graphics.g2d.*
import arc.math.geom.*
import arc.struct.*
import arc.util.*
Expand Down Expand Up @@ -55,20 +55,19 @@ class ClientLogic {
if (arg is UnitType) ui.unitPicker.pickUnit(arg)
switchTo = null
}
// Game join text after hh
if (settings.getString("gamejointext")?.isNotBlank() == true) {
val input = settings.getString("gamejointext").split("(?<!\\\\);".toRegex()) // Hacky way to allow escaping the split
val out = StringBuilder()
Log.debug("The split input: $input")
input.forEach { // Try running each bit as a command, this code is terribly inefficient but should get the job done so I don't care
val clean = if (!it.endsWith("\\\\;")) it.removeSuffix(";") else it // FINISHME: Remove the \ before the ; if needed
Log.debug("Input part: '$it' ('$clean')")
val res = ChatFragment.handleClientCommand(clean, false)
if (res.type == CommandHandler.ResponseType.noCommand) out.append(clean) // If the command doesn't exist we pass the text through to the output, otherwise we don't pass it to the output. this is kind of hacky but i don't care.
}
Log.debug("Sent message: $out")
Call.sendChatMessage(out.toString())
}
if (settings.getString("gamejointext")?.isNotBlank() == true) {
val input = settings.getString("gamejointext").split("(?<!\\\\);".toRegex()) // Hacky way to allow escaping the split
val out = StringBuilder()
Log.debug("The split input: $input")
input.forEach { // Try running each bit as a command, this code is terribly inefficient but should get the job done so I don't care
val clean = if (!it.endsWith("\\\\;")) it.removeSuffix(";") else it // FINISHME: Remove the \ before the ; if needed
Log.debug("Input part: '$it' ('$clean')")
val res = ChatFragment.handleClientCommand(clean, false)
if (res.type == CommandHandler.ResponseType.noCommand) out.append(clean) // If the command doesn't exist we pass the text through to the output, otherwise we don't pass it to the output. this is kind of hacky but i don't care.
}
Log.debug("Sent message: $out")
Call.sendChatMessage(out.toString())
}
}
}, .1F)
Expand Down

0 comments on commit 953b772

Please sign in to comment.