Skip to content

Commit 3bb2da2

Browse files
committed
Merge remote-tracking branch 'origin/master-1.19-lts' into master-1.20-lts
2 parents dd80ae8 + a033199 commit 3bb2da2

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
As always, don't forget to backup your world before updating!
2+
Requires CyclopsCore version 1.19.0 or higher.
3+
4+
Fixes:
5+
* Fix NPE in ScriptingData if FileWatcher was not initialized
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
As always, don't forget to backup your world before updating!
2+
Requires CyclopsCore version 1.19.0 or higher.
3+
4+
Fixes:
5+
* Fix null object values not being skipped to NBT, Closes #22
6+
* Fix delete not being highlighted as keyword, Closes #23

src/main/java/org/cyclops/integratedscripting/core/language/LanguageHandlerJavaScript.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public LanguageHandlerJavaScript() {
4242
this.tokenStyles = Maps.newHashMap();
4343

4444
this.tokenStyles.put("const", KEYWORD);
45+
this.tokenStyles.put("delete", KEYWORD);
4546
this.tokenStyles.put("let", KEYWORD);
4647
this.tokenStyles.put("var", KEYWORD);
4748
this.tokenStyles.put("function", KEYWORD);

src/main/java/org/cyclops/integratedscripting/evaluate/translation/translator/ValueTranslatorNbt.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,11 @@ public ValueTypeNbt.ValueNbt translateFromGraal(Context context, Value value, IE
122122
// In all other cases, assume we have a compound tag
123123
CompoundTag tag = new CompoundTag();
124124
for (String memberKey : value.getMemberKeys()) {
125-
IValue subValue = ValueTranslators.REGISTRY.translateFromGraal(context, value.getMember(memberKey), exceptionFactory);
126-
tag.put(memberKey, ValueTranslators.REGISTRY.translateToNbt(context, subValue, exceptionFactory));
125+
Value memberValue = value.getMember(memberKey);
126+
if (!memberValue.isNull()) {
127+
IValue subValue = ValueTranslators.REGISTRY.translateFromGraal(context, memberValue, exceptionFactory);
128+
tag.put(memberKey, ValueTranslators.REGISTRY.translateToNbt(context, subValue, exceptionFactory));
129+
}
127130
}
128131
return ValueTypeNbt.ValueNbt.of(tag);
129132
}

src/test/java/org/cyclops/integratedscripting/evaluate/translation/ValueTranslatorsJavaScriptTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,13 @@ public void testNbtCompound() throws EvaluationException {
350350
assertThat(listValue.getArrayElement(2), equalTo(CTX.asValue(3)));
351351
}
352352

353+
@Test
354+
public void testNbtCompoundWithNullAndUndefined() throws EvaluationException {
355+
CompoundTag compoundTag = new CompoundTag();
356+
compoundTag.put("a", StringTag.valueOf("bla"));
357+
assertThat(ValueTranslators.REGISTRY.translateFromGraal(CTX, getJsValue("exports = { 'a': 'bla', 'b': null, 'c': undefined }"), EF), equalTo(ValueTypeNbt.ValueNbt.of(compoundTag)));
358+
}
359+
353360
@Test
354361
public void testNbtCompoundBidirectional() throws EvaluationException {
355362
CompoundTag compoundTag = new CompoundTag();

0 commit comments

Comments
 (0)