Skip to content

Commit

Permalink
修复了数据模板计分板名称错误的问题,修复了nbt聊天组件缺少大括号的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Alumopper committed Aug 19, 2024
1 parent 92ec809 commit 4876527
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/main/kotlin/top/mcfpp/lang/DataTemplateObject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ package top.mcfpp.lang

import net.querz.nbt.io.SNBTUtil
import net.querz.nbt.tag.CompoundTag
import top.mcfpp.command.Command
import top.mcfpp.command.Commands
import top.mcfpp.lang.type.MCFPPDataTemplateType
import top.mcfpp.lang.type.MCFPPNBTType
import top.mcfpp.lang.type.MCFPPType
import top.mcfpp.lang.value.MCFPPValue
import top.mcfpp.model.DataTemplate
import top.mcfpp.model.Member
import top.mcfpp.model.ObjectClass
import top.mcfpp.model.field.CompoundDataField
import top.mcfpp.model.function.Function
import top.mcfpp.model.function.UnknownFunction
Expand Down Expand Up @@ -42,7 +40,7 @@ open class DataTemplateObject : Var<DataTemplateObject> {
this.templateType = template
this.name = identifier
this.identifier = identifier
instanceField = template.field.createInstance(this)
instanceField = template.field.createDataTemplateInstance(this)
}

/**
Expand Down Expand Up @@ -81,6 +79,9 @@ open class DataTemplateObject : Var<DataTemplateObject> {
}

is DataTemplateObject -> {
if(this is DataTemplateObjectConcrete){
this.toDynamic(true)
}
assignCommand(b)
return this
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/top/mcfpp/lib/ChatComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class KeybindChatComponent(val key: String) : ChatComponent() {

class NBTChatComponent(val nbt: NBTBasedData<*>, val interpret: Boolean = false, val separator: ChatComponent? = null) : ChatComponent() {
override fun toCommandPart(): Command {
return Command("{\"type\":\"nbt\",\"nbt\":\"").build(nbt.nbtPath.toCommandPart()).build("\",\"interpret\":$interpret, ${styleToString()}")
return Command("{\"type\":\"nbt\",\"nbt\":\"").build(nbt.nbtPath.toCommandPart(), false).build("\",\"interpret\":$interpret, ${styleToString()}}", false)
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/main/kotlin/top/mcfpp/model/field/CompoundDataField.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package top.mcfpp.model.field

import org.jetbrains.annotations.Nullable
import top.mcfpp.lang.DataTemplateObject
import top.mcfpp.model.CanSelectMember
import top.mcfpp.lang.Var
import top.mcfpp.lang.type.MCFPPType
Expand Down Expand Up @@ -215,9 +216,14 @@ class CompoundDataField : IFieldWithFunction, IFieldWithVar, IFieldWithType {
}
//endregion

fun createInstance(selector: CanSelectMember): CompoundDataField{
fun createDataTemplateInstance(selector: DataTemplateObject): CompoundDataField{
val re = CompoundDataField(this)
re.allVars.forEach { it.parent = selector }
re.allVars.forEach {
it.parent = selector
it.name = selector.identifier + "_" + it.identifier
it.nbtPath.pathList.removeLast()
it.nbtPath.memberIndex(it.identifier)
}
return re
}
}

0 comments on commit 4876527

Please sign in to comment.