Skip to content

Commit f1f683f

Browse files
committed
fix
1 parent feab7b4 commit f1f683f

File tree

8 files changed

+88
-38
lines changed

8 files changed

+88
-38
lines changed

src/main/java/com/github/zly2006/xbackup/gui/BMStyle.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.github.zly2006.xbackup.gui;
22
//? if poly_lib {
33

4-
import net.creeperhost.polylib.client.PolyPalette;
4+
/*import net.creeperhost.polylib.client.PolyPalette;
55
import net.creeperhost.polylib.client.modulargui.elements.*;
66
import net.creeperhost.polylib.client.modulargui.lib.Assembly;
77
import net.creeperhost.polylib.client.modulargui.lib.geometry.Axis;
@@ -62,4 +62,4 @@ public static int listEntryBackground(boolean hoveredOrSelected) {
6262
}
6363
}
6464
}
65-
//?}
65+
*///?}

src/main/java/com/github/zly2006/xbackup/gui/OptionDialog.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.github.zly2006.xbackup.gui;
22

33
//? if poly_lib {
4-
import net.creeperhost.polylib.client.PolyPalette;
4+
/*import net.creeperhost.polylib.client.PolyPalette;
55
import net.creeperhost.polylib.client.modulargui.ModularGui;
66
import net.creeperhost.polylib.client.modulargui.elements.GuiButton;
77
import net.creeperhost.polylib.client.modulargui.elements.GuiElement;
@@ -19,9 +19,9 @@
1919
import static net.creeperhost.polylib.client.modulargui.lib.geometry.GeoParam.*;
2020
import static net.minecraft.util.Formatting.GREEN;
2121
22-
/**
22+
/^*
2323
* Created by brandon3055 on 14/10/2023
24-
*/
24+
^/
2525
@Deprecated //TODO Add a more generic version of this to PolyLib
2626
public class OptionDialog extends GuiElement<OptionDialog> implements BackgroundRender {
2727
@@ -97,21 +97,21 @@ public void renderBehind(GuiRender render, double mouseX, double mouseY, float p
9797
render.toolTipBackground(xMin(), yMin(), xSize(), ySize(), 0xFF100010, 0xFF5000FF, 0xFF28007f);
9898
}
9999
100-
/**
100+
/^*
101101
* Opens a simple dialog that can be used to display information with an "Ok" button that will close the dialog.
102102
*
103103
* @param parent Can be any gui element (Will just be used to get the root element)
104104
* @param dialogText
105-
*/
105+
^/
106106
public static OptionDialog simpleInfoDialog(@NotNull GuiParent<?> parent, Text dialogText) {
107107
return simpleInfoDialog(parent, dialogText, () ->{});
108108
}
109109
110-
/**
110+
/^*
111111
* Opens a simple dialog that can be used to display information with an "Ok" button that will close the dialog.
112112
*
113113
* @param parent Can be any gui element (Will just be used to get the root element)
114-
*/
114+
^/
115115
public static OptionDialog simpleInfoDialog(@NotNull GuiParent<?> parent, Text dialogText, Runnable onAccepted) {
116116
OptionDialog dialog = new OptionDialog(parent.getModularGui().getRoot(),
117117
dialogText,
@@ -124,4 +124,4 @@ public static OptionDialog simpleInfoDialog(@NotNull GuiParent<?> parent, Text d
124124
}
125125
}
126126
127-
//?}
127+
*///?}

src/main/java/com/github/zly2006/xbackup/mixin/MixinSelectWorldScreen.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.github.zly2006.xbackup.BackupDatabaseService;
44
import com.github.zly2006.xbackup.XBackup;
55
//? if poly_lib {
6-
import com.github.zly2006.xbackup.gui.BackupsGui;
7-
//?}
6+
/*import com.github.zly2006.xbackup.gui.BackupsGui;
7+
*///?}
88
import net.fabricmc.loader.api.FabricLoader;
99
import net.minecraft.client.gui.DrawContext;
1010
import net.minecraft.client.gui.screen.Screen;
@@ -29,7 +29,7 @@ protected MixinSelectWorldScreen(Text title) {
2929
}
3030

3131
//? if poly_lib {
32-
@Unique
32+
/*@Unique
3333
ButtonWidget buttonWidget;
3434
3535
@Shadow
@@ -83,5 +83,5 @@ private void render(DrawContext context, int mouseX, int mouseY, float delta, Ca
8383
}
8484
}
8585
}
86-
//?}
86+
*///?}
8787
}

src/main/kotlin/com/github/zly2006/xbackup/Commands.kt

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import net.minecraft.text.Text
2828
import net.minecraft.util.Formatting
2929
import net.minecraft.util.Util
3030
import net.minecraft.util.WorldSavePath
31+
import java.net.URI
3132
import java.nio.file.Path
3233
import java.text.SimpleDateFormat
3334
import java.util.*
@@ -42,7 +43,8 @@ fun shortDateTimeText(time: Long): MutableText {
4243
SimpleDateFormat("HH:mm").apply {
4344
timeZone = TimeZone.getDefault()
4445
}.format(time)
45-
} else {
46+
}
47+
else {
4648
SimpleDateFormat("MM-dd HH:mm").apply {
4749
timeZone = TimeZone.getDefault()
4850
}.format(time)
@@ -77,21 +79,29 @@ fun sizeText(bytes: Long) = Text.literal(sizeToString(bytes)).formatted(Formatti
7779
fun MutableText.hover(literalText: MutableText) {
7880
styled {
7981
it.withHoverEvent(
80-
HoverEvent(
82+
//? if >=1.21.5 {
83+
HoverEvent.ShowText(literalText)
84+
//?} else {
85+
/*HoverEvent(
8186
HoverEvent.Action.SHOW_TEXT,
8287
literalText
8388
)
89+
*///?}
8490
)
8591
}
8692
}
8793

8894
fun MutableText.clickRun(cmd: String) {
8995
styled {
9096
it.withClickEvent(
91-
ClickEvent(
97+
//? if >=1.21.5 {
98+
ClickEvent.RunCommand(cmd)
99+
//?} else {
100+
/*ClickEvent(
92101
ClickEvent.Action.RUN_COMMAND,
93102
cmd
94103
)
104+
*///?}
95105
)
96106
}
97107
}
@@ -122,7 +132,7 @@ object Commands {
122132
}
123133

124134
literal("1") {
125-
requires = {false}
135+
requires = { false }
126136
executes {
127137
println(11)
128138
1
@@ -138,7 +148,12 @@ object Commands {
138148
if (XBackup.config.mirrorMode) {
139149
source.send(Text.literal("X Backup is in mirror mode").formatted(Formatting.GOLD))
140150
}
141-
source.send(Utils.translate("command.xb.background_task_status", XBackup.backgroundState.toString()))
151+
source.send(
152+
Utils.translate(
153+
"command.xb.background_task_status",
154+
XBackup.backgroundState.toString()
155+
)
156+
)
142157
if (XBackup.service.activeTaskProgress != -1) {
143158
source.send(Text.literal("云备份任务:${XBackup.service.activeTask} ${XBackup.service.activeTaskProgress}%"))
144159
source.send(networkStatsText())
@@ -195,7 +210,8 @@ object Commands {
195210
val backups = XBackup.service.listBackups(offset, 6)
196211
if (backups.isEmpty()) {
197212
it.source.send(Utils.translate("command.xb.no_backups_found"))
198-
} else {
213+
}
214+
else {
199215
it.source.send(Utils.translate("command.xb.backups"))
200216
backups.forEach { backup ->
201217
it.source.send(
@@ -227,10 +243,14 @@ object Commands {
227243
Utils.translate("command.xb.version", XBackup.MOD_VERSION + "(" + XBackup.GIT_COMMIT + ")")
228244
.styled {
229245
it.withClickEvent(
230-
ClickEvent(
246+
//? if >=1.21.5 {
247+
ClickEvent.OpenUrl(URI("https://github.com/zly2006/x-backup"))
248+
//?} else {
249+
/*ClickEvent(
231250
ClickEvent.Action.OPEN_URL,
232251
"https://github.com/zly2006/x-backup"
233252
)
253+
*///?}
234254
)
235255
}
236256
)
@@ -279,7 +299,8 @@ object Commands {
279299
}
280300
if (XBackup.config.mirrorMode) {
281301
registerMirrorMode(dispatcher)
282-
} else {
302+
}
303+
else {
283304
registerBackupMode(dispatcher)
284305
}
285306
}
@@ -356,10 +377,20 @@ object Commands {
356377
val id = result.backId
357378
if (XBackup.config.cloudBackupToken != null) {
358379
XBackup.service.launch(Dispatchers.Default) {
359-
it.source.server.broadcast(Utils.translate("command.xb.uploading_backup", backupIdText(id)))
380+
it.source.server.broadcast(
381+
Utils.translate(
382+
"command.xb.uploading_backup",
383+
backupIdText(id)
384+
)
385+
)
360386
XBackup.isBusy = false
361387
XBackup.service.cloudStorageProvider.uploadBackup(XBackup.service, id)
362-
it.source.server.broadcast(Utils.translate("command.xb.backup_uploaded", backupIdText(id)))
388+
it.source.server.broadcast(
389+
Utils.translate(
390+
"command.xb.backup_uploaded",
391+
backupIdText(id)
392+
)
393+
)
363394
}
364395
}
365396
}
@@ -389,7 +420,8 @@ object Commands {
389420
val id = IntegerArgumentType.getInteger(it, "id")
390421
val from = ColumnPosArgumentType.getColumnPos(it, "from")
391422
val to = ColumnPosArgumentType.getColumnPos(it, "to")
392-
val path = it.source.server.getSavePath(WorldSavePath.ROOT).toAbsolutePath().normalize()
423+
val path =
424+
it.source.server.getSavePath(WorldSavePath.ROOT).toAbsolutePath().normalize()
393425
val world = it.source.world
394426
val backup = getBackup(id)
395427
val minX = min(from.x, to.x)
@@ -414,6 +446,7 @@ object Commands {
414446
}
415447
false
416448
}
449+
417450
"mcc" -> {
418451
val x = p.fileName.toString().split(".")[1].toInt()
419452
val z = p.fileName.toString().split(".")[2].toInt()
@@ -422,6 +455,7 @@ object Commands {
422455
}
423456
false
424457
}
458+
425459
else -> false
426460
}
427461
}
@@ -501,7 +535,8 @@ object Commands {
501535
XBackup.ensureNotBusy(Dispatchers.IO) {
502536
it.source.send(Utils.translate("command.xb.uploading_backup", backupIdText(id)))
503537
XBackup.isBusy = false
504-
val result = XBackup.service.cloudStorageProvider.uploadBackup(XBackup.service, backup.id)
538+
val result =
539+
XBackup.service.cloudStorageProvider.uploadBackup(XBackup.service, backup.id)
505540
it.source.send(Utils.translate("command.xb.backup_uploaded", backupIdText(id)))
506541
}
507542
1
@@ -580,7 +615,8 @@ object Commands {
580615
val result = XBackup.service.check(backup)
581616
if (result) {
582617
it.source.send(Utils.translate("command.xb.backup_ok", backupIdText(id)))
583-
} else {
618+
}
619+
else {
584620
it.source.send(Utils.translate("command.xb.backup_corrupted", backupIdText(id)))
585621
}
586622
}
@@ -616,12 +652,22 @@ object Commands {
616652
executes {
617653
XBackup.config.backupInterval = it.getArgument("seconds", Int::class.java)
618654
XBackup.saveConfig()
619-
it.source.send(Utils.translate("command.xb.set_backup_interval", XBackup.config.backupInterval))
655+
it.source.send(
656+
Utils.translate(
657+
"command.xb.set_backup_interval",
658+
XBackup.config.backupInterval
659+
)
660+
)
620661
1
621662
}
622663
}
623664
executes {
624-
it.source.send(Utils.translate("command.xb.current_backup_interval", XBackup.config.backupInterval))
665+
it.source.send(
666+
Utils.translate(
667+
"command.xb.current_backup_interval",
668+
XBackup.config.backupInterval
669+
)
670+
)
625671
1
626672
}
627673
}

src/main/kotlin/com/github/zly2006/xbackup/XBackup.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ object XBackup : ModInitializer {
4242
lateinit var config: Config
4343
private val configPath = FabricLoader.getInstance().configDir.resolve("x-backup.config.json")
4444
val log = LoggerFactory.getLogger("XBackup")!!
45-
const val MOD_VERSION = /*$ mod_version*/ "0.3.10"
46-
const val GIT_COMMIT = /*$ git_commit*/ "b5c84f2"
47-
const val COMMIT_DATE = /*$ commit_date*/ "2025-02-13T13:10:50+08:00"
45+
const val MOD_VERSION = /*$ mod_version*/ "0.3.11"
46+
const val GIT_COMMIT = /*$ git_commit*/ "feab7b4"
47+
const val COMMIT_DATE = /*$ commit_date*/ "2025-04-16T13:51:49+08:00"
4848
var _service: BackupDatabaseService? = null
4949
val service get() = _service!!
5050
var server: MinecraftServer? = null

src/main/kotlin/com/github/zly2006/xbackup/cloud/OnedriveSupport.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,14 @@ class OnedriveSupport(
131131
service.activeTask = "Failed to get upload session: Free plan limit"
132132
XBackup.server?.broadcast(Utils.translate("message.xb.error.free_plan_limit").styled {
133133
it.withClickEvent(
134-
ClickEvent(
134+
//? if >=1.21.5 {
135+
ClickEvent.OpenUrl(URI("https://redenmc.com/x-backup/plans"))
136+
//?} else {
137+
/*ClickEvent(
135138
ClickEvent.Action.OPEN_URL,
136139
"https://redenmc.com/x-backup/plans"
137140
)
141+
*///?}
138142
)
139143
})
140144
throw DontRetryException(IllegalStateException("Free plan limit"))

src/main/kotlin/com/github/zly2006/xbackup/gui/BackupsGui.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.github.zly2006.xbackup.gui
22

33
//? if poly_lib {
4-
import com.github.zly2006.xbackup.BackupDatabaseService
4+
/*import com.github.zly2006.xbackup.BackupDatabaseService
55
import kotlinx.coroutines.runBlocking
66
import net.creeperhost.polylib.client.modulargui.ModularGui
77
import net.creeperhost.polylib.client.modulargui.ModularGuiScreen
@@ -240,6 +240,6 @@ class BackupsGui(private val service: BackupDatabaseService, val worldRoot: Path
240240
}
241241
}
242242
}
243-
//?} else {
244-
/*class BackupsGui
245-
*///?}
243+
*///?} else {
244+
class BackupsGui
245+
//?}

stonecutter.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ plugins {
1010
id("me.modmuss50.mod-publish-plugin") version "0.8.4" apply false
1111
id("org.ajoberstar.grgit") version "5.0.0-rc.3"
1212
}
13-
stonecutter active "1.21.1" /* [SC] DO NOT EDIT */
13+
stonecutter active "1.21.5" /* [SC] DO NOT EDIT */
1414

1515
subprojects {
1616
apply(plugin = "org.jetbrains.kotlin.jvm")

0 commit comments

Comments
 (0)