diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index c56546da49..fd4850a5d5 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -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 diff --git a/core/assets/bundles/bundle_ja.properties b/core/assets/bundles/bundle_ja.properties index a3a13ad5a8..6c4c1e52cb 100644 --- a/core/assets/bundles/bundle_ja.properties +++ b/core/assets/bundles/bundle_ja.properties @@ -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} によって配置されたアテム @@ -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]すべての電力グリッドを接続します(絶縁またはダイオード化されていない場合) @@ -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 @@ -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 = リンク解除時にロジックリンク名を解放 diff --git a/core/src/mindustry/client/Commands.kt b/core/src/mindustry/client/Commands.kt index fa076340c5..1b2dc67e02 100644 --- a/core/src/mindustry/client/Commands.kt +++ b/core/src/mindustry/client/Commands.kt @@ -1,6 +1,7 @@ package mindustry.client import arc.* +import arc.files.* import arc.func.* import arc.graphics.* import arc.math.* @@ -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 ", 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 ", 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 ", Core.bundle.get("client.command.serverjs.description")) { args, player -> player.sendMessage("[accent]${mods.scripts.runConsole(args[0])}") @@ -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()) { 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) } diff --git a/core/src/mindustry/client/ScriptEngineHolder.kt b/core/src/mindustry/client/ScriptEngineHolder.kt new file mode 100644 index 0000000000..f4149d021e --- /dev/null +++ b/core/src/mindustry/client/ScriptEngineHolder.kt @@ -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") } +} \ No newline at end of file diff --git a/core/src/mindustry/client/antigrief/Moderation.kt b/core/src/mindustry/client/antigrief/Moderation.kt index ecbc54562b..03f7f34319 100644 --- a/core/src/mindustry/client/antigrief/Moderation.kt +++ b/core/src/mindustry/client/antigrief/Moderation.kt @@ -1,6 +1,7 @@ package mindustry.client.antigrief import arc.* +import arc.struct.* import arc.util.* import arc.util.serialization.* import mindustry.* @@ -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() + val ips = ObjectSet() + val names = ObjectSet() 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}") } } diff --git a/core/src/mindustry/net/BeControl.java b/core/src/mindustry/net/BeControl.java index 005c4066a7..0426c82a1c 100644 --- a/core/src/mindustry/net/BeControl.java +++ b/core/src/mindustry/net/BeControl.java @@ -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 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 error){ mainExecutor.submit(() -> { try{ diff --git a/desktop/build.gradle b/desktop/build.gradle index f88865db83..7a98fca03b 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -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" } }