Skip to content

Commit

Permalink
Merge branch 'v7' into v8
Browse files Browse the repository at this point in the history
  • Loading branch information
buthed010203 committed Oct 2, 2024
2 parents 80323a4 + edbf7b1 commit a52d123
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 18 deletions.
3 changes: 2 additions & 1 deletion core/assets/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ client.command.scanprocs.description = Scans every processor on the map, printin
client.command.marker.description = Adds a marker with specified name at (x, y) or your current position if x and y are not specified
client.command.marker.added = Successfully added a new marker at ({0}, {1})
client.command.js.description = Runs JS on the client
client.command.serverjs.description = Runs JS on the client as well as the server
client.command.kt.description = Runs Kotlin Script on the client
client.command.serverjs.description = Runs JS on the client as well as the server (runs !js & /js)
client.command.networking.description = Check the current status of the client networking system
client.command.fixpower.description = [accent]Connects all power grids (unless they're insulated or dioded)
client.command.fixpower.success = [accent]Successfully connected {0} power grids in {2} configs {1} grids remain
Expand Down
13 changes: 7 additions & 6 deletions core/assets/bundles/bundle_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ client.sortedplans = 距離で建設キューを正常に並べ替えました
client.freeze = 凍結
client.confirmfreeze = {0}[white]を凍結/解凍しますか?現在の凍結状態は次のとおりです:{1}
client.rollback.title = このプレイヤーの行動をロールバックしますか?
client.banreason.title = バン理由
client.banreason.body = このバンの理由を入力してください
client.banreason.title = BANの理由
client.banreason.body = このBANの理由を入力してください
client.setupcomms = 通信用に使用
client.setupcomms.confirm = このブロックを通信に使用しますか?
client.attemwarn = ({1}, {2}) に {0} によって配置されたアテム
Expand Down Expand Up @@ -229,6 +229,7 @@ client.command.scanprocs.description = マップ上のすべてのプロセッ
client.command.marker.description = 指定された名前のマーカーを (x, y) または現在の位置に追加します。x と y が指定されていない場合は現在の位置に追加されます
client.command.marker.added = ({0}, {1}) に新しいマーカーを追加しました
client.command.js.description = クライアントで JS を実行します
client.command.kt.description = クライアントで Kotlin を実行します
client.command.serverjs.description = サーバーとクライアントの両方で JS を実行します
client.command.networking.description = 現在のクライアントネットワーキングシステムの状態を確認します
client.command.fixpower.description = [accent]すべての電力グリッドを接続します(絶縁またはダイオード化されていない場合)
Expand Down Expand Up @@ -304,9 +305,9 @@ client.command.unmute.byid = [accent]プレイヤー ID {0}!
client.command.unmute.notmuted = [scarlet]そのプレイヤーはミュートされていません!
client.command.clearmutes.description = ミュートされたプレイヤーのリストをクリアします。
client.command.clearmutes.success = [accent]ミュートされたプレイヤーのリストをクリアしました!
client.command.autoohno.description = Runs the auto ohno procedure on fish servers
client.command.autoohno.running = [accent]Running auto ohno
client.command.seer.description = Clientside moderation utilities
client.command.autoohno.description = fishサーバーで自動ohno手順を実行します
client.command.autoohno.running = [accent]自動ohno実行中
client.command.seer.description = クライアント側のモデレーションユーティリティ
client.command.seer.disabled = [scarlet]設定で Seer を有効にしてください!
client.command.admin.description = モデレーションコマンドと設定にアクセスします
# End Client Commands
Expand Down Expand Up @@ -419,7 +420,7 @@ client.setting.showtoasts.name = トーストを表示
client.setting.showtoasts.description = トーストの表示を無効にします。ClashGonesのトローリングを止めるのに便利
client.setting.unloaderview.name = 搬出機の転送を表示
client.setting.customnullunloader.name = カスタムヌルアンローダー
client.setting.cursednesslevel.name = 呪い度
client.setting.cursednesslevel.name = 呪いレベル
client.setting.cursednesslevel.description = [scarlet]てんかん警告: OHNO以上の値\n(OHNOより上に対するてんかん警告)
client.setting.showcutscenes.name = カットシーンを表示
client.setting.logiclinkorder.name = リンク解除時にロジックリンク名を解放
Expand Down
25 changes: 19 additions & 6 deletions core/src/mindustry/client/Commands.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mindustry.client

import arc.*
import arc.files.*
import arc.func.*
import arc.graphics.*
import arc.math.*
Expand Down Expand Up @@ -202,11 +203,23 @@ fun setupCommands() {
Log.debug(out)
}

// Removed as the dependency was like 50MB. If i ever add this back, it will probably just download the jar when needed and then cache it between client builds so that each update isn't massive.
// val kts by lazy { ScriptEngineManager().getEngineByExtension("kts") }
// register("kts <code...>", Core.bundle.get("client.command.kts.description")) { args, player: Player ->
// player.sendMessage("[accent]${try{ kts.eval(args[0]) }catch(e: ScriptException){ e.message }}")
// }
var installingKt = false
// This command doesn't work unless the supporting jar file is on the class path
register("kt <code...>", Core.bundle.get("client.command.kts.description")) { args, player: Player ->
try { ScriptEngineHolder } catch (_: Throwable) { player.sendMessage("[scarlet]The current java install does not support scripting. Please install a full jvm"); return@register }

if (installingKt) player.sendMessage("[scarlet]Already installing kotlin script support")
if (ScriptEngineHolder.kts == null) ui.showConfirm("It seems that you do not have kotlin script support installed. Would you like to download it? (~60MB)") { // FINISHME: Bundle
installingKt = true
becontrol.downloadJar(
"https://github.com/mindustry-antigrief/kotlinScriptSupport/releases/latest/download/fooKotlinScriptSupport.jar",
Fi(ScriptEngineHolder::class.java.protectionDomain.codeSource.location.toURI().path).sibling("fooKotlinScriptSupport.jar"),
{ ui.showConfirm("Finished downloading kotlin script support. You must restart the game to use it. Restart now?") { restartGame() } },
{ player.sendMessage("[scarlet]Problem downloading kotlin script support ${it.printStackTrace()}") }
)
}
player.sendMessage("[accent]${try { ScriptEngineHolder.kts?.eval(args[0]) ?: return@register } catch (e: Throwable /* ScriptException */) { e.message }}")
}

register("/js <code...>", Core.bundle.get("client.command.serverjs.description")) { args, player ->
player.sendMessage("[accent]${mods.scripts.runConsole(args[0])}")
Expand Down Expand Up @@ -754,7 +767,7 @@ fun setupCommands() {
val current = ui.join.lastHost ?: return@register
if (current.group == null) current.group = ui.join.communityHosts.find { it == current } ?.group ?: return@register
switchTo = ui.join.communityHosts.filterTo(arrayListOf<Any>()) { it.group == current.group && it != current && (it.version == Version.build || Version.build == -1) }.apply { add(current); add(u) }
val first = switchTo!!.removeFirst() as Host
val first = switchTo!!.removeAt(0) as Host
NetClient.connect(first.address, first.port)
}

Expand Down
8 changes: 8 additions & 0 deletions core/src/mindustry/client/ScriptEngineHolder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package mindustry.client

import javax.script.ScriptEngine
import javax.script.ScriptEngineManager

object ScriptEngineHolder {
val kts: ScriptEngine? by lazy { ScriptEngineManager().getEngineByExtension("kts") }
}
13 changes: 9 additions & 4 deletions core/src/mindustry/client/antigrief/Moderation.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mindustry.client.antigrief

import arc.*
import arc.struct.*
import arc.util.*
import arc.util.serialization.*
import mindustry.*
Expand Down Expand Up @@ -101,15 +102,19 @@ class Moderation {
// Dont send in admin chat as it can get spammy
// if (info.timesJoined > 10 && info.timesKicked < 3) Vars.player.sendMessage("[accent]${player.name}[accent] has joined ${info.timesJoined-1} times before, they have been kicked ${info.timesKicked} times")
// else sendMessage("/a [scarlet]${player.name}[scarlet] has joined ${info.timesJoined-1} times before, they have been kicked ${info.timesKicked} times")
Vars.player.sendMessage("[scarlet]${player.name}[scarlet] has joined ${info.timesJoined-1} times before, they have been kicked ${info.timesKicked} times")
Vars.player.sendMessage("[scarlet]${player.name} [scarlet]has joined ${info.timesJoined-1} times before, they have been kicked ${info.timesKicked} times")
}

// These next three lines are the laziest way of deduplicating the messages but it works so we don't really care.
val ids = ObjectSet<String>()
val ips = ObjectSet<String>()
val names = ObjectSet<String>()
for (n in traces.size - 1 downTo 0) {
val i = traces[n]
if (i.trace.ip == info.uuid || i.trace.ip == info.ip) { // Update info
if (i.trace.uuid != info.uuid) Vars.player.sendMessage("[scarlet]${player.name}[scarlet] has changed UUID: ${i.trace.uuid} -> ${info.uuid}")
if (i.trace.ip != info.ip) Vars.player.sendMessage("[scarlet]${player.name}[scarlet] has changed IP: ${i.trace.ip} -> ${info.ip}")
if (i.name != player.name) Vars.player.sendMessage("[scarlet]${player.name}[scarlet] has changed name, was previously: ${i.name}")
if (i.trace.uuid != info.uuid && ids.add(i.trace.uuid)) Vars.player.sendMessage("[scarlet]${player.name} [scarlet]has changed UUID: ${i.trace.uuid} -> ${info.uuid}")
if (i.trace.ip != info.ip && ips.add(i.trace.ip)) Vars.player.sendMessage("[scarlet]${player.name} [scarlet]has changed IP: ${i.trace.ip} -> ${info.ip}")
if (i.name != player.name && names.add(i.name)) Vars.player.sendMessage("[scarlet]${player.name} [scarlet]has changed name, was previously: ${i.name}")
}
}

Expand Down
5 changes: 5 additions & 0 deletions core/src/mindustry/net/BeControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ public void showUpdateDialog(){
}
}

/** Convenience method to download a jar so that this doesn't need to get copied multiple times */
public void downloadJar(String url, Fi dest, Runnable done, Cons<Throwable> error){
download(url, dest, l -> {}, p -> {}, () -> false, done, error);
}

private void download(String furl, Fi dest, Intc length, Floatc progressor, Boolp canceled, Runnable done, Cons<Throwable> error){
mainExecutor.submit(() -> {
try{
Expand Down
2 changes: 1 addition & 1 deletion desktop/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ task dist(type: Jar, dependsOn: configurations.runtimeClasspath){

manifest{
attributes 'Main-Class': project.mainClassName
attributes 'Class-Path': "bcprov-jdk15on.jar bcpkix-jdk15on.jar bctls-jdk15on.jar bcutil-jdk15on.jar"
attributes 'Class-Path': "bcprov-jdk15on.jar bcpkix-jdk15on.jar bctls-jdk15on.jar bcutil-jdk15on.jar fooKotlinScriptSupport.jar"
}
}

Expand Down

0 comments on commit a52d123

Please sign in to comment.