@@ -28,6 +28,7 @@ import net.minecraft.text.Text
2828import net.minecraft.util.Formatting
2929import net.minecraft.util.Util
3030import net.minecraft.util.WorldSavePath
31+ import java.net.URI
3132import java.nio.file.Path
3233import java.text.SimpleDateFormat
3334import 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
7779fun 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
8894fun 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 }
0 commit comments