From a2919a1433c9150666a69e461173927218939c89 Mon Sep 17 00:00:00 2001 From: Efnilite <35348263+Efnilite@users.noreply.github.com> Date: Tue, 10 Sep 2024 17:57:48 +0200 Subject: [PATCH 01/14] init commit --- .../njol/skript/effects/EffCancelEvent.java | 109 ++++++++---------- .../syntaxes/effects/EffCancelEventTest.java | 13 +++ src/test/skript/junit/EffCancelEvent.sk | 21 ++++ 3 files changed, 83 insertions(+), 60 deletions(-) create mode 100644 src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffCancelEventTest.java create mode 100644 src/test/skript/junit/EffCancelEvent.sk diff --git a/src/main/java/ch/njol/skript/effects/EffCancelEvent.java b/src/main/java/ch/njol/skript/effects/EffCancelEvent.java index e5b3ba4f2b5..93022e9bca9 100644 --- a/src/main/java/ch/njol/skript/effects/EffCancelEvent.java +++ b/src/main/java/ch/njol/skript/effects/EffCancelEvent.java @@ -1,34 +1,5 @@ -/** - * 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 org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.Event.Result; -import org.bukkit.event.block.BlockCanBuildEvent; -import org.bukkit.event.inventory.InventoryInteractEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerLoginEvent; -import org.eclipse.jdt.annotation.Nullable; - import ch.njol.skript.Skript; import ch.njol.skript.bukkitutil.PlayerUtils; import ch.njol.skript.doc.Description; @@ -38,69 +9,87 @@ import ch.njol.skript.events.EvtClick; import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Expression; -import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.log.ErrorQuality; import ch.njol.skript.util.Utils; import ch.njol.util.Kleenean; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.Event.Result; +import org.bukkit.event.block.BlockCanBuildEvent; +import org.bukkit.event.entity.EntityToggleSwimEvent; +import org.bukkit.event.inventory.InventoryInteractEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.eclipse.jdt.annotation.Nullable; -/** - * @author Peter Güttinger - */ @Name("Cancel Event") @Description("Cancels the event (e.g. prevent blocks from being placed, or damage being taken).") -@Examples({"on damage:", - " victim is a player", - " victim has the permission \"skript.god\"", - " cancel the event"}) +@Examples({ + "on damage:", + "\tvictim is a player", + "\tvictim has the permission \"skript.god\"", + "\tcancel the event" +}) @Since("1.0") public class EffCancelEvent extends Effect { + static { - Skript.registerEffect(EffCancelEvent.class, "cancel [the] event", "uncancel [the] event"); + Skript.registerEffect(EffCancelEvent.class, "[:un]cancel [the] event"); } private boolean cancel; @SuppressWarnings("null") @Override - public boolean init(final Expression[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) { + public boolean init(Expression[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult result) { if (isDelayed == Kleenean.TRUE) { - Skript.error("Can't cancel an event anymore after it has already passed", ErrorQuality.SEMANTIC_ERROR); + Skript.error("Can't cancel an event after it has already passed", ErrorQuality.SEMANTIC_ERROR); return false; } - cancel = matchedPattern == 0; - final Class[] es = getParser().getCurrentEvents(); - if (es == null) + + cancel = !result.hasTag("un"); + Class[] currentEvents = getParser().getCurrentEvents(); + + if (currentEvents == null) return false; - for (final Class e : es) { + + for (Class e : currentEvents) { if (Cancellable.class.isAssignableFrom(e) || BlockCanBuildEvent.class.isAssignableFrom(e)) return true; // TODO warning if some event(s) cannot be cancelled even though some can (needs a way to be suppressed) } - if (getParser().isCurrentEvent(PlayerLoginEvent.class)) + + if (getParser().isCurrentEvent(PlayerLoginEvent.class)) { Skript.error("A connect event cannot be cancelled, but the player may be kicked ('kick player by reason of \"...\"')", ErrorQuality.SEMANTIC_ERROR); - else + } else if (getParser().isCurrentEvent(EntityToggleSwimEvent.class)) { + Skript.error("Cancelling a toggle swim event has no effect", ErrorQuality.SEMANTIC_ERROR); + } else { Skript.error(Utils.A(getParser().getCurrentEventName()) + " event cannot be cancelled", ErrorQuality.SEMANTIC_ERROR); + } return false; } @Override - public void execute(final Event e) { - if (e instanceof Cancellable) - ((Cancellable) e).setCancelled(cancel); - if (e instanceof PlayerInteractEvent) { - EvtClick.interactTracker.eventModified((Cancellable) e); - ((PlayerInteractEvent) e).setUseItemInHand(cancel ? Result.DENY : Result.DEFAULT); - ((PlayerInteractEvent) e).setUseInteractedBlock(cancel ? Result.DENY : Result.DEFAULT); - } else if (e instanceof BlockCanBuildEvent) { - ((BlockCanBuildEvent) e).setBuildable(!cancel); - } else if (e instanceof PlayerDropItemEvent) { - PlayerUtils.updateInventory(((PlayerDropItemEvent) e).getPlayer()); - } else if (e instanceof InventoryInteractEvent) { - PlayerUtils.updateInventory(((Player) ((InventoryInteractEvent) e).getWhoClicked())); + public void execute(Event event) { + if (event instanceof Cancellable) + ((Cancellable) event).setCancelled(cancel); + if (event instanceof PlayerInteractEvent) { + EvtClick.interactTracker.eventModified((Cancellable) event); + ((PlayerInteractEvent) event).setUseItemInHand(cancel ? Result.DENY : Result.DEFAULT); + ((PlayerInteractEvent) event).setUseInteractedBlock(cancel ? Result.DENY : Result.DEFAULT); + } else if (event instanceof BlockCanBuildEvent) { + ((BlockCanBuildEvent) event).setBuildable(!cancel); + } else if (event instanceof PlayerDropItemEvent) { + PlayerUtils.updateInventory(((PlayerDropItemEvent) event).getPlayer()); + } else if (event instanceof InventoryInteractEvent) { + PlayerUtils.updateInventory(((Player) ((InventoryInteractEvent) event).getWhoClicked())); } } @Override - public String toString(final @Nullable Event e, final boolean debug) { + public String toString(@Nullable Event event, boolean debug) { return (cancel ? "" : "un") + "cancel event"; } diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffCancelEventTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffCancelEventTest.java new file mode 100644 index 00000000000..a1546d69005 --- /dev/null +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffCancelEventTest.java @@ -0,0 +1,13 @@ +package org.skriptlang.skript.test.tests.syntaxes.effects; + +import ch.njol.skript.test.runner.SkriptJUnitTest; +import org.junit.Test; + +public class EffCancelEventTest extends SkriptJUnitTest { + + @Test + public void test() { + spawnTestPig(); + } + +} diff --git a/src/test/skript/junit/EffCancelEvent.sk b/src/test/skript/junit/EffCancelEvent.sk new file mode 100644 index 00000000000..7baad602b34 --- /dev/null +++ b/src/test/skript/junit/EffCancelEvent.sk @@ -0,0 +1,21 @@ +test "SimpleJUnitTest" when running JUnit: + set {_tests::1} to "event not cancelled by default" + set {_tests::2} to "cancel event" + set {_tests::3} to "uncancel event" + + ensure junit test "org.skriptlang.skript.test.tests.syntaxes.effects.EffCancelEventTest" completes {_tests::*} + +on spawn of pig: + set {_test} to "org.skriptlang.skript.test.tests.syntaxes.effects.EffCancelEventTest" + junit test is {_test} + + if event is not cancelled: + complete objective "event not cancelled by default" for {_test} + + cancel event + if event is cancelled: + complete objective "cancel event" for {_test} + + uncancel event + if event is not cancelled: + complete objective "uncancel event" for {_test} \ No newline at end of file From 50ded104f378e8efe05b6e0b057d3cdf9e2280fe Mon Sep 17 00:00:00 2001 From: Efnilite <35348263+Efnilite@users.noreply.github.com> Date: Tue, 10 Sep 2024 18:05:41 +0200 Subject: [PATCH 02/14] fix merge --- .../njol/skript/effects/EffCancelEvent.java | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/njol/skript/effects/EffCancelEvent.java b/src/main/java/ch/njol/skript/effects/EffCancelEvent.java index 795f2cb2d9b..13a5b7e860f 100644 --- a/src/main/java/ch/njol/skript/effects/EffCancelEvent.java +++ b/src/main/java/ch/njol/skript/effects/EffCancelEvent.java @@ -1,5 +1,29 @@ package ch.njol.skript.effects; +import ch.njol.skript.Skript; +import ch.njol.skript.bukkitutil.PlayerUtils; +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.events.EvtClick; +import ch.njol.skript.lang.Effect; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.skript.log.ErrorQuality; +import ch.njol.skript.util.Utils; +import ch.njol.util.Kleenean; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.block.BlockCanBuildEvent; +import org.bukkit.event.entity.EntityToggleSwimEvent; +import org.bukkit.event.inventory.InventoryInteractEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.jetbrains.annotations.Nullable; + @Name("Cancel Event") @Description("Cancels the event (e.g. prevent blocks from being placed, or damage being taken).") @Examples({ @@ -19,7 +43,7 @@ public class EffCancelEvent extends Effect { @SuppressWarnings("null") @Override - public boolean init(Expression[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult result) { + public boolean init(Expression[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult result) { if (isDelayed == Kleenean.TRUE) { Skript.error("Can't cancel an event after it has already passed", ErrorQuality.SEMANTIC_ERROR); return false; @@ -52,8 +76,8 @@ public void execute(Event event) { ((Cancellable) event).setCancelled(cancel); if (event instanceof PlayerInteractEvent) { EvtClick.interactTracker.eventModified((Cancellable) event); - ((PlayerInteractEvent) event).setUseItemInHand(cancel ? Result.DENY : Result.DEFAULT); - ((PlayerInteractEvent) event).setUseInteractedBlock(cancel ? Result.DENY : Result.DEFAULT); + ((PlayerInteractEvent) event).setUseItemInHand(cancel ? Event.Result.DENY : Event.Result.DEFAULT); + ((PlayerInteractEvent) event).setUseInteractedBlock(cancel ? Event.Result.DENY : Event.Result.DEFAULT); } else if (event instanceof BlockCanBuildEvent) { ((BlockCanBuildEvent) event).setBuildable(!cancel); } else if (event instanceof PlayerDropItemEvent) { From b264a1ff8f7ee11ad02f4460db18bead838f8285 Mon Sep 17 00:00:00 2001 From: Efnilite <35348263+Efnilite@users.noreply.github.com> Date: Tue, 10 Sep 2024 18:21:19 +0200 Subject: [PATCH 03/14] appease Pikachu and fix not reaching --- .../ch/njol/skript/effects/EffCancelEvent.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/ch/njol/skript/effects/EffCancelEvent.java b/src/main/java/ch/njol/skript/effects/EffCancelEvent.java index 13a5b7e860f..3d4ec5d386b 100644 --- a/src/main/java/ch/njol/skript/effects/EffCancelEvent.java +++ b/src/main/java/ch/njol/skript/effects/EffCancelEvent.java @@ -36,7 +36,7 @@ public class EffCancelEvent extends Effect { static { - Skript.registerEffect(EffCancelEvent.class, "[:un]cancel [the] event"); + Skript.registerEffect(EffCancelEvent.class, "cancel [the] event", "uncancel [the] event"); } private boolean cancel; @@ -49,24 +49,24 @@ public boolean init(Expression[] expressions, int matchedPattern, Kleenean is return false; } - cancel = !result.hasTag("un"); + cancel = matchedPattern == 0; Class[] currentEvents = getParser().getCurrentEvents(); if (currentEvents == null) return false; - for (Class e : currentEvents) { - if (Cancellable.class.isAssignableFrom(e) || BlockCanBuildEvent.class.isAssignableFrom(e)) + if (cancel && getParser().isCurrentEvent(EntityToggleSwimEvent.class)) + Skript.error("Cancelling a toggle swim event has no effect", ErrorQuality.SEMANTIC_ERROR); + + for (Class event : currentEvents) { + if (Cancellable.class.isAssignableFrom(event) || BlockCanBuildEvent.class.isAssignableFrom(event)) return true; // TODO warning if some event(s) cannot be cancelled even though some can (needs a way to be suppressed) } - if (getParser().isCurrentEvent(PlayerLoginEvent.class)) { + if (getParser().isCurrentEvent(PlayerLoginEvent.class)) Skript.error("A connect event cannot be cancelled, but the player may be kicked ('kick player by reason of \"...\"')", ErrorQuality.SEMANTIC_ERROR); - } else if (getParser().isCurrentEvent(EntityToggleSwimEvent.class)) { - Skript.error("Cancelling a toggle swim event has no effect", ErrorQuality.SEMANTIC_ERROR); - } else { + else Skript.error(Utils.A(getParser().getCurrentEventName()) + " event cannot be cancelled", ErrorQuality.SEMANTIC_ERROR); - } return false; } From 3a2bc5fe36a6fc49f8bd7a1af6ecb98bf1f191ee Mon Sep 17 00:00:00 2001 From: Efnilite <35348263+Efnilite@users.noreply.github.com> Date: Tue, 10 Sep 2024 22:33:39 +0200 Subject: [PATCH 04/14] fix event --- src/test/skript/junit/EffCancelEvent.sk | 4 ++-- .../tests/regressions/7054-cancelling swim toggle.sk | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 src/test/skript/tests/regressions/7054-cancelling swim toggle.sk diff --git a/src/test/skript/junit/EffCancelEvent.sk b/src/test/skript/junit/EffCancelEvent.sk index 7baad602b34..db6e4c9edb5 100644 --- a/src/test/skript/junit/EffCancelEvent.sk +++ b/src/test/skript/junit/EffCancelEvent.sk @@ -1,4 +1,4 @@ -test "SimpleJUnitTest" when running JUnit: +test "EffCancelEventJUnit" when running JUnit: set {_tests::1} to "event not cancelled by default" set {_tests::2} to "cancel event" set {_tests::3} to "uncancel event" @@ -18,4 +18,4 @@ on spawn of pig: uncancel event if event is not cancelled: - complete objective "uncancel event" for {_test} \ No newline at end of file + complete objective "uncancel event" for {_test} diff --git a/src/test/skript/tests/regressions/7054-cancelling swim toggle.sk b/src/test/skript/tests/regressions/7054-cancelling swim toggle.sk new file mode 100644 index 00000000000..6895735034e --- /dev/null +++ b/src/test/skript/tests/regressions/7054-cancelling swim toggle.sk @@ -0,0 +1,9 @@ +parse: + results: {SwimToggle::parse::*} + code: + on swim toggle: + sgsfg + +test "cancelling swim toggle": + send "%{SwimToggle::parse::*}%" to console + assert {SwimToggle::parse::*} contains "Cancelling a toggle swim event has no effect" with "cancelling swim toggle doesn't error" \ No newline at end of file From 1bec68cc6114319e3a66659b53359edd6f9b5151 Mon Sep 17 00:00:00 2001 From: Efnilite <35348263+Efnilite@users.noreply.github.com> Date: Wed, 11 Sep 2024 22:33:10 +0200 Subject: [PATCH 05/14] fix test --- .../skript/tests/regressions/7054-cancelling swim toggle.sk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/skript/tests/regressions/7054-cancelling swim toggle.sk b/src/test/skript/tests/regressions/7054-cancelling swim toggle.sk index 6895735034e..e8a359bb27a 100644 --- a/src/test/skript/tests/regressions/7054-cancelling swim toggle.sk +++ b/src/test/skript/tests/regressions/7054-cancelling swim toggle.sk @@ -2,8 +2,7 @@ parse: results: {SwimToggle::parse::*} code: on swim toggle: - sgsfg + cancel event test "cancelling swim toggle": - send "%{SwimToggle::parse::*}%" to console assert {SwimToggle::parse::*} contains "Cancelling a toggle swim event has no effect" with "cancelling swim toggle doesn't error" \ No newline at end of file From 560cf9145bfcfd8d895bb97b20f2d66276197c44 Mon Sep 17 00:00:00 2001 From: Efnilite <35348263+Efnilite@users.noreply.github.com> Date: Wed, 11 Sep 2024 23:01:22 +0200 Subject: [PATCH 06/14] update --- .../7054-cancelling swim toggle.sk | 8 ------ .../7054-update event cancelling.sk | 26 +++++++++++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) delete mode 100644 src/test/skript/tests/regressions/7054-cancelling swim toggle.sk create mode 100644 src/test/skript/tests/regressions/7054-update event cancelling.sk diff --git a/src/test/skript/tests/regressions/7054-cancelling swim toggle.sk b/src/test/skript/tests/regressions/7054-cancelling swim toggle.sk deleted file mode 100644 index e8a359bb27a..00000000000 --- a/src/test/skript/tests/regressions/7054-cancelling swim toggle.sk +++ /dev/null @@ -1,8 +0,0 @@ -parse: - results: {SwimToggle::parse::*} - code: - on swim toggle: - cancel event - -test "cancelling swim toggle": - assert {SwimToggle::parse::*} contains "Cancelling a toggle swim event has no effect" with "cancelling swim toggle doesn't error" \ No newline at end of file diff --git a/src/test/skript/tests/regressions/7054-update event cancelling.sk b/src/test/skript/tests/regressions/7054-update event cancelling.sk new file mode 100644 index 00000000000..8d15a2c614d --- /dev/null +++ b/src/test/skript/tests/regressions/7054-update event cancelling.sk @@ -0,0 +1,26 @@ +parse: + results: {PlayerLogin::parse::*} + code: + on connect: + cancel event + +parse: + results: {PlayerQuit::parse::*} + code: + on quit: + cancel event + +parse: + results: {SwimToggle::parse::*} + code: + on swim toggle: + cancel event + +test "cancelling swim toggle": + assert {SwimToggle::parse::*} contains "Cancelling a toggle swim event has no effect" with "cancelling swim toggle doesn't error" + +test "cancelling player login": + assert {PlayerLogin::parse::*} contains "A connect event cannot be cancelled, but the player may be kicked ('kick player by reason of \"...\"')" with "cancelling player login doesn't error" + +test "cancelling regular event": + assert {PlayerQuit::parse::*} contains "A quit event cannot be cancelled" with "cancelling regular event doesn't error" From c29a4d24e507b4e1edb975947d676324ce9a7b24 Mon Sep 17 00:00:00 2001 From: Efnilite <35348263+Efnilite@users.noreply.github.com> Date: Thu, 12 Sep 2024 22:52:24 +0200 Subject: [PATCH 07/14] oops --- .../skript/tests/regressions/7054-update event cancelling.sk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/skript/tests/regressions/7054-update event cancelling.sk b/src/test/skript/tests/regressions/7054-update event cancelling.sk index 8d15a2c614d..91a1591249b 100644 --- a/src/test/skript/tests/regressions/7054-update event cancelling.sk +++ b/src/test/skript/tests/regressions/7054-update event cancelling.sk @@ -23,4 +23,4 @@ test "cancelling player login": assert {PlayerLogin::parse::*} contains "A connect event cannot be cancelled, but the player may be kicked ('kick player by reason of \"...\"')" with "cancelling player login doesn't error" test "cancelling regular event": - assert {PlayerQuit::parse::*} contains "A quit event cannot be cancelled" with "cancelling regular event doesn't error" + assert {PlayerQuit::parse::*} contains "An on quit event cannot be cancelled" with "cancelling regular event doesn't error" From 2de8bef1fdcd7e272f7034baae3944202c9773e0 Mon Sep 17 00:00:00 2001 From: Efnilite <35348263+Efnilite@users.noreply.github.com> Date: Thu, 12 Sep 2024 22:58:48 +0200 Subject: [PATCH 08/14] oops --- .../skript/tests/regressions/7054-update event cancelling.sk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/skript/tests/regressions/7054-update event cancelling.sk b/src/test/skript/tests/regressions/7054-update event cancelling.sk index 91a1591249b..5773ca9f42e 100644 --- a/src/test/skript/tests/regressions/7054-update event cancelling.sk +++ b/src/test/skript/tests/regressions/7054-update event cancelling.sk @@ -20,7 +20,7 @@ test "cancelling swim toggle": assert {SwimToggle::parse::*} contains "Cancelling a toggle swim event has no effect" with "cancelling swim toggle doesn't error" test "cancelling player login": - assert {PlayerLogin::parse::*} contains "A connect event cannot be cancelled, but the player may be kicked ('kick player by reason of \"...\"')" with "cancelling player login doesn't error" + assert {PlayerLogin::parse::*} contains "A connect event cannot be cancelled, but the player may be kicked (\'kick player by reason of \"...\"\')" with "cancelling player login doesn't error" test "cancelling regular event": assert {PlayerQuit::parse::*} contains "An on quit event cannot be cancelled" with "cancelling regular event doesn't error" From 47a280b11add09c4b8785375b2848d9e73762602 Mon Sep 17 00:00:00 2001 From: Efnilite <35348263+Efnilite@users.noreply.github.com> Date: Thu, 12 Sep 2024 23:14:01 +0200 Subject: [PATCH 09/14] stupid quotes --- .../skript/tests/regressions/7054-update event cancelling.sk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/skript/tests/regressions/7054-update event cancelling.sk b/src/test/skript/tests/regressions/7054-update event cancelling.sk index 5773ca9f42e..8a371308d8d 100644 --- a/src/test/skript/tests/regressions/7054-update event cancelling.sk +++ b/src/test/skript/tests/regressions/7054-update event cancelling.sk @@ -20,7 +20,7 @@ test "cancelling swim toggle": assert {SwimToggle::parse::*} contains "Cancelling a toggle swim event has no effect" with "cancelling swim toggle doesn't error" test "cancelling player login": - assert {PlayerLogin::parse::*} contains "A connect event cannot be cancelled, but the player may be kicked (\'kick player by reason of \"...\"\')" with "cancelling player login doesn't error" + assert {PlayerLogin::parse::*} contains "A connect event cannot be cancelled, but the player may be kicked ('kick player by reason of ""...""')" with "cancelling player login doesn't error" test "cancelling regular event": assert {PlayerQuit::parse::*} contains "An on quit event cannot be cancelled" with "cancelling regular event doesn't error" From a81aa46e910ed3edb3d5f3a594a4f05088a4876a Mon Sep 17 00:00:00 2001 From: Efnilite <35348263+Efnilite@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:20:52 +0200 Subject: [PATCH 10/14] fix shutdown delay --- .../test/tests/syntaxes/effects/EffCancelEventTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffCancelEventTest.java b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffCancelEventTest.java index a1546d69005..9b9320570c3 100644 --- a/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffCancelEventTest.java +++ b/src/test/java/org/skriptlang/skript/test/tests/syntaxes/effects/EffCancelEventTest.java @@ -5,6 +5,10 @@ public class EffCancelEventTest extends SkriptJUnitTest { + static { + setShutdownDelay(1); + } + @Test public void test() { spawnTestPig(); From 2436b988f84082852bbc2810d5fef0aadd40729e Mon Sep 17 00:00:00 2001 From: Efy <35348263+Efnilite@users.noreply.github.com> Date: Fri, 13 Sep 2024 19:23:38 +0200 Subject: [PATCH 11/14] Update src/main/java/ch/njol/skript/effects/EffCancelEvent.java Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> --- src/main/java/ch/njol/skript/effects/EffCancelEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/effects/EffCancelEvent.java b/src/main/java/ch/njol/skript/effects/EffCancelEvent.java index 3d4ec5d386b..0f07ead4c12 100644 --- a/src/main/java/ch/njol/skript/effects/EffCancelEvent.java +++ b/src/main/java/ch/njol/skript/effects/EffCancelEvent.java @@ -56,7 +56,7 @@ public boolean init(Expression[] expressions, int matchedPattern, Kleenean is return false; if (cancel && getParser().isCurrentEvent(EntityToggleSwimEvent.class)) - Skript.error("Cancelling a toggle swim event has no effect", ErrorQuality.SEMANTIC_ERROR); + Skript.error("Cancelling a toggle swim event has no effect"); for (Class event : currentEvents) { if (Cancellable.class.isAssignableFrom(event) || BlockCanBuildEvent.class.isAssignableFrom(event)) From 30df66856ec62bb0819fb002cf815cf16f1fd355 Mon Sep 17 00:00:00 2001 From: Efnilite <35348263+Efnilite@users.noreply.github.com> Date: Sat, 28 Sep 2024 17:02:19 +0200 Subject: [PATCH 12/14] update --- src/main/java/ch/njol/skript/effects/EffCancelEvent.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/njol/skript/effects/EffCancelEvent.java b/src/main/java/ch/njol/skript/effects/EffCancelEvent.java index 0f07ead4c12..97e941d8436 100644 --- a/src/main/java/ch/njol/skript/effects/EffCancelEvent.java +++ b/src/main/java/ch/njol/skript/effects/EffCancelEvent.java @@ -40,10 +40,10 @@ public class EffCancelEvent extends Effect { } private boolean cancel; - - @SuppressWarnings("null") + @Override - public boolean init(Expression[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult result) { + public boolean init(Expression[] expressions, int matchedPattern, + Kleenean isDelayed, ParseResult parseResult) { if (isDelayed == Kleenean.TRUE) { Skript.error("Can't cancel an event after it has already passed", ErrorQuality.SEMANTIC_ERROR); return false; From 8290693b9ce3c6dfee77d802e63eb007ca53e72b Mon Sep 17 00:00:00 2001 From: Efy <35348263+Efnilite@users.noreply.github.com> Date: Tue, 1 Oct 2024 18:24:16 +0200 Subject: [PATCH 13/14] Update src/main/java/ch/njol/skript/effects/EffCancelEvent.java Co-authored-by: Patrick Miller --- src/main/java/ch/njol/skript/effects/EffCancelEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/effects/EffCancelEvent.java b/src/main/java/ch/njol/skript/effects/EffCancelEvent.java index 97e941d8436..d92bb4c1c17 100644 --- a/src/main/java/ch/njol/skript/effects/EffCancelEvent.java +++ b/src/main/java/ch/njol/skript/effects/EffCancelEvent.java @@ -45,7 +45,7 @@ public class EffCancelEvent extends Effect { public boolean init(Expression[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { if (isDelayed == Kleenean.TRUE) { - Skript.error("Can't cancel an event after it has already passed", ErrorQuality.SEMANTIC_ERROR); + Skript.error("An event cannot be cancelled after it has already passed", ErrorQuality.SEMANTIC_ERROR); return false; } From 1b07749752d93b4409b1375d12bb950aeea97faa Mon Sep 17 00:00:00 2001 From: Efnilite <35348263+Efnilite@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:53:51 +0200 Subject: [PATCH 14/14] fix not returning false --- src/main/java/ch/njol/skript/effects/EffCancelEvent.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/effects/EffCancelEvent.java b/src/main/java/ch/njol/skript/effects/EffCancelEvent.java index 97e941d8436..905d1967da2 100644 --- a/src/main/java/ch/njol/skript/effects/EffCancelEvent.java +++ b/src/main/java/ch/njol/skript/effects/EffCancelEvent.java @@ -55,8 +55,10 @@ public boolean init(Expression[] expressions, int matchedPattern, if (currentEvents == null) return false; - if (cancel && getParser().isCurrentEvent(EntityToggleSwimEvent.class)) + if (cancel && getParser().isCurrentEvent(EntityToggleSwimEvent.class)) { Skript.error("Cancelling a toggle swim event has no effect"); + return false; + } for (Class event : currentEvents) { if (Cancellable.class.isAssignableFrom(event) || BlockCanBuildEvent.class.isAssignableFrom(event))