mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
cli: use dummy parser as failover
This commit is contained in:
parent
de3800ba62
commit
11ac933cd5
@ -26,6 +26,7 @@ import de.bixilon.minosoft.commands.parser.minecraft.resource.ResourceParser
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.resource.tag.ResourceOrTagParser
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.score.holder.ScoreHolderParser
|
||||
import de.bixilon.minosoft.commands.parser.minecraft.target.TargetParser
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.dummy.DummyParser
|
||||
import de.bixilon.minosoft.data.registries.factory.DefaultFactory
|
||||
|
||||
object ArgumentParserFactories : DefaultFactory<ArgumentParserFactory<*>>(
|
||||
@ -42,6 +43,8 @@ object ArgumentParserFactories : DefaultFactory<ArgumentParserFactory<*>>(
|
||||
FloatRangeParser,
|
||||
IntRangeParser,
|
||||
|
||||
DummyParser,
|
||||
|
||||
ScoreHolderParser,
|
||||
ResourceParser,
|
||||
ResourceOrTagParser,
|
||||
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.commands.parser.minosoft.dummy
|
||||
|
||||
import de.bixilon.minosoft.commands.parser.ArgumentParser
|
||||
import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactory
|
||||
import de.bixilon.minosoft.commands.util.CommandReader
|
||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
object DummyParser : ArgumentParser<Any>, ArgumentParserFactory<DummyParser> {
|
||||
override val RESOURCE_LOCATION: ResourceLocation = "minosoft:dummy".toResourceLocation()
|
||||
override val examples: List<Any> = listOf("?")
|
||||
override val placeholder = ChatComponent.of("<?>")
|
||||
|
||||
override fun parse(reader: CommandReader): String {
|
||||
return "?"
|
||||
}
|
||||
|
||||
override fun getSuggestions(reader: CommandReader): List<Any> {
|
||||
return examples
|
||||
}
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer) = this
|
||||
}
|
@ -15,5 +15,4 @@ package de.bixilon.minosoft.commands.suggestion.factory
|
||||
|
||||
import de.bixilon.minosoft.data.registries.factory.DefaultFactory
|
||||
|
||||
object SuggestionFactories : DefaultFactory<SuggestionFactory<*>>(
|
||||
)
|
||||
object SuggestionFactories : DefaultFactory<SuggestionFactory<*>>()
|
||||
|
@ -51,8 +51,8 @@ class CommandsS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||
for ((childIndex, child) in it.withIndex()) {
|
||||
children[childIndex] = nodes[child] ?: throw IllegalArgumentException("Invalid child: $child for $childIndex")
|
||||
}
|
||||
node.redirect = children.unsafeCast()
|
||||
}
|
||||
builder.redirectNode?.let { node.redirect = nodes[it] }
|
||||
}
|
||||
|
||||
return nodes.unsafeCast()
|
||||
|
@ -19,6 +19,7 @@ import de.bixilon.minosoft.commands.nodes.NamedNode
|
||||
import de.bixilon.minosoft.commands.nodes.builder.ArgumentNodes
|
||||
import de.bixilon.minosoft.commands.nodes.builder.CommandNodeBuilder
|
||||
import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactories
|
||||
import de.bixilon.minosoft.commands.parser.minosoft.dummy.DummyParser
|
||||
import de.bixilon.minosoft.commands.suggestion.factory.SuggestionFactories
|
||||
import de.bixilon.minosoft.data.container.ItemStackUtil
|
||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||
@ -301,6 +302,7 @@ class PlayInByteBuffer : InByteBuffer {
|
||||
val parser = ArgumentParserFactories[parserName]
|
||||
if (parser == null) {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.VERBOSE) { "Can not find parser: $parserName" }
|
||||
builder.parser = DummyParser
|
||||
} else {
|
||||
builder.parser = parser.read(this)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user