From 5da61b63235c716df53864164c08be834b532799 Mon Sep 17 00:00:00 2001 From: APickledWalrus Date: Sat, 18 Jan 2020 21:32:01 -0500 Subject: [PATCH 1/7] Fiery Explosion Stuff --- .../conditions/CondExplodesWithFire.java | 94 ++++++++++++++++++ .../skript/effects/EffExplodeWithFire.java | 95 +++++++++++++++++++ .../syntaxes/effects/EffExplodeWithFire.sk | 6 ++ 3 files changed, 195 insertions(+) create mode 100644 src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java create mode 100644 src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java create mode 100644 src/test/skript/tests/syntaxes/effects/EffExplodeWithFire.sk diff --git a/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java b/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java new file mode 100644 index 00000000000..e4fd8680990 --- /dev/null +++ b/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java @@ -0,0 +1,94 @@ +/** + * 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 2011-2017 Peter Güttinger and contributors + */ +package ch.njol.skript.conditions; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Explosive; +import org.bukkit.event.Event; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.eclipse.jdt.annotation.Nullable; + +import ch.njol.skript.ScriptLoader; +import ch.njol.skript.Skript; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.lang.Condition; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.skript.log.ErrorQuality; +import ch.njol.util.Kleenean; + +@Name("Explodes With Fire") +@Description("Checks if an entity will create fire if it explodes.") +@Examples({"on explosion prime:", + "\tif the event-explosion is fiery:", + "\t\tbroadcast \"A fiery explosive has been ignited!\""}) +@Since("INSERT VERSION") +public class CondExplodesWithFire extends Condition { + + static { + Skript.registerCondition(CondExplodesWithFire.class, + "%entities% [(1¦((does|do) not|(doesn't|don't)))] explode[s] with fire", + "%entities% [(1¦((does|do) not|(doesn't|don't)))] cause[s] (a fiery|an incendiary explosion)", + "the [event(-| )]explosion (is|1¦(is not|isn't)) fiery"); + } + + @SuppressWarnings("null") + private Expression entities; + + private boolean isEvent; + + @SuppressWarnings({"unchecked", "null"}) + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + isEvent = matchedPattern == 2; + if (isEvent) { + if (!ScriptLoader.isCurrentEvent(ExplosionPrimeEvent.class)) { + Skript.error("Checking if the explosion is fiery is only possible in explosion prime events", ErrorQuality.SEMANTIC_ERROR); + return false; + } + } + if (matchedPattern < 2) + entities = (Expression) exprs[0]; + setNegated(parseResult.mark == 1); + return true; + } + + @Override + public boolean check(Event e) { + if (isEvent) + return ((ExplosionPrimeEvent) e).getFire(); + if (e instanceof Explosive) { + if (isNegated()) + return !((Explosive) e).isIncendiary(); + return ((Explosive) e).isIncendiary(); + } + return false; + } + + @Override + public String toString(@Nullable Event e, boolean debug) { + if (isEvent) + return "the event-explosion " + (isNegated() == false ? "" : "is not") + " fiery (ExplosionPrimeEvent)"; + return entities.toString(e, debug) + (isNegated() == false ? "" : " do not") + " explode with fire"; + } +} diff --git a/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java b/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java new file mode 100644 index 00000000000..77f65164051 --- /dev/null +++ b/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java @@ -0,0 +1,95 @@ +/** + * 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 2011-2017 Peter Güttinger and contributors + */ +package ch.njol.skript.effects; + +import ch.njol.skript.ScriptLoader; +import ch.njol.skript.Skript; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; +import ch.njol.skript.lang.Effect; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser; +import ch.njol.skript.log.ErrorQuality; +import ch.njol.util.Kleenean; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Explosive; +import org.bukkit.event.Event; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.eclipse.jdt.annotation.Nullable; + +@Name("Explode With Fire") +@Description("Sets if an entity will explode with fire. Use \"make the explosion fiery\" in explosion prime events.") +@Examples({"on explosion prime:", + "\tmake the explosion fiery"}) +@Since("INSERT VERSION") +public class EffExplodeWithFire extends Effect { + + static { + Skript.registerEffect(EffExplodeWithFire.class, + "make %entities% [(1¦not)] explode with fire", + "make %entities% [(1¦not)] cause (a fiery|an incendiary explosion)", + "make the [event(-| )]explosion [(1¦not)] fiery"); + } + + @SuppressWarnings("null") + private Expression entities; + + private boolean causeFire; + + private boolean isEvent; + + @SuppressWarnings({"unchecked", "null"}) + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { + isEvent = matchedPattern == 2; + if (isEvent) { + if (!ScriptLoader.isCurrentEvent(ExplosionPrimeEvent.class)) { + Skript.error("Making the explosion fiery is only usable in explosion prime events", ErrorQuality.SEMANTIC_ERROR); + return false; + } + } + if (matchedPattern < 2) + entities = (Expression) exprs[0]; + causeFire = parseResult.mark != 1; + return true; + } + + @Override + protected void execute(Event e) { + if (isEvent) { + ((ExplosionPrimeEvent) e).setFire(causeFire); + } else { + for (Entity entity : entities.getArray(e)) { + if (entity instanceof Explosive) + ((Explosive) entity).setIsIncendiary(causeFire); + } + } + } + + @Override + public String toString(@Nullable Event e, boolean debug) { + if (isEvent) + return "make the explosion " + (causeFire == true ? "" : "not") + " fiery (ExplosionPrimeEvent)"; + return "make " + entities.toString(e, debug) + (causeFire == true ? "" : " not") + " explode with fire"; + } +} diff --git a/src/test/skript/tests/syntaxes/effects/EffExplodeWithFire.sk b/src/test/skript/tests/syntaxes/effects/EffExplodeWithFire.sk new file mode 100644 index 00000000000..58b82177b4b --- /dev/null +++ b/src/test/skript/tests/syntaxes/effects/EffExplodeWithFire.sk @@ -0,0 +1,6 @@ +test "explode with fire effect/condition": + spawn a primed tnt at spawn of world "world" + assert last spawned primed tnt does not explode with fire with "primed tnt should not explode with fire by default" + make last spawned primed tnt explode with fire + assert last spawned primed tnt explodes with fire with "primed tnt should explode with fire after being set to explode with fire" + delete last spawned tnt From ce15e677cda96399454201fb9bec447047cd8922 Mon Sep 17 00:00:00 2001 From: APickledWalrus Date: Sun, 19 Jan 2020 11:37:06 -0500 Subject: [PATCH 2/7] Fix Condition --- .../njol/skript/conditions/CondExplodesWithFire.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java b/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java index e4fd8680990..ab9ba29e1a3 100644 --- a/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java +++ b/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java @@ -63,7 +63,7 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye isEvent = matchedPattern == 2; if (isEvent) { if (!ScriptLoader.isCurrentEvent(ExplosionPrimeEvent.class)) { - Skript.error("Checking if the explosion is fiery is only possible in explosion prime events", ErrorQuality.SEMANTIC_ERROR); + Skript.error("Checking if the event explosion is fiery is only possible in explosion prime events", ErrorQuality.SEMANTIC_ERROR); return false; } } @@ -75,14 +75,12 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye @Override public boolean check(Event e) { - if (isEvent) - return ((ExplosionPrimeEvent) e).getFire(); - if (e instanceof Explosive) { + if (isEvent) { if (isNegated()) - return !((Explosive) e).isIncendiary(); - return ((Explosive) e).isIncendiary(); + return !((ExplosionPrimeEvent) e).getFire(); + return ((ExplosionPrimeEvent) e).getFire(); } - return false; + return entities.check(e, entity -> entity instanceof Explosive && ((Explosive) entity).isIncendiary(), isNegated()); } @Override From ccb94656c504361ac30071ea23cd3fd13bce49f6 Mon Sep 17 00:00:00 2001 From: APickledWalrus Date: Sun, 22 Mar 2020 18:55:09 -0400 Subject: [PATCH 3/7] Merge conditions --- .../ch/njol/skript/conditions/CondExplodesWithFire.java | 8 +++----- .../java/ch/njol/skript/effects/EffExplodeWithFire.java | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java b/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java index ab9ba29e1a3..2557cb8031d 100644 --- a/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java +++ b/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java @@ -61,11 +61,9 @@ public class CondExplodesWithFire extends Condition { @Override public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { isEvent = matchedPattern == 2; - if (isEvent) { - if (!ScriptLoader.isCurrentEvent(ExplosionPrimeEvent.class)) { - Skript.error("Checking if the event explosion is fiery is only possible in explosion prime events", ErrorQuality.SEMANTIC_ERROR); - return false; - } + if (isEvent && !ScriptLoader.isCurrentEvent(ExplosionPrimeEvent.class)) { + Skript.error("Checking if the event explosion is fiery is only possible in explosion prime events", ErrorQuality.SEMANTIC_ERROR); + return false; } if (matchedPattern < 2) entities = (Expression) exprs[0]; diff --git a/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java b/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java index 77f65164051..364207dea30 100644 --- a/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java +++ b/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java @@ -62,11 +62,9 @@ public class EffExplodeWithFire extends Effect { @Override public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { isEvent = matchedPattern == 2; - if (isEvent) { - if (!ScriptLoader.isCurrentEvent(ExplosionPrimeEvent.class)) { - Skript.error("Making the explosion fiery is only usable in explosion prime events", ErrorQuality.SEMANTIC_ERROR); - return false; - } + if (isEvent && !ScriptLoader.isCurrentEvent(ExplosionPrimeEvent.class)) { + Skript.error("Making the explosion fiery is only usable in explosion prime events", ErrorQuality.SEMANTIC_ERROR); + return false; } if (matchedPattern < 2) entities = (Expression) exprs[0]; From b7f72cce95dd9c62a5d30f47ea12e1491b0dd8d2 Mon Sep 17 00:00:00 2001 From: APickledWalrus Date: Mon, 27 Apr 2020 07:43:57 -0400 Subject: [PATCH 4/7] Make Requested Changes --- .../java/ch/njol/skript/conditions/CondExplodesWithFire.java | 4 +--- src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java b/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java index 2557cb8031d..2ea3dc10432 100644 --- a/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java +++ b/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java @@ -74,9 +74,7 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye @Override public boolean check(Event e) { if (isEvent) { - if (isNegated()) - return !((ExplosionPrimeEvent) e).getFire(); - return ((ExplosionPrimeEvent) e).getFire(); + return ((ExplosionPrimeEvent) e).getFire() ^ isNegated(); } return entities.check(e, entity -> entity instanceof Explosive && ((Explosive) entity).isIncendiary(), isNegated()); } diff --git a/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java b/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java index 364207dea30..021f7b8c6cf 100644 --- a/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java +++ b/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java @@ -46,7 +46,7 @@ public class EffExplodeWithFire extends Effect { static { Skript.registerEffect(EffExplodeWithFire.class, - "make %entities% [(1¦not)] explode with fire", + "make %entities% explosion [(1¦not)] (fiery|incendiary)", "make %entities% [(1¦not)] cause (a fiery|an incendiary explosion)", "make the [event(-| )]explosion [(1¦not)] fiery"); } From 1325dfe3b725f0732febd96ef5e7088d3b64d788 Mon Sep 17 00:00:00 2001 From: APickledWalrus Date: Mon, 27 Apr 2020 08:13:18 -0400 Subject: [PATCH 5/7] Fix test --- src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java | 2 +- src/test/skript/tests/syntaxes/effects/EffExplodeWithFire.sk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java b/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java index 021f7b8c6cf..d709567ee7a 100644 --- a/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java +++ b/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java @@ -46,7 +46,7 @@ public class EffExplodeWithFire extends Effect { static { Skript.registerEffect(EffExplodeWithFire.class, - "make %entities% explosion [(1¦not)] (fiery|incendiary)", + "make %entities%'[s] explosion [(1¦not)] (fiery|incendiary)", "make %entities% [(1¦not)] cause (a fiery|an incendiary explosion)", "make the [event(-| )]explosion [(1¦not)] fiery"); } diff --git a/src/test/skript/tests/syntaxes/effects/EffExplodeWithFire.sk b/src/test/skript/tests/syntaxes/effects/EffExplodeWithFire.sk index 58b82177b4b..064aae3a372 100644 --- a/src/test/skript/tests/syntaxes/effects/EffExplodeWithFire.sk +++ b/src/test/skript/tests/syntaxes/effects/EffExplodeWithFire.sk @@ -1,6 +1,6 @@ test "explode with fire effect/condition": spawn a primed tnt at spawn of world "world" assert last spawned primed tnt does not explode with fire with "primed tnt should not explode with fire by default" - make last spawned primed tnt explode with fire + make the last spawned primed tnt's explosion fiery assert last spawned primed tnt explodes with fire with "primed tnt should explode with fire after being set to explode with fire" delete last spawned tnt From 0ad2e904a2c7d7e5cf001d531d561b754ea35e00 Mon Sep 17 00:00:00 2001 From: APickledWalrus Date: Sat, 11 Jul 2020 15:52:41 -0400 Subject: [PATCH 6/7] Pattern Changes & Refactoring --- ...lodesWithFire.java => CondIncendiary.java} | 45 ++++++++++--------- ...xplodeWithFire.java => EffIncendiary.java} | 31 ++++++------- 2 files changed, 40 insertions(+), 36 deletions(-) rename src/main/java/ch/njol/skript/conditions/{CondExplodesWithFire.java => CondIncendiary.java} (69%) rename src/main/java/ch/njol/skript/effects/{EffExplodeWithFire.java => EffIncendiary.java} (71%) diff --git a/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java b/src/main/java/ch/njol/skript/conditions/CondIncendiary.java similarity index 69% rename from src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java rename to src/main/java/ch/njol/skript/conditions/CondIncendiary.java index 2ea3dc10432..07d212c1fc2 100644 --- a/src/main/java/ch/njol/skript/conditions/CondExplodesWithFire.java +++ b/src/main/java/ch/njol/skript/conditions/CondIncendiary.java @@ -19,12 +19,6 @@ */ package ch.njol.skript.conditions; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Explosive; -import org.bukkit.event.Event; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.eclipse.jdt.annotation.Nullable; - import ch.njol.skript.ScriptLoader; import ch.njol.skript.Skript; import ch.njol.skript.doc.Description; @@ -37,19 +31,26 @@ import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; -@Name("Explodes With Fire") -@Description("Checks if an entity will create fire if it explodes.") +import org.bukkit.entity.Entity; +import org.bukkit.entity.Explosive; +import org.bukkit.event.Event; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.eclipse.jdt.annotation.Nullable; + +@Name("Is Incendiary") +@Description("Checks if an entity will create fire when it explodes. This condition is also usable in an explosion prime event.") @Examples({"on explosion prime:", - "\tif the event-explosion is fiery:", + "\tif the explosion is fiery:", "\t\tbroadcast \"A fiery explosive has been ignited!\""}) @Since("INSERT VERSION") -public class CondExplodesWithFire extends Condition { +public class CondIncendiary extends Condition { static { - Skript.registerCondition(CondExplodesWithFire.class, - "%entities% [(1¦((does|do) not|(doesn't|don't)))] explode[s] with fire", - "%entities% [(1¦((does|do) not|(doesn't|don't)))] cause[s] (a fiery|an incendiary explosion)", - "the [event(-| )]explosion (is|1¦(is not|isn't)) fiery"); + Skript.registerCondition(CondIncendiary.class, + "%entities% ((is|are) incendiary|cause an (incendiary|fiery) explosion)", + "%entities% ((is not|are not|isn't|aren't) incendiary|(does not|do not|doesn't|don't) cause[s] an (incendiary|fiery) explosion)", + "the [event(-| )]explosion (is|1¦(is not|isn't)) (incendiary|fiery)" + ); } @SuppressWarnings("null") @@ -62,27 +63,29 @@ public class CondExplodesWithFire extends Condition { public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { isEvent = matchedPattern == 2; if (isEvent && !ScriptLoader.isCurrentEvent(ExplosionPrimeEvent.class)) { - Skript.error("Checking if the event explosion is fiery is only possible in explosion prime events", ErrorQuality.SEMANTIC_ERROR); + Skript.error("Checking if 'the explosion' is fiery is only possible in an explosion prime event", ErrorQuality.SEMANTIC_ERROR); return false; } - if (matchedPattern < 2) + if (!isEvent) entities = (Expression) exprs[0]; - setNegated(parseResult.mark == 1); + setNegated(matchedPattern == 1 || parseResult.mark == 1); return true; } @Override public boolean check(Event e) { - if (isEvent) { + if (isEvent) return ((ExplosionPrimeEvent) e).getFire() ^ isNegated(); - } return entities.check(e, entity -> entity instanceof Explosive && ((Explosive) entity).isIncendiary(), isNegated()); } @Override public String toString(@Nullable Event e, boolean debug) { if (isEvent) - return "the event-explosion " + (isNegated() == false ? "" : "is not") + " fiery (ExplosionPrimeEvent)"; - return entities.toString(e, debug) + (isNegated() == false ? "" : " do not") + " explode with fire"; + return "the event-explosion " + (isNegated() == false ? "is" : "is not") + " incendiary"; + if (entities.isSingle()) + return entities.toString(e, debug) + (isNegated() == false ? " is" : " is not") + " incendiary"; + return entities.toString(e, debug) + (isNegated() == false ? " are" : " are not") + " incendiary"; } + } diff --git a/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java b/src/main/java/ch/njol/skript/effects/EffIncendiary.java similarity index 71% rename from src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java rename to src/main/java/ch/njol/skript/effects/EffIncendiary.java index d709567ee7a..b8812de2c2e 100644 --- a/src/main/java/ch/njol/skript/effects/EffExplodeWithFire.java +++ b/src/main/java/ch/njol/skript/effects/EffIncendiary.java @@ -27,7 +27,7 @@ import ch.njol.skript.doc.Since; import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Expression; -import ch.njol.skript.lang.SkriptParser; +import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.skript.log.ErrorQuality; import ch.njol.util.Kleenean; @@ -37,18 +37,19 @@ import org.bukkit.event.entity.ExplosionPrimeEvent; import org.eclipse.jdt.annotation.Nullable; -@Name("Explode With Fire") -@Description("Sets if an entity will explode with fire. Use \"make the explosion fiery\" in explosion prime events.") -@Examples({"on explosion prime:", - "\tmake the explosion fiery"}) +@Name("Make Incendiary") +@Description("Sets if an entity's explosion will leave behind fire. This effect is also usable in an explosion prime event.") +@Examples({"on explosion prime:", + "\tmake the explosion fiery"}) @Since("INSERT VERSION") -public class EffExplodeWithFire extends Effect { +public class EffIncendiary extends Effect { static { - Skript.registerEffect(EffExplodeWithFire.class, - "make %entities%'[s] explosion [(1¦not)] (fiery|incendiary)", - "make %entities% [(1¦not)] cause (a fiery|an incendiary explosion)", - "make the [event(-| )]explosion [(1¦not)] fiery"); + Skript.registerEffect(EffIncendiary.class, + "make %entities% [(1¦not)] incendiary", + "make %entities%'[s] explosion [(1¦not)] (incendiary|fiery)", + "make [the] [event(-| )]explosion [(1¦not)] (incendiary|fiery)" + ); } @SuppressWarnings("null") @@ -60,13 +61,13 @@ public class EffExplodeWithFire extends Effect { @SuppressWarnings({"unchecked", "null"}) @Override - public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { isEvent = matchedPattern == 2; if (isEvent && !ScriptLoader.isCurrentEvent(ExplosionPrimeEvent.class)) { - Skript.error("Making the explosion fiery is only usable in explosion prime events", ErrorQuality.SEMANTIC_ERROR); + Skript.error("Making 'the explosion' fiery is only usable in an explosion prime event", ErrorQuality.SEMANTIC_ERROR); return false; } - if (matchedPattern < 2) + if (!isEvent) entities = (Expression) exprs[0]; causeFire = parseResult.mark != 1; return true; @@ -87,7 +88,7 @@ protected void execute(Event e) { @Override public String toString(@Nullable Event e, boolean debug) { if (isEvent) - return "make the explosion " + (causeFire == true ? "" : "not") + " fiery (ExplosionPrimeEvent)"; - return "make " + entities.toString(e, debug) + (causeFire == true ? "" : " not") + " explode with fire"; + return "make the event-explosion " + (causeFire == true ? "" : "not") + " fiery"; + return "make " + entities.toString(e, debug) + (causeFire == true ? "" : " not") + " incendiary"; } } From 2bbeae3e11d68e8ecca6121dd6536e69d438f056 Mon Sep 17 00:00:00 2001 From: APickledWalrus Date: Sun, 19 Jul 2020 15:17:50 -0400 Subject: [PATCH 7/7] Test and pattern fixes --- src/main/java/ch/njol/skript/conditions/CondIncendiary.java | 6 +++--- src/main/java/ch/njol/skript/effects/EffIncendiary.java | 3 ++- .../skript/tests/syntaxes/effects/EffExplodeWithFire.sk | 6 ++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIncendiary.java b/src/main/java/ch/njol/skript/conditions/CondIncendiary.java index 07d212c1fc2..c7f0b981413 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIncendiary.java +++ b/src/main/java/ch/njol/skript/conditions/CondIncendiary.java @@ -47,8 +47,8 @@ public class CondIncendiary extends Condition { static { Skript.registerCondition(CondIncendiary.class, - "%entities% ((is|are) incendiary|cause an (incendiary|fiery) explosion)", - "%entities% ((is not|are not|isn't|aren't) incendiary|(does not|do not|doesn't|don't) cause[s] an (incendiary|fiery) explosion)", + "%entities% ((is|are) incendiary|cause[s] a[n] (incendiary|fiery) explosion)", + "%entities% ((is not|are not|isn't|aren't) incendiary|(does not|do not|doesn't|don't) cause[s] a[n] (incendiary|fiery) explosion)", "the [event(-| )]explosion (is|1¦(is not|isn't)) (incendiary|fiery)" ); } @@ -58,8 +58,8 @@ public class CondIncendiary extends Condition { private boolean isEvent; - @SuppressWarnings({"unchecked", "null"}) @Override + @SuppressWarnings({"unchecked", "null"}) public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { isEvent = matchedPattern == 2; if (isEvent && !ScriptLoader.isCurrentEvent(ExplosionPrimeEvent.class)) { diff --git a/src/main/java/ch/njol/skript/effects/EffIncendiary.java b/src/main/java/ch/njol/skript/effects/EffIncendiary.java index b8812de2c2e..9adc81e8409 100644 --- a/src/main/java/ch/njol/skript/effects/EffIncendiary.java +++ b/src/main/java/ch/njol/skript/effects/EffIncendiary.java @@ -59,8 +59,8 @@ public class EffIncendiary extends Effect { private boolean isEvent; - @SuppressWarnings({"unchecked", "null"}) @Override + @SuppressWarnings({"unchecked", "null"}) public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { isEvent = matchedPattern == 2; if (isEvent && !ScriptLoader.isCurrentEvent(ExplosionPrimeEvent.class)) { @@ -91,4 +91,5 @@ public String toString(@Nullable Event e, boolean debug) { return "make the event-explosion " + (causeFire == true ? "" : "not") + " fiery"; return "make " + entities.toString(e, debug) + (causeFire == true ? "" : " not") + " incendiary"; } + } diff --git a/src/test/skript/tests/syntaxes/effects/EffExplodeWithFire.sk b/src/test/skript/tests/syntaxes/effects/EffExplodeWithFire.sk index 064aae3a372..fce4c2d37eb 100644 --- a/src/test/skript/tests/syntaxes/effects/EffExplodeWithFire.sk +++ b/src/test/skript/tests/syntaxes/effects/EffExplodeWithFire.sk @@ -1,6 +1,8 @@ test "explode with fire effect/condition": spawn a primed tnt at spawn of world "world" - assert last spawned primed tnt does not explode with fire with "primed tnt should not explode with fire by default" + assert last spawned primed tnt doesn't cause an incendiary explosion with "a primed tnt's explosion shouldn't cause fire by default" make the last spawned primed tnt's explosion fiery - assert last spawned primed tnt explodes with fire with "primed tnt should explode with fire after being set to explode with fire" + assert last spawned primed tnt causes an incendiary explosion with "a primed tnt's explosion should cause fire when set to" + make the last spawned primed tnt's explosion not fiery + assert last spawned primed tnt doesn't cause an incendiary explosion with "a primed tnt's explosion shouldn't cause fire when set not to" delete last spawned tnt