From a292b6a14c59cc6eb9fb6433eb9fc36a97183eab Mon Sep 17 00:00:00 2001 From: cheeezburga <47320303+cheeezburga@users.noreply.github.com> Date: Sat, 4 May 2024 02:30:19 +1000 Subject: [PATCH 01/13] Adds some fire resistant syntax --- .../conditions/CondIsFireResistant.java | 52 +++++++++++++ .../njol/skript/effects/EffFireResistant.java | 77 +++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java create mode 100644 src/main/java/ch/njol/skript/effects/EffFireResistant.java diff --git a/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java b/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java new file mode 100644 index 00000000000..0946290320c --- /dev/null +++ b/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java @@ -0,0 +1,52 @@ +/** + * This file is part of Skript. + * + * Skript 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. + * + * Skript 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 Skript. If not, see . + * + * Copyright Peter Güttinger, SkriptLang team and contributors + */ +package ch.njol.skript.conditions; + +import ch.njol.skript.aliases.ItemType; +import ch.njol.skript.conditions.base.PropertyCondition; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.RequiredPlugins; +import ch.njol.skript.doc.Since; + +@Name("Is Fire Resistant") +@Description("Checks whether an item is fire resistant.") +@Examples({ + "if player's tool is fire resistant:", + "if {_items::*} aren't resistant to fire:" +}) +@RequiredPlugins("Spigot 1.20.5+") +@Since("INSERT VERSION") +public class CondIsFireResistant extends PropertyCondition { + + static { + PropertyCondition.register(CondIsFireResistant.class, "(fire resistant|resistant to fire)", "itemtypes"); + } + + @Override + public boolean check(ItemType item) { + return item.getItemMeta().isFireResistant(); + } + + @Override + public String getPropertyName() { + return "(fire resistant|resistant to fire)"; + } +} diff --git a/src/main/java/ch/njol/skript/effects/EffFireResistant.java b/src/main/java/ch/njol/skript/effects/EffFireResistant.java new file mode 100644 index 00000000000..b9c4d971fba --- /dev/null +++ b/src/main/java/ch/njol/skript/effects/EffFireResistant.java @@ -0,0 +1,77 @@ +/** + * This file is part of Skript. + * + * Skript 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. + * + * Skript 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 Skript. If not, see . + * + * Copyright Peter Güttinger, SkriptLang team and contributors + */ +package ch.njol.skript.effects; + +import ch.njol.skript.Skript; +import ch.njol.skript.aliases.ItemType; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.RequiredPlugins; +import ch.njol.skript.doc.Since; +import ch.njol.skript.lang.Effect; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.util.Kleenean; +import org.bukkit.event.Event; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.Nullable; + +@Name("Make Fire Resistant") +@Description("Makes items fire resistant.") +@Examples({ + "make player's tool fire resistant:", + "make {_items::*} not resistant to fire" +}) +@RequiredPlugins("Spigot 1.20.5+") +@Since("INSERT VERSION") +public class EffFireResistant extends Effect { + + static { + Skript.registerEffect(EffFireResistant.class, + "make %itemtypes% [:not] (fire resistant|resistant to fire)" + ); + } + + @SuppressWarnings("NotNullFieldNotInitialized") + private Expression items; + private boolean not; + + @Override + @SuppressWarnings("unchecked") + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + items = (Expression) exprs[0]; + not = parseResult.hasTag("not"); + return true; + } + + @Override + protected void execute(Event event) { + for (ItemType item : this.items.getArray(event)) { + ItemMeta meta = item.getItemMeta(); + meta.setFireResistant(!not); + item.setItemMeta(meta); + } + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + return "make " + items.toString(event, debug) + (not ? " not" : "") + " fire resistant"; + } +} From 11d64b0f9091503bf9b46eca602c99aedac1a3fe Mon Sep 17 00:00:00 2001 From: cheeezburga <47320303+cheeezburga@users.noreply.github.com> Date: Sat, 4 May 2024 02:47:26 +1000 Subject: [PATCH 02/13] Fix property name method --- .../java/ch/njol/skript/conditions/CondIsFireResistant.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java b/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java index 0946290320c..2255349b938 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java @@ -47,6 +47,6 @@ public boolean check(ItemType item) { @Override public String getPropertyName() { - return "(fire resistant|resistant to fire)"; + return "fire resistant"; } } From 2ed8ca948afcfb67a30fba908b449bda4a537b3f Mon Sep 17 00:00:00 2001 From: cheeezburga <47320303+cheeezburga@users.noreply.github.com> Date: Sat, 4 May 2024 03:39:32 +1000 Subject: [PATCH 03/13] Adds expression and method checks - Added an expression to create a copy of an itemtype with or without fire resistance - Added method checks to only register the syntax if the appropriate method exists --- .../conditions/CondIsFireResistant.java | 5 +- .../njol/skript/effects/EffFireResistant.java | 5 +- .../expressions/ExprWithFireResistance.java | 66 +++++++++++++++++++ 3 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java diff --git a/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java b/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java index 2255349b938..72dea15e864 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java @@ -18,6 +18,7 @@ */ package ch.njol.skript.conditions; +import ch.njol.skript.Skript; import ch.njol.skript.aliases.ItemType; import ch.njol.skript.conditions.base.PropertyCondition; import ch.njol.skript.doc.Description; @@ -25,6 +26,7 @@ import ch.njol.skript.doc.Name; import ch.njol.skript.doc.RequiredPlugins; import ch.njol.skript.doc.Since; +import org.bukkit.inventory.meta.ItemMeta; @Name("Is Fire Resistant") @Description("Checks whether an item is fire resistant.") @@ -37,7 +39,8 @@ public class CondIsFireResistant extends PropertyCondition { static { - PropertyCondition.register(CondIsFireResistant.class, "(fire resistant|resistant to fire)", "itemtypes"); + if (Skript.methodExists(ItemMeta.class, "isFireResistant")) + PropertyCondition.register(CondIsFireResistant.class, "(fire resistant|resistant to fire)", "itemtypes"); } @Override diff --git a/src/main/java/ch/njol/skript/effects/EffFireResistant.java b/src/main/java/ch/njol/skript/effects/EffFireResistant.java index b9c4d971fba..4bb6ae66445 100644 --- a/src/main/java/ch/njol/skript/effects/EffFireResistant.java +++ b/src/main/java/ch/njol/skript/effects/EffFireResistant.java @@ -44,9 +44,8 @@ public class EffFireResistant extends Effect { static { - Skript.registerEffect(EffFireResistant.class, - "make %itemtypes% [:not] (fire resistant|resistant to fire)" - ); + if (Skript.methodExists(ItemMeta.class, "setFireResistant")) + Skript.registerEffect(EffFireResistant.class, "make %itemtypes% [:not] (fire resistant|resistant to fire)"); } @SuppressWarnings("NotNullFieldNotInitialized") diff --git a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java new file mode 100644 index 00000000000..8e403b1cc9f --- /dev/null +++ b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java @@ -0,0 +1,66 @@ +package ch.njol.skript.expressions; + +import ch.njol.skript.Skript; +import ch.njol.skript.aliases.ItemType; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.RequiredPlugins; +import ch.njol.skript.doc.Since; +import ch.njol.skript.expressions.base.PropertyExpression; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.ExpressionType; +import ch.njol.skript.lang.SkriptParser; +import ch.njol.util.Kleenean; +import org.bukkit.event.Event; +import org.bukkit.inventory.meta.ItemMeta; +import org.eclipse.jdt.annotation.Nullable; + +@Name("With Fire Resistance") +@Description("Creates a copy of an item with (or without) fire resistance.") +@Examples({ + "set {_x} to diamond sword with fire resistance", + "equip player with netherite helmet without fire resistance", + "drop fire resistant stone at player" +}) +@RequiredPlugins("Spigot 1.20.5+") +@Since("INSERT VERSION") +public class ExprWithFireResistance extends PropertyExpression { + + static { + if (Skript.methodExists(ItemMeta.class, "setFireResistant")) + Skript.registerExpression(ExprWithFireResistance.class, ItemType.class, ExpressionType.PROPERTY, + "%itemtype% with[:out] fire[ ]resistance", + "fire resistant %itemtype%"); + } + + private boolean out; + + @SuppressWarnings("unchecked") + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { + setExpr((Expression) exprs[0]); + out = parseResult.hasTag("out"); + return true; + } + + @Override + protected ItemType[] get(Event e, ItemType[] source) { + return get(source.clone(), item -> { + ItemMeta meta = item.getItemMeta(); + meta.setFireResistant(!out); + item.setItemMeta(meta); + return item; + }); + } + + @Override + public Class getReturnType() { + return ItemType.class; + } + + @Override + public String toString(final @Nullable Event event, boolean debug) { + return getExpr().toString(event, debug) + " with fire resistance"; + } +} From 10c67f8df372fd8115feb2c787a97965faa25b1e Mon Sep 17 00:00:00 2001 From: cheeezburga <47320303+cheeezburga@users.noreply.github.com> Date: Sat, 4 May 2024 13:13:43 +1000 Subject: [PATCH 04/13] Fixed method checks to provide the argument class --- .../njol/skript/effects/EffFireResistant.java | 2 +- .../expressions/ExprWithFireResistance.java | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/njol/skript/effects/EffFireResistant.java b/src/main/java/ch/njol/skript/effects/EffFireResistant.java index 4bb6ae66445..52feec65e6e 100644 --- a/src/main/java/ch/njol/skript/effects/EffFireResistant.java +++ b/src/main/java/ch/njol/skript/effects/EffFireResistant.java @@ -44,7 +44,7 @@ public class EffFireResistant extends Effect { static { - if (Skript.methodExists(ItemMeta.class, "setFireResistant")) + if (Skript.methodExists(ItemMeta.class, "setFireResistant", boolean.class)) Skript.registerEffect(EffFireResistant.class, "make %itemtypes% [:not] (fire resistant|resistant to fire)"); } diff --git a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java index 8e403b1cc9f..251f042119e 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java +++ b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java @@ -1,3 +1,21 @@ +/** + * This file is part of Skript. + * + * Skript 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. + * + * Skript 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 Skript. If not, see . + * + * Copyright Peter Güttinger, SkriptLang team and contributors + */ package ch.njol.skript.expressions; import ch.njol.skript.Skript; @@ -28,7 +46,7 @@ public class ExprWithFireResistance extends PropertyExpression { static { - if (Skript.methodExists(ItemMeta.class, "setFireResistant")) + if (Skript.methodExists(ItemMeta.class, "setFireResistant", boolean.class)) Skript.registerExpression(ExprWithFireResistance.class, ItemType.class, ExpressionType.PROPERTY, "%itemtype% with[:out] fire[ ]resistance", "fire resistant %itemtype%"); From 499284145a19a3c01dbe05de661e0b69c662eb2f Mon Sep 17 00:00:00 2001 From: cheeezburga <47320303+cheeezburga@users.noreply.github.com> Date: Sat, 4 May 2024 13:14:04 +1000 Subject: [PATCH 05/13] Added tests for each of the syntax --- .../conditions/CondIsFireResistant.sk | 41 +++++++++++++++++++ .../syntaxes/effects/EffFireResistant.sk | 12 ++++++ .../expressions/ExprWithFireResistance.sk | 10 +++++ 3 files changed, 63 insertions(+) create mode 100644 src/test/skript/tests/syntaxes/conditions/CondIsFireResistant.sk create mode 100644 src/test/skript/tests/syntaxes/effects/EffFireResistant.sk create mode 100644 src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk diff --git a/src/test/skript/tests/syntaxes/conditions/CondIsFireResistant.sk b/src/test/skript/tests/syntaxes/conditions/CondIsFireResistant.sk new file mode 100644 index 00000000000..cfc16296834 --- /dev/null +++ b/src/test/skript/tests/syntaxes/conditions/CondIsFireResistant.sk @@ -0,0 +1,41 @@ +test "is fire resistant": + + # single item: naturally not fire resistant + set {_item} to diamond + assert {_item} is not fire resistant with "diamond is unexpectedly fire resistant" + + # SEE PR DESCRIPTION + # single item: artificially not fire resistant + # set {_item} to netherite boots without fire resistance + # assert {_item} is not fire resistant with "netherite boots are unexpectedly fire resistant" + + # SEE PR DESCRIPTION + # single item: naturally fire resistant + # set {_item} to netherite boots + # assert {_item} is fire resistant with "netherite boots are unexpectedly not fire resistant" + + # single item: artificially fire resistant + set {_item} to fire resistant diamond + assert {_item} is fire resistant with "fire resistant diamond is unexpectedly not fire resistant" + + # multiple items: naturally not fire resistant + set {_item} to diamond + set {_item2} to stone block + assert ({_item} and {_item2}) are not fire resistant with "{_item} and {_item2} are unexpectedly fire resistant" + + # SEE PR DESCRIPTION + # multiple items: artificially not fire resistance + # set {_item} to netherite boots without fire resistance + # set {_item2} to netherite helmet without fire resistance + # assert ({_item} and {_item2}) are not fire resistant with "{_item} and {_item2} are unexpectedly fire resistant" + + # SEE PR DESCRIPTION + # multiple items: naturally fire resistant + # set {_item} to netherite boots + # set {_item2} to netherite helmet + # assert ({_item} and {_item2}) are fire resistant with "{_item} and {_item2} are unexpectedly not fire resistant" + + # multiple items: artifically fire resistant + set {_item} to diamond with fire resistance + set {_item2} to fire resistant stone block + assert ({_item} and {_item2}) are fire resistant with "fire resistant {_item} and {_item2} are unexpectedly not fire resistant" diff --git a/src/test/skript/tests/syntaxes/effects/EffFireResistant.sk b/src/test/skript/tests/syntaxes/effects/EffFireResistant.sk new file mode 100644 index 00000000000..701a406e2f3 --- /dev/null +++ b/src/test/skript/tests/syntaxes/effects/EffFireResistant.sk @@ -0,0 +1,12 @@ +test "apply fire resistance": + + # single item + set {_item} to diamond + make {_item} fire resistant + assert {_item} is fire resistant with "{_item} is unexpectedly not fire resistant" + + # multiple items + set {_item} to diamond + set {_item2} to paper + make ({_item} and {_item2}) resistant to fire + assert ({_item} and {_item2}) are resistant to fire with "{_item} and {_item2} are unexpectedly not fire resistant" \ No newline at end of file diff --git a/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk b/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk new file mode 100644 index 00000000000..0c7c0d4a463 --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk @@ -0,0 +1,10 @@ +test "item with fire resistance": + + # single item + set {_item} to diamond with fire resistance + assert {_item} is fire resistant with "{_item} was not fire resistant" + + # multiple items + set {_item} to fire resistant diamond + set {_item2} to paper with fire resistance + assert ({_item} and {_item2}) are not fire resistant with "{_item} and {_item2} were not fire resistant" \ No newline at end of file From 906df7228a119831edf1a940216b9a3455b18827 Mon Sep 17 00:00:00 2001 From: cheeezburga <47320303+cheeezburga@users.noreply.github.com> Date: Sat, 4 May 2024 13:22:28 +1000 Subject: [PATCH 06/13] Added notes to description of expression --- .../ch/njol/skript/expressions/ExprWithFireResistance.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java index 251f042119e..0c876700ffc 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java +++ b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java @@ -35,7 +35,11 @@ import org.eclipse.jdt.annotation.Nullable; @Name("With Fire Resistance") -@Description("Creates a copy of an item with (or without) fire resistance.") +@Description({ + "Creates a copy of an item with (or without) fire resistance.", + "Note: items that already have fire resistant (e.g. netherite armour, tools, etc) currently can't have their fire resistance removed.", + "This was missed in 1.20.5 and .6, but should be fixed in 1.21." +}) @Examples({ "set {_x} to diamond sword with fire resistance", "equip player with netherite helmet without fire resistance", From ae7d740f73ccd028154e5268f088cf5e51d2abd6 Mon Sep 17 00:00:00 2001 From: cheeezburga <47320303+cheeezburga@users.noreply.github.com> Date: Sat, 4 May 2024 14:14:34 +1000 Subject: [PATCH 07/13] Apply suggestions from code review Co-authored-by: Shane Bee --- src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java | 1 + src/main/java/ch/njol/skript/effects/EffFireResistant.java | 1 + .../java/ch/njol/skript/expressions/ExprWithFireResistance.java | 1 + 3 files changed, 3 insertions(+) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java b/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java index 72dea15e864..924fbd8a710 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsFireResistant.java @@ -52,4 +52,5 @@ public boolean check(ItemType item) { public String getPropertyName() { return "fire resistant"; } + } diff --git a/src/main/java/ch/njol/skript/effects/EffFireResistant.java b/src/main/java/ch/njol/skript/effects/EffFireResistant.java index 52feec65e6e..6a7bfb79f89 100644 --- a/src/main/java/ch/njol/skript/effects/EffFireResistant.java +++ b/src/main/java/ch/njol/skript/effects/EffFireResistant.java @@ -73,4 +73,5 @@ protected void execute(Event event) { public String toString(@Nullable Event event, boolean debug) { return "make " + items.toString(event, debug) + (not ? " not" : "") + " fire resistant"; } + } diff --git a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java index 0c876700ffc..3c178970c1d 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java +++ b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java @@ -85,4 +85,5 @@ public Class getReturnType() { public String toString(final @Nullable Event event, boolean debug) { return getExpr().toString(event, debug) + " with fire resistance"; } + } From ec33025e2d38feba38c9c267f2290496376aeedd Mon Sep 17 00:00:00 2001 From: cheeezburga <47320303+cheeezburga@users.noreply.github.com> Date: Sat, 4 May 2024 23:57:39 +1000 Subject: [PATCH 08/13] Add version checks to tests and apply suggestions from code review --- .../tests/syntaxes/conditions/CondIsFireResistant.sk | 10 +++++----- .../skript/tests/syntaxes/effects/EffFireResistant.sk | 6 ++++-- .../syntaxes/expressions/ExprWithFireResistance.sk | 6 ++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/test/skript/tests/syntaxes/conditions/CondIsFireResistant.sk b/src/test/skript/tests/syntaxes/conditions/CondIsFireResistant.sk index cfc16296834..6a61df2b7f9 100644 --- a/src/test/skript/tests/syntaxes/conditions/CondIsFireResistant.sk +++ b/src/test/skript/tests/syntaxes/conditions/CondIsFireResistant.sk @@ -1,15 +1,15 @@ -test "is fire resistant": +test "is fire resistant" while running minecraft "1.20.5": # single item: naturally not fire resistant set {_item} to diamond assert {_item} is not fire resistant with "diamond is unexpectedly fire resistant" - # SEE PR DESCRIPTION + # TODO: enable in 1.21 (doesn't work in 1.20.5 or 1.20.6) # single item: artificially not fire resistant # set {_item} to netherite boots without fire resistance # assert {_item} is not fire resistant with "netherite boots are unexpectedly fire resistant" - # SEE PR DESCRIPTION + # TODO: enable in 1.21 (doesn't work in 1.20.5 or 1.20.6) # single item: naturally fire resistant # set {_item} to netherite boots # assert {_item} is fire resistant with "netherite boots are unexpectedly not fire resistant" @@ -23,13 +23,13 @@ test "is fire resistant": set {_item2} to stone block assert ({_item} and {_item2}) are not fire resistant with "{_item} and {_item2} are unexpectedly fire resistant" - # SEE PR DESCRIPTION + # TODO: enable in 1.21 (doesn't work in 1.20.5 or 1.20.6) # multiple items: artificially not fire resistance # set {_item} to netherite boots without fire resistance # set {_item2} to netherite helmet without fire resistance # assert ({_item} and {_item2}) are not fire resistant with "{_item} and {_item2} are unexpectedly fire resistant" - # SEE PR DESCRIPTION + # TODO: enable in 1.21 (doesn't work in 1.20.5 or 1.20.6) # multiple items: naturally fire resistant # set {_item} to netherite boots # set {_item2} to netherite helmet diff --git a/src/test/skript/tests/syntaxes/effects/EffFireResistant.sk b/src/test/skript/tests/syntaxes/effects/EffFireResistant.sk index 701a406e2f3..5d014472ba0 100644 --- a/src/test/skript/tests/syntaxes/effects/EffFireResistant.sk +++ b/src/test/skript/tests/syntaxes/effects/EffFireResistant.sk @@ -1,4 +1,4 @@ -test "apply fire resistance": +test "apply fire resistance" while running minecraft "1.20.5": # single item set {_item} to diamond @@ -9,4 +9,6 @@ test "apply fire resistance": set {_item} to diamond set {_item2} to paper make ({_item} and {_item2}) resistant to fire - assert ({_item} and {_item2}) are resistant to fire with "{_item} and {_item2} are unexpectedly not fire resistant" \ No newline at end of file + assert ({_item} and {_item2}) are resistant to fire with "{_item} and {_item2} are unexpectedly not fire resistant" + + # TODO: add tests for already fire resistant items (i.e. netherite) in 1.21 (doesn't work in 1.20.5 or 1.20.6) diff --git a/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk b/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk index 0c7c0d4a463..83778ce61c8 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk @@ -1,4 +1,4 @@ -test "item with fire resistance": +test "item with fire resistance" while running minecraft "1.20.5": # single item set {_item} to diamond with fire resistance @@ -7,4 +7,6 @@ test "item with fire resistance": # multiple items set {_item} to fire resistant diamond set {_item2} to paper with fire resistance - assert ({_item} and {_item2}) are not fire resistant with "{_item} and {_item2} were not fire resistant" \ No newline at end of file + assert ({_item} and {_item2}) are not fire resistant with "{_item} and {_item2} were not fire resistant" + + # TODO: add tests for already fire resistant items (i.e. netherite) in 1.21 (doesn't work in 1.20.5 or 1.20.6) From 6fdf15b2c35e244520a42bc8811345ca83d10b32 Mon Sep 17 00:00:00 2001 From: cheeezburga <47320303+cheeezburga@users.noreply.github.com> Date: Sat, 4 May 2024 23:59:00 +1000 Subject: [PATCH 09/13] Removed note from syntax description - Happy to add back a different version of this like what Fuse suggested, but general consensus seemed to be to get rid of it --- .../ch/njol/skript/expressions/ExprWithFireResistance.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java index 0c876700ffc..5d002467717 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java +++ b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java @@ -36,9 +36,7 @@ @Name("With Fire Resistance") @Description({ - "Creates a copy of an item with (or without) fire resistance.", - "Note: items that already have fire resistant (e.g. netherite armour, tools, etc) currently can't have their fire resistance removed.", - "This was missed in 1.20.5 and .6, but should be fixed in 1.21." + "Creates a copy of an item with (or without) fire resistance." }) @Examples({ "set {_x} to diamond sword with fire resistance", From aad72ebce9e33b498518ba1a04c1631d4dd6ee84 Mon Sep 17 00:00:00 2001 From: cheeezburga <47320303+cheeezburga@users.noreply.github.com> Date: Sun, 5 May 2024 00:35:52 +1000 Subject: [PATCH 10/13] Apply suggestions from code review Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> --- .../ch/njol/skript/expressions/ExprWithFireResistance.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java index f8ea88668ec..5120ff5d083 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java +++ b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java @@ -65,7 +65,7 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye } @Override - protected ItemType[] get(Event e, ItemType[] source) { + protected ItemType[] get(Event event, ItemType[] source) { return get(source.clone(), item -> { ItemMeta meta = item.getItemMeta(); meta.setFireResistant(!out); @@ -80,7 +80,7 @@ public Class getReturnType() { } @Override - public String toString(final @Nullable Event event, boolean debug) { + public String toString(@Nullable Event event, boolean debug) { return getExpr().toString(event, debug) + " with fire resistance"; } From 2d3d2eaf61f58b8fa2153002d275d2047343e25b Mon Sep 17 00:00:00 2001 From: cheeezburga <47320303+cheeezburga@users.noreply.github.com> Date: Sun, 5 May 2024 00:37:02 +1000 Subject: [PATCH 11/13] Apply suggestions from code review --- .../ch/njol/skript/expressions/ExprWithFireResistance.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java index 5120ff5d083..e471b4610ee 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java +++ b/src/main/java/ch/njol/skript/expressions/ExprWithFireResistance.java @@ -28,7 +28,7 @@ import ch.njol.skript.expressions.base.PropertyExpression; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.ExpressionType; -import ch.njol.skript.lang.SkriptParser; +import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.util.Kleenean; import org.bukkit.event.Event; import org.bukkit.inventory.meta.ItemMeta; @@ -58,7 +58,7 @@ public class ExprWithFireResistance extends PropertyExpression[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { setExpr((Expression) exprs[0]); out = parseResult.hasTag("out"); return true; From 6f1b7037d2bce5546afbf098754e85926432147e Mon Sep 17 00:00:00 2001 From: cheeezburga <47320303+cheeezburga@users.noreply.github.com> Date: Sun, 5 May 2024 00:39:43 +1000 Subject: [PATCH 12/13] Fixed tests --- .../skript/tests/syntaxes/conditions/CondIsFireResistant.sk | 2 +- src/test/skript/tests/syntaxes/effects/EffFireResistant.sk | 2 +- .../skript/tests/syntaxes/expressions/ExprWithFireResistance.sk | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/skript/tests/syntaxes/conditions/CondIsFireResistant.sk b/src/test/skript/tests/syntaxes/conditions/CondIsFireResistant.sk index 6a61df2b7f9..61555e98fae 100644 --- a/src/test/skript/tests/syntaxes/conditions/CondIsFireResistant.sk +++ b/src/test/skript/tests/syntaxes/conditions/CondIsFireResistant.sk @@ -1,4 +1,4 @@ -test "is fire resistant" while running minecraft "1.20.5": +test "is fire resistant" when running minecraft "1.20.5": # single item: naturally not fire resistant set {_item} to diamond diff --git a/src/test/skript/tests/syntaxes/effects/EffFireResistant.sk b/src/test/skript/tests/syntaxes/effects/EffFireResistant.sk index 5d014472ba0..1005555ff01 100644 --- a/src/test/skript/tests/syntaxes/effects/EffFireResistant.sk +++ b/src/test/skript/tests/syntaxes/effects/EffFireResistant.sk @@ -1,4 +1,4 @@ -test "apply fire resistance" while running minecraft "1.20.5": +test "apply fire resistance" when running minecraft "1.20.5": # single item set {_item} to diamond diff --git a/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk b/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk index 83778ce61c8..7ca31ba5799 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk @@ -1,4 +1,4 @@ -test "item with fire resistance" while running minecraft "1.20.5": +test "item with fire resistance" when running minecraft "1.20.5": # single item set {_item} to diamond with fire resistance From 9c3a7cc3345948644632ea970b5e62ff4bfd3477 Mon Sep 17 00:00:00 2001 From: cheeezburga <47320303+cheeezburga@users.noreply.github.com> Date: Sun, 5 May 2024 00:52:47 +1000 Subject: [PATCH 13/13] Fixed expression test --- .../skript/tests/syntaxes/expressions/ExprWithFireResistance.sk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk b/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk index 7ca31ba5799..e7c2754a3cb 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprWithFireResistance.sk @@ -7,6 +7,6 @@ test "item with fire resistance" when running minecraft "1.20.5": # multiple items set {_item} to fire resistant diamond set {_item2} to paper with fire resistance - assert ({_item} and {_item2}) are not fire resistant with "{_item} and {_item2} were not fire resistant" + assert ({_item} and {_item2}) are fire resistant with "{_item} and {_item2} are unexpectedly not fire resistant" # TODO: add tests for already fire resistant items (i.e. netherite) in 1.21 (doesn't work in 1.20.5 or 1.20.6)