Skip to content

Commit

Permalink
Finished main /dml-refabricated(part of #123)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligabi1 committed Mar 6, 2023
1 parent 92dded0 commit 297b818
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
38 changes: 33 additions & 5 deletions base/src/main/kotlin/dev/nathanpb/dml/command/DMLCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import net.minecraft.command.CommandRegistryAccess
import net.minecraft.server.command.CommandManager.RegistrationEnvironment
import net.minecraft.server.command.CommandManager.literal
import net.minecraft.server.command.ServerCommandSource
import net.minecraft.text.MutableText
import net.minecraft.text.Text
import net.minecraft.text.*
import net.minecraft.util.Formatting


Expand All @@ -33,7 +32,27 @@ class DMLCommand: CommandRegistrationCallback {

// Main Command
.executes {
it.source.sendMessage(Text.literal("Hello, Brigadier!"))
val metadata = FabricLoader.getInstance().getModContainer("dml-refabricated").get().metadata
val authors = metadata.authors.filter { person -> person.name != "IterationFunk" }.joinToString {
person -> person.name
}
val contributors = metadata.contributors.joinToString {
person -> person.name
}

it.source.sendMessage(coloredText("-= ", true).append(coloredText("${metadata.name} v${metadata.version}")).append(coloredText(" =-", true)))
it.source.sendMessage(coloredText("Original mod by ").append(coloredText("IterationFunk", true)))
it.source.sendMessage(coloredText("Reimagining/port by ").append(coloredText(authors, true)))
it.source.sendMessage(coloredText("With contributions of ").append(coloredText(contributors, true)))
it.source.sendMessage(Text.empty())
it.source.sendMessage(
hyperlink("CurseForge", "https://curseforge.com/minecraft/mc-mods/deep-mob-learning-refabricated", 0xF46434).append(
" ").append(
hyperlink("Modrinth", "https://modrinth.com/mod/deep-mob-learning-refabricated", 0x1CD368)).append(
" ").append(
hyperlink("Issue Tracker", "https://github.com/CafeteriaGuild/DeepMobLearning-Refabricated/issues", 0x6E5494))
)


return@executes 1
})
Expand All @@ -56,7 +75,16 @@ class DMLCommand: CommandRegistrationCallback {
return coloredText(message, false)
}

private fun coloredText(message: String, translatable: Boolean): MutableText {
return (if(translatable) Text.translatable(message) else Text.literal(message)).styled { RenderUtils.STYLE }
private fun coloredText(message: String, altStyle: Boolean): MutableText {
return Text.literal(message).styled { if(altStyle) RenderUtils.ALT_STYLE else RenderUtils.STYLE }
}

private fun hyperlink(title: String, url: String, color: Int): MutableText {
return Text.literal("[$title]").styled { Style.EMPTY
.withClickEvent(ClickEvent(ClickEvent.Action.OPEN_URL, url))
.withHoverEvent(HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal("Click to open link").styled { Style.EMPTY.withColor(color) }))
.withColor(color)
.withBold(true)
}
}
}
2 changes: 2 additions & 0 deletions base/src/main/kotlin/dev/nathanpb/dml/utils/RenderUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class RenderUtils {

companion object {
private const val TITLE_COLOR: Int = 0x04FCC4
private const val ALT_TITLE_COLOR: Int = 0x62D8FF
val STYLE: Style = Style.EMPTY.withColor(TITLE_COLOR)
val ALT_STYLE: Style = Style.EMPTY.withColor(ALT_TITLE_COLOR)
val DEFAULT_BACKGROUND_PAINTER: NinePatchBackgroundPainter by lazy {
BackgroundPainter.createNinePatch(identifier("textures/gui/dml_background_painter.png"))
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"name": "Deep Mob Learning: Refabricated",
"description": "A revitalized version of IterationFunk's server friendly mob loot acquisition mod, now on Fabric!",
"authors": ["NathanPB", "Luligabi", "IterationFunk"],
"contributors": ["ProjectET"],
"contact": {
"homepage": "https://www.curseforge.com/minecraft/mc-mods/deep-mob-learning-refabricated",
"repo": "https://github.com/CafeteriaGuild/DeepMobLearning-Refabricated",
Expand Down

0 comments on commit 297b818

Please sign in to comment.