Skip to content

Commit

Permalink
feat
Browse files Browse the repository at this point in the history
  • Loading branch information
zly2006 committed Jul 16, 2024
1 parent 450bfd9 commit 726b426
Showing 1 changed file with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package com.github.zly2006.enclosure.command

import com.github.zly2006.enclosure.Enclosure
import com.github.zly2006.enclosure.EnclosureArea
import com.github.zly2006.enclosure.ServerMain
import com.github.zly2006.enclosure.utils.Serializable2Text.SerializationSettings.Name
import com.github.zly2006.enclosure.utils.Serializable2Text.SerializationSettings.NameHover
import com.github.zly2006.enclosure.utils.checkPermission
import com.mojang.authlib.GameProfile
import me.lucko.fabric.api.permissions.v0.Options
Expand Down Expand Up @@ -89,7 +91,39 @@ fun BuilderScope<*>.registerForceLoad() {
}
literal("list") {
executes {
TODO()
var has = false
for (enclosure in ServerMain.getAllEnclosures()) {
if (enclosure.ticket != null) {
has = true
val time = buildString {
val ticks = enclosure.ticket!!.remainingTicks
val seconds = ticks / 20
val minutes = seconds / 60
val hours = minutes / 60
if (hours != 0) append(hours).append("h")
if (minutes % 60 != 0) append(minutes % 60).append("m")
if (seconds % 60 != 0) append(seconds % 60).append("s")
if (ticks % 20 != 0) append(ticks % 20).append("gt")
}
source.sendFeedback(
{
Text.literal("Force loading ")
.append(enclosure.serialize(NameHover, null))
.append(" with level ${enclosure.ticket!!.level}")
.append(" for $time ")
.append(" by ")
.append(
source.server.playerManager.getPlayer(enclosure.ticket!!.executor.id)?.styledDisplayName
?: Text.literal(enclosure.ticket!!.executor.name)
)
},
false
)
}
}
if (!has) {
source.sendFeedback({ Text.literal("No force loading tickets") }, false)
}
}
}
}
Expand Down

0 comments on commit 726b426

Please sign in to comment.