Skip to content

Commit

Permalink
command util: format clickable commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Bixilon committed May 6, 2024
1 parent af79d23 commit ae7a289
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
25 changes: 25 additions & 0 deletions src/main/java/de/bixilon/minosoft/terminal/CommandUtil.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Minosoft
* Copyright (C) 2020-2024 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/

package de.bixilon.minosoft.terminal

import de.bixilon.minosoft.data.text.TextComponent
import de.bixilon.minosoft.data.text.events.click.InternalCommandClickEvent
import de.bixilon.minosoft.data.text.formatting.color.ChatColors

object CommandUtil {

fun commandText(command: String): TextComponent {
return TextComponent("\"$command\"").clickEvent(InternalCommandClickEvent(command)).color(ChatColors.GRAY).underline()
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2023 Moritz Zwerger
* Copyright (C) 2020-2024 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
Expand All @@ -17,8 +17,7 @@ import de.bixilon.minosoft.commands.nodes.LiteralNode
import de.bixilon.minosoft.commands.stack.print.PrintTarget
import de.bixilon.minosoft.config.profile.profiles.other.OtherProfileManager
import de.bixilon.minosoft.data.text.BaseComponent
import de.bixilon.minosoft.data.text.TextComponent
import de.bixilon.minosoft.data.text.events.click.InternalCommandClickEvent
import de.bixilon.minosoft.terminal.CommandUtil.commandText
import de.bixilon.minosoft.updater.MinosoftUpdate
import de.bixilon.minosoft.updater.MinosoftUpdater
import de.bixilon.minosoft.updater.UpdateProgress
Expand Down Expand Up @@ -66,8 +65,8 @@ object UpdateCommand : Command {
} else {
print("There is a new update available:")
print("Version: ${it.name} (${it.id})")
print(BaseComponent("Run ", TextComponent("\"update notes\"").clickEvent(InternalCommandClickEvent("update notes")), " to see the release notes."))
print(BaseComponent("Run ", TextComponent("\"update update\"").clickEvent(InternalCommandClickEvent("update update")), " to download and update."))
print(BaseComponent("Run ", commandText("update notes"), " to see the release notes."))
print(BaseComponent("Run ", commandText("update update"), " to download and update."))
}
}
}
Expand Down

0 comments on commit ae7a289

Please sign in to comment.