mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 18:05:51 -04:00
parent
578e5fcf13
commit
d3ba3fcc2e
@ -13,7 +13,14 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.commands.stack.print
|
package de.bixilon.minosoft.commands.stack.print
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.text.BaseComponent
|
||||||
|
import de.bixilon.minosoft.data.text.TextComponent
|
||||||
|
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||||
|
|
||||||
interface PrintTarget {
|
interface PrintTarget {
|
||||||
|
|
||||||
fun print(message: Any)
|
fun print(message: Any)
|
||||||
|
fun error(message: Any) {
|
||||||
|
print(BaseComponent(TextComponent("[ERROR] ").bold().color(ChatColors.RED), message))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ class AccountProfile(
|
|||||||
var selected: Account? by BackingDelegate(get = { entries[_selected] }, set = { _selected = it?.id })
|
var selected: Account? by BackingDelegate(get = { entries[_selected] }, set = { _selected = it?.id })
|
||||||
|
|
||||||
init {
|
init {
|
||||||
this::_selected.observe(this) { this.selected = entries[_selected] }
|
this::_selected.observe(this) { this.selected = entries[it] }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,4 +38,8 @@ object OverworldEffects : DimensionEffects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val fog: Boolean get() = true
|
override val fog: Boolean get() = true
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return identifier.toString()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ class NodeTextInputElement(
|
|||||||
try {
|
try {
|
||||||
node.execute(CommandReader(value), stack)
|
node.execute(CommandReader(value), stack)
|
||||||
} catch (exception: Throwable) {
|
} catch (exception: Throwable) {
|
||||||
exception.message?.let { stack.print.print(TextComponent("Error: $it").color(ChatColors.RED)) }
|
exception.message?.let { stack.print.error(TextComponent(it).color(ChatColors.RED)) }
|
||||||
}
|
}
|
||||||
updateError(null)
|
updateError(null)
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ import de.bixilon.minosoft.gui.rendering.gui.gui.GUIBuilder
|
|||||||
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
import de.bixilon.minosoft.gui.rendering.gui.gui.LayoutedGUIElement
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.Menu
|
import de.bixilon.minosoft.gui.rendering.gui.gui.screen.menu.Menu
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionStates
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionStates
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.play.ClientActionC2SP
|
|
||||||
|
|
||||||
class RespawnMenu(guiRenderer: GUIRenderer) : Menu(guiRenderer) {
|
class RespawnMenu(guiRenderer: GUIRenderer) : Menu(guiRenderer) {
|
||||||
|
|
||||||
@ -43,7 +42,7 @@ class RespawnMenu(guiRenderer: GUIRenderer) : Menu(guiRenderer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun respawn() {
|
fun respawn() {
|
||||||
guiRenderer.connection.network.send(ClientActionC2SP(ClientActionC2SP.ClientActions.PERFORM_RESPAWN))
|
guiRenderer.connection.util.respawn()
|
||||||
canPop = true
|
canPop = true
|
||||||
guiRenderer.gui.pop()
|
guiRenderer.gui.pop()
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import de.bixilon.minosoft.modding.event.events.chat.ChatMessageSendEvent
|
|||||||
import de.bixilon.minosoft.modding.event.events.container.ContainerCloseEvent
|
import de.bixilon.minosoft.modding.event.events.container.ContainerCloseEvent
|
||||||
import de.bixilon.minosoft.protocol.ProtocolUtil.encodeNetwork
|
import de.bixilon.minosoft.protocol.ProtocolUtil.encodeNetwork
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
|
import de.bixilon.minosoft.protocol.packets.c2s.play.ClientActionC2SP
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.play.chat.ChatMessageC2SP
|
import de.bixilon.minosoft.protocol.packets.c2s.play.chat.ChatMessageC2SP
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.play.chat.CommandC2SP
|
import de.bixilon.minosoft.protocol.packets.c2s.play.chat.CommandC2SP
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.play.chat.SignedChatMessageC2SP
|
import de.bixilon.minosoft.protocol.packets.c2s.play.chat.SignedChatMessageC2SP
|
||||||
@ -149,4 +150,8 @@ class ConnectionUtil(
|
|||||||
connection.world.entities.clear(connection)
|
connection.world.entities.clear(connection)
|
||||||
connection.world.clear()
|
connection.world.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun respawn() {
|
||||||
|
connection.network.send(ClientActionC2SP(ClientActionC2SP.ClientActions.PERFORM_RESPAWN))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,14 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.terminal.commands
|
package de.bixilon.minosoft.terminal.commands
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.terminal.commands.connection.ActionCommand
|
||||||
|
import de.bixilon.minosoft.terminal.commands.connection.QueryCommand
|
||||||
import de.bixilon.minosoft.terminal.commands.connection.SayCommand
|
import de.bixilon.minosoft.terminal.commands.connection.SayCommand
|
||||||
import de.bixilon.minosoft.terminal.commands.rendering.ReloadCommand
|
import de.bixilon.minosoft.terminal.commands.rendering.ReloadCommand
|
||||||
|
|
||||||
object Commands {
|
object Commands {
|
||||||
val COMMANDS: List<Command> = listOf(
|
val COMMANDS: List<Command> = listOf(
|
||||||
HelpCommand,
|
HelpCommand,
|
||||||
SayCommand,
|
|
||||||
ConnectionManageCommand,
|
ConnectionManageCommand,
|
||||||
AccountManageCommand,
|
AccountManageCommand,
|
||||||
ReloadCommand,
|
ReloadCommand,
|
||||||
@ -29,5 +30,9 @@ object Commands {
|
|||||||
CrashCommand, DumpCommand,
|
CrashCommand, DumpCommand,
|
||||||
|
|
||||||
AboutCommand,
|
AboutCommand,
|
||||||
|
|
||||||
|
|
||||||
|
SayCommand,
|
||||||
|
ActionCommand, QueryCommand,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 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.commands.connection
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.commands.nodes.LiteralNode
|
||||||
|
import de.bixilon.minosoft.commands.stack.CommandStack
|
||||||
|
|
||||||
|
object ActionCommand : ConnectionCommand {
|
||||||
|
override var node = LiteralNode("action", setOf("do"))
|
||||||
|
.addChild(LiteralNode("respawn", executor = { it.respawn() }))
|
||||||
|
|
||||||
|
|
||||||
|
private fun CommandStack.respawn() {
|
||||||
|
if (connection.player.healthCondition.hp > 0.0f) {
|
||||||
|
return print.error("You are still alive!")
|
||||||
|
}
|
||||||
|
print.print("Performing respawn...")
|
||||||
|
connection.util.respawn()
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 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.commands.connection
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.commands.nodes.LiteralNode
|
||||||
|
import de.bixilon.minosoft.data.registries.effects.attributes.MinecraftAttributes
|
||||||
|
|
||||||
|
object QueryCommand : ConnectionCommand {
|
||||||
|
override var node = LiteralNode("query")
|
||||||
|
.addChild(LiteralNode("health", executor = { it.print.print("Health §c${it.connection.player.healthCondition.hp}§r/§c${it.connection.player.attributes[MinecraftAttributes.MAX_HEALTH]}, hunger=${it.connection.player.healthCondition.hunger}") }))
|
||||||
|
.addChild(LiteralNode("xp", setOf("experience", "exp"), executor = { it.print.print("Experience: level §e${it.connection.player.experienceCondition.level}") }))
|
||||||
|
.addChild(LiteralNode("dimension", executor = { it.print.print("Dimension: §e${it.connection.world.dimension.effects}") }))
|
||||||
|
}
|
@ -17,6 +17,6 @@ import de.bixilon.minosoft.commands.nodes.ChatNode
|
|||||||
import de.bixilon.minosoft.commands.nodes.LiteralNode
|
import de.bixilon.minosoft.commands.nodes.LiteralNode
|
||||||
|
|
||||||
object SayCommand : ConnectionCommand {
|
object SayCommand : ConnectionCommand {
|
||||||
override var node = LiteralNode("say", setOf("chat", "send", "write"))
|
override var node = LiteralNode("say", setOf("chat", "send"))
|
||||||
.addChild(ChatNode("message", allowCLI = false))
|
.addChild(ChatNode("message", allowCLI = false))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user