Skip to content

Commit 21dd137

Browse files
committed
修复了数据模板计分板名称错误的问题,修复了nbt聊天组件缺少大括号的问题
1 parent 0b8f5ae commit 21dd137

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/main/kotlin/top/mcfpp/lang/DataTemplateObject.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ package top.mcfpp.lang
22

33
import net.querz.nbt.io.SNBTUtil
44
import net.querz.nbt.tag.CompoundTag
5-
import top.mcfpp.command.Command
65
import top.mcfpp.command.Commands
76
import top.mcfpp.lang.type.MCFPPDataTemplateType
87
import top.mcfpp.lang.type.MCFPPNBTType
98
import top.mcfpp.lang.type.MCFPPType
109
import top.mcfpp.lang.value.MCFPPValue
1110
import top.mcfpp.model.DataTemplate
1211
import top.mcfpp.model.Member
13-
import top.mcfpp.model.ObjectClass
1412
import top.mcfpp.model.field.CompoundDataField
1513
import top.mcfpp.model.function.Function
1614
import top.mcfpp.model.function.UnknownFunction
@@ -42,7 +40,7 @@ open class DataTemplateObject : Var<DataTemplateObject> {
4240
this.templateType = template
4341
this.name = identifier
4442
this.identifier = identifier
45-
instanceField = template.field.createInstance(this)
43+
instanceField = template.field.createDataTemplateInstance(this)
4644
}
4745

4846
/**
@@ -81,6 +79,9 @@ open class DataTemplateObject : Var<DataTemplateObject> {
8179
}
8280

8381
is DataTemplateObject -> {
82+
if(this is DataTemplateObjectConcrete){
83+
this.toDynamic(true)
84+
}
8485
assignCommand(b)
8586
return this
8687
}

src/main/kotlin/top/mcfpp/lib/ChatComponent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class KeybindChatComponent(val key: String) : ChatComponent() {
101101

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

src/main/kotlin/top/mcfpp/model/field/CompoundDataField.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package top.mcfpp.model.field
22

33
import org.jetbrains.annotations.Nullable
4+
import top.mcfpp.lang.DataTemplateObject
45
import top.mcfpp.model.CanSelectMember
56
import top.mcfpp.lang.Var
67
import top.mcfpp.lang.type.MCFPPType
@@ -215,9 +216,14 @@ class CompoundDataField : IFieldWithFunction, IFieldWithVar, IFieldWithType {
215216
}
216217
//endregion
217218

218-
fun createInstance(selector: CanSelectMember): CompoundDataField{
219+
fun createDataTemplateInstance(selector: DataTemplateObject): CompoundDataField{
219220
val re = CompoundDataField(this)
220-
re.allVars.forEach { it.parent = selector }
221+
re.allVars.forEach {
222+
it.parent = selector
223+
it.name = selector.identifier + "_" + it.identifier
224+
it.nbtPath.pathList.removeLast()
225+
it.nbtPath.memberIndex(it.identifier)
226+
}
221227
return re
222228
}
223229
}

0 commit comments

Comments
 (0)