-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Support animating inventory on title change
chore: Add example showcasing animated title
- Loading branch information
Showing
7 changed files
with
73 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
kotlin.code.style=official | ||
group=com.mineinabyss | ||
version=0.10 | ||
idofrontVersion=0.24.0 | ||
idofrontVersion=0.24.1 |
31 changes: 27 additions & 4 deletions
31
guiy-example/src/main/kotlin/com/mineinabyss/guiy/example/GuiyCommands.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,41 @@ | ||
package com.mineinabyss.guiy.example | ||
|
||
import com.mineinabyss.guiy.example.gui.AnimatedTitle | ||
import com.mineinabyss.guiy.example.gui.MainMenu | ||
import com.mineinabyss.guiy.inventory.guiy | ||
import com.mineinabyss.idofront.commands.execution.IdofrontCommandExecutor | ||
import com.mineinabyss.idofront.commands.extensions.actions.playerAction | ||
import org.bukkit.command.Command | ||
import org.bukkit.command.CommandSender | ||
import org.bukkit.command.TabCompleter | ||
|
||
class GuiyCommands(val plugin: GuiyExamplePlugin) : IdofrontCommandExecutor() { | ||
class GuiyCommands(val plugin: GuiyExamplePlugin) : IdofrontCommandExecutor(), TabCompleter { | ||
override val commands = commands(plugin) { | ||
"guiyexample" { | ||
playerAction { | ||
guiy { | ||
MainMenu(player) | ||
"creative" { | ||
playerAction { | ||
guiy { | ||
MainMenu(player) | ||
} | ||
} | ||
} | ||
"animated" { | ||
playerAction { | ||
guiy { | ||
AnimatedTitle(player) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun onTabComplete( | ||
sender: CommandSender, | ||
command: Command, | ||
label: String, | ||
args: Array<out String>? | ||
): List<String> = | ||
if (command.name == "guiyexample") | ||
listOf("creative", "animated") | ||
else listOf() | ||
} |
28 changes: 28 additions & 0 deletions
28
guiy-example/src/main/kotlin/com/mineinabyss/guiy/example/gui/AnimatedTitle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.mineinabyss.guiy.example.gui | ||
|
||
import androidx.compose.runtime.* | ||
import com.mineinabyss.guiy.components.canvases.Chest | ||
import com.mineinabyss.guiy.inventory.LocalGuiyOwner | ||
import com.mineinabyss.guiy.modifiers.Modifier | ||
import com.mineinabyss.guiy.modifiers.fillMaxHeight | ||
import kotlinx.coroutines.delay | ||
import org.bukkit.entity.Player | ||
|
||
@Composable | ||
fun AnimatedTitle(player: Player) { | ||
val owner = LocalGuiyOwner.current | ||
var seconds by remember { mutableStateOf(0) } | ||
LaunchedEffect(Unit) { | ||
while (true) { | ||
delay(1000) | ||
seconds++ | ||
} | ||
} | ||
Chest( | ||
setOf(player), | ||
"<red>${seconds}s have passed!", | ||
onClose = { owner.exit() }, | ||
modifier = Modifier.fillMaxHeight() | ||
) { | ||
} | ||
} |
4 changes: 1 addition & 3 deletions
4
guiy-example/src/main/kotlin/com/mineinabyss/guiy/example/gui/MainMenu.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters