diff --git a/resources/changelog/1.19.2-1.0.5.txt b/resources/changelog/1.19.2-1.0.5.txt new file mode 100644 index 00000000..a92d5e02 --- /dev/null +++ b/resources/changelog/1.19.2-1.0.5.txt @@ -0,0 +1,5 @@ +As always, don't forget to backup your world before updating! +Requires CyclopsCore version 1.19.0 or higher. + +Fixes: +* Fix NPE in ScriptingData if FileWatcher was not initialized diff --git a/resources/changelog/1.19.2-1.0.6.txt b/resources/changelog/1.19.2-1.0.6.txt new file mode 100644 index 00000000..6c2c44bb --- /dev/null +++ b/resources/changelog/1.19.2-1.0.6.txt @@ -0,0 +1,6 @@ +As always, don't forget to backup your world before updating! +Requires CyclopsCore version 1.19.0 or higher. + +Fixes: +* Fix null object values not being skipped to NBT, Closes #22 +* Fix delete not being highlighted as keyword, Closes #23 diff --git a/resources/changelog/1.20.1-1.0.5.txt b/resources/changelog/1.20.1-1.0.5.txt new file mode 100644 index 00000000..a92d5e02 --- /dev/null +++ b/resources/changelog/1.20.1-1.0.5.txt @@ -0,0 +1,5 @@ +As always, don't forget to backup your world before updating! +Requires CyclopsCore version 1.19.0 or higher. + +Fixes: +* Fix NPE in ScriptingData if FileWatcher was not initialized diff --git a/resources/changelog/1.20.1-1.0.6.txt b/resources/changelog/1.20.1-1.0.6.txt new file mode 100644 index 00000000..f30743ff --- /dev/null +++ b/resources/changelog/1.20.1-1.0.6.txt @@ -0,0 +1,7 @@ +As always, don't forget to backup your world before updating! +Requires CyclopsCore version 1.19.0 or higher. + +Fixes: +* Fix null object values not being skipped to NBT, Closes #22 +* Fix delete not being highlighted as keyword, Closes #23 +* Fix NPE in ScriptingData if FileWatcher was not initialized diff --git a/src/main/java/org/cyclops/integratedscripting/core/language/LanguageHandlerJavaScript.java b/src/main/java/org/cyclops/integratedscripting/core/language/LanguageHandlerJavaScript.java index 51a5abec..a5ce5568 100644 --- a/src/main/java/org/cyclops/integratedscripting/core/language/LanguageHandlerJavaScript.java +++ b/src/main/java/org/cyclops/integratedscripting/core/language/LanguageHandlerJavaScript.java @@ -42,6 +42,7 @@ public LanguageHandlerJavaScript() { this.tokenStyles = Maps.newHashMap(); this.tokenStyles.put("const", KEYWORD); + this.tokenStyles.put("delete", KEYWORD); this.tokenStyles.put("let", KEYWORD); this.tokenStyles.put("var", KEYWORD); this.tokenStyles.put("function", KEYWORD); diff --git a/src/main/java/org/cyclops/integratedscripting/evaluate/translation/translator/ValueTranslatorNbt.java b/src/main/java/org/cyclops/integratedscripting/evaluate/translation/translator/ValueTranslatorNbt.java index f662b964..0bfe48d4 100644 --- a/src/main/java/org/cyclops/integratedscripting/evaluate/translation/translator/ValueTranslatorNbt.java +++ b/src/main/java/org/cyclops/integratedscripting/evaluate/translation/translator/ValueTranslatorNbt.java @@ -123,8 +123,11 @@ public ValueTypeNbt.ValueNbt translateFromGraal(Context context, Value value, IE // In all other cases, assume we have a compound tag CompoundTag tag = new CompoundTag(); for (String memberKey : value.getMemberKeys()) { - IValue subValue = ValueTranslators.REGISTRY.translateFromGraal(context, value.getMember(memberKey), exceptionFactory, valueDeseralizationContext); - tag.put(memberKey, ValueTranslators.REGISTRY.translateToNbt(context, subValue, exceptionFactory)); + Value memberValue = value.getMember(memberKey); + if (!memberValue.isNull()) { + IValue subValue = ValueTranslators.REGISTRY.translateFromGraal(context, memberValue, exceptionFactory, valueDeseralizationContext); + tag.put(memberKey, ValueTranslators.REGISTRY.translateToNbt(context, subValue, exceptionFactory)); + } } return ValueTypeNbt.ValueNbt.of(tag); } diff --git a/src/test/java/org/cyclops/integratedscripting/evaluate/translation/ValueTranslatorsJavaScriptTests.java b/src/test/java/org/cyclops/integratedscripting/evaluate/translation/ValueTranslatorsJavaScriptTests.java index d9735dcc..31bb321e 100644 --- a/src/test/java/org/cyclops/integratedscripting/evaluate/translation/ValueTranslatorsJavaScriptTests.java +++ b/src/test/java/org/cyclops/integratedscripting/evaluate/translation/ValueTranslatorsJavaScriptTests.java @@ -350,6 +350,13 @@ public void testNbtCompound() throws EvaluationException { assertThat(listValue.getArrayElement(2), equalTo(CTX.asValue(3))); } + @Test + public void testNbtCompoundWithNullAndUndefined() throws EvaluationException { + CompoundTag compoundTag = new CompoundTag(); + compoundTag.put("a", StringTag.valueOf("bla")); + assertThat(ValueTranslators.REGISTRY.translateFromGraal(CTX, getJsValue("exports = { 'a': 'bla', 'b': null, 'c': undefined }"), EF, VDC), equalTo(ValueTypeNbt.ValueNbt.of(compoundTag))); + } + @Test public void testNbtCompoundBidirectional() throws EvaluationException { CompoundTag compoundTag = new CompoundTag();