From 22a2bfb421655a9f48ba5da683d7bcc33bac2bbf Mon Sep 17 00:00:00 2001 From: potaro Date: Sat, 27 Jul 2024 16:03:01 -0400 Subject: [PATCH 01/10] Fix sorting indices of a list with children (#6897) --- .../ch/njol/skript/expressions/ExprIndices.java | 9 ++++++++- .../6881-sorted indices with children.sk | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/test/skript/tests/regressions/6881-sorted indices with children.sk diff --git a/src/main/java/ch/njol/skript/expressions/ExprIndices.java b/src/main/java/ch/njol/skript/expressions/ExprIndices.java index c09bfe81964..87dffe51ae5 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprIndices.java +++ b/src/main/java/ch/njol/skript/expressions/ExprIndices.java @@ -30,6 +30,7 @@ import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.util.LiteralUtils; import ch.njol.util.Kleenean; +import ch.njol.util.Pair; import org.bukkit.event.Event; import org.eclipse.jdt.annotation.Nullable; @@ -101,8 +102,14 @@ protected String[] get(Event e) { if (sort) { int direction = descending ? -1 : 1; return variable.entrySet().stream() + .map((entry) -> new Pair<>( + entry.getKey(), + entry.getValue() instanceof Map + ? ((Map) entry.getValue()).get(null) + : entry.getValue() + )) .sorted((a, b) -> ExprSortedList.compare(a.getValue(), b.getValue()) * direction) - .map(Entry::getKey) + .map(Pair::getKey) .toArray(String[]::new); } diff --git a/src/test/skript/tests/regressions/6881-sorted indices with children.sk b/src/test/skript/tests/regressions/6881-sorted indices with children.sk new file mode 100644 index 00000000000..3b7826e90d5 --- /dev/null +++ b/src/test/skript/tests/regressions/6881-sorted indices with children.sk @@ -0,0 +1,15 @@ +test "sorted indices with children": + set {_test::1} to 111 + set {_test::2} to 555 + set {_test::3} to 444 + set {_test::1::a} to 2 + set {_test::2::b} to 3 + set {_test::3::c} to 6 + set {_test::3::a::foo} to "i" + set {_test::3::b::bar} to "love" + set {_test::3::c::baz} to "skript" + set {_indices::*} to (sorted indices of {_test::*} in ascending order) + + assert {_indices::*} is ("1", "3", "2") with "sorted indices on list with children threw or was incorrect" + assert {_test::*} is (111, 555, 444) with "modified children wrongly" + assert {_test::3::*} is 6 with "modified children wrongly" From 97e43868ba54558232aa02925cbd529e83353966 Mon Sep 17 00:00:00 2001 From: Shane Bee Date: Wed, 31 Jul 2024 08:34:10 -0700 Subject: [PATCH 02/10] Properly name PotionEffectType in lang (#6854) --- src/main/resources/lang/default.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/lang/default.lang b/src/main/resources/lang/default.lang index 3e4bc87b7a4..2fa3c5164e0 100644 --- a/src/main/resources/lang/default.lang +++ b/src/main/resources/lang/default.lang @@ -2322,7 +2322,7 @@ types: itemstack: item stack¦s @an itementity: dropped item¦s @a # same as entities.dropped item.name biome: biome¦s @a - potioneffecttype: potion¦s @a + potioneffecttype: potion effect type¦s @a potioneffect: potion effect¦s @a enchantment: enchantment¦s @an damagecause: damage cause¦s @a From a30b33fe4e9d92651c178716ea60f6ede9a37585 Mon Sep 17 00:00:00 2001 From: sovdee <10354869+sovdeeth@users.noreply.github.com> Date: Wed, 31 Jul 2024 09:27:46 -0700 Subject: [PATCH 03/10] allow pufferfish as entitydata (#6919) --- src/main/resources/lang/default.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/lang/default.lang b/src/main/resources/lang/default.lang index 2fa3c5164e0..8678c5f5525 100644 --- a/src/main/resources/lang/default.lang +++ b/src/main/resources/lang/default.lang @@ -1061,7 +1061,7 @@ entities: pattern: salmon(|1¦s) puffer fish: name: puffer fish¦es - pattern: puffer fish(|1¦es) + pattern: puffer[ ]fish(|1¦es) tropical fish: name: tropical fish¦es pattern: tropical fish(|1¦es) From 598bfb652099ea4d17c55d3fcd7acdc90c439b72 Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Thu, 1 Aug 2024 10:28:23 -0400 Subject: [PATCH 04/10] Fixes an error with SimplifiedChinese language file (#6932) --- src/main/resources/lang/simplifiedchinese.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/lang/simplifiedchinese.lang b/src/main/resources/lang/simplifiedchinese.lang index 9daa56b74c2..b502f9068aa 100644 --- a/src/main/resources/lang/simplifiedchinese.lang +++ b/src/main/resources/lang/simplifiedchinese.lang @@ -15,7 +15,7 @@ skript: invalid reload: Skript只能通过Bukkit的“/reload”或Skript的“/skript reload”命令来重新加载。 no scripts: 没有发现任何脚本,也许你应该写一些 ;) no errors: 所有脚本都已加载,没有错误。 - scripts loaded: 已加载%s个脚本,包括%s个结构和%s个命令(%s内) + scripts loaded: 已加载%s个脚本,总共包含%s个结构。 (耗时%s) finished loading: 已完成加载。 # -- Skript command -- From 88addb3cfd357382886ef052f58c197f0f82206c Mon Sep 17 00:00:00 2001 From: Patrick Miller Date: Thu, 1 Aug 2024 11:08:26 -0400 Subject: [PATCH 05/10] Fix missing aliases not regenerating for reloads (#6949) --- src/main/java/ch/njol/skript/aliases/AliasesProvider.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/ch/njol/skript/aliases/AliasesProvider.java b/src/main/java/ch/njol/skript/aliases/AliasesProvider.java index cccf91618ed..cce78c4ef71 100644 --- a/src/main/java/ch/njol/skript/aliases/AliasesProvider.java +++ b/src/main/java/ch/njol/skript/aliases/AliasesProvider.java @@ -416,6 +416,7 @@ public EntityData getRelatedEntity(ItemData item) { public void clearAliases() { aliases.clear(); + materials.clear(); variations.clear(); aliasesMap.clear(); } From ad1a492053b232c47c91f7f7fd95c75c408e8eed Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:29:45 -0400 Subject: [PATCH 06/10] Adds new spawn reasons for 1.21 (#6906) --- src/main/resources/lang/default.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/lang/default.lang b/src/main/resources/lang/default.lang index 8678c5f5525..59fa474fec6 100644 --- a/src/main/resources/lang/default.lang +++ b/src/main/resources/lang/default.lang @@ -2099,8 +2099,10 @@ spawn reasons: natural: natural nether_portal: nether portal ocelot_baby: ocelot baby + ominous_item_spawner: ominous item spawner patrol: patrol piglin_zombified: piglin zombification + potion_effect: potion effect raid: raid reinforcements: reinforcements sheared: shear, sheared From 2f94384df3c645ae796a792efd5180204d79316f Mon Sep 17 00:00:00 2001 From: Patrick Miller Date: Thu, 1 Aug 2024 11:35:48 -0400 Subject: [PATCH 07/10] Delay listening behavior logic until after the event implementation initializes (#6948) --- .../java/ch/njol/skript/events/EvtMove.java | 3 +-- .../java/ch/njol/skript/lang/SkriptEvent.java | 17 +++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/ch/njol/skript/events/EvtMove.java b/src/main/java/ch/njol/skript/events/EvtMove.java index 01aa9436072..0eec1d9aa1c 100644 --- a/src/main/java/ch/njol/skript/events/EvtMove.java +++ b/src/main/java/ch/njol/skript/events/EvtMove.java @@ -132,7 +132,6 @@ public boolean check(Event event) { } @Override - @Nullable @SuppressWarnings("unchecked") public Class [] getEventClasses() { if (isPlayer) { @@ -140,7 +139,7 @@ public boolean check(Event event) { } else if (HAS_ENTITY_MOVE) { return new Class[] {EntityMoveEvent.class}; } - return null; + throw new IllegalStateException("This event has not yet initialized!"); } @Override diff --git a/src/main/java/ch/njol/skript/lang/SkriptEvent.java b/src/main/java/ch/njol/skript/lang/SkriptEvent.java index 145115a4460..83145335fcc 100644 --- a/src/main/java/ch/njol/skript/lang/SkriptEvent.java +++ b/src/main/java/ch/njol/skript/lang/SkriptEvent.java @@ -85,8 +85,17 @@ public final boolean init(Literal[] args, int matchedPattern, ParseResult par throw new IllegalStateException(); skriptEventInfo = (SkriptEventInfo) syntaxElementInfo; + assert entryContainer != null; // cannot be null for non-simple structures + this.source = entryContainer.getSource(); + + // use default value for now + listeningBehavior = eventData.getListenerBehavior(); + + // initialize implementation + if (!init(args, matchedPattern, parseResult)) + return false; + // evaluate whether this event supports listening to cancelled events - supportsListeningBehavior = false; for (Class eventClass : getEventClasses()) { if (Cancellable.class.isAssignableFrom(eventClass)) { supportsListeningBehavior = true; @@ -94,7 +103,6 @@ public final boolean init(Literal[] args, int matchedPattern, ParseResult par } } - listeningBehavior = eventData.getListenerBehavior(); // if the behavior is non-null, it was set by the user if (listeningBehavior != null && !isListeningBehaviorSupported()) { String eventName = skriptEventInfo.name.toLowerCase(Locale.ENGLISH); @@ -102,10 +110,7 @@ public final boolean init(Literal[] args, int matchedPattern, ParseResult par return false; } - assert entryContainer != null; // cannot be null for non-simple structures - this.source = entryContainer.getSource(); - - return init(args, matchedPattern, parseResult); + return true; } /** From c53a57ee6da030f36f6df1868b47eaf8396384dd Mon Sep 17 00:00:00 2001 From: Patrick Miller Date: Thu, 1 Aug 2024 12:20:09 -0400 Subject: [PATCH 08/10] Fix ExprRemainingAir Negative Value Handling (#6947) --- .../skript/expressions/ExprRemainingAir.java | 131 +++++++----------- .../syntaxes/expressions/ExprRemainingAir.sk | 18 +++ 2 files changed, 70 insertions(+), 79 deletions(-) create mode 100644 src/test/skript/tests/syntaxes/expressions/ExprRemainingAir.sk diff --git a/src/main/java/ch/njol/skript/expressions/ExprRemainingAir.java b/src/main/java/ch/njol/skript/expressions/ExprRemainingAir.java index 57b07d4d641..9c2d5f0e036 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprRemainingAir.java +++ b/src/main/java/ch/njol/skript/expressions/ExprRemainingAir.java @@ -1,28 +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.expressions; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.Event; -import org.eclipse.jdt.annotation.Nullable; - -import ch.njol.skript.classes.Changer; import ch.njol.skript.classes.Changer.ChangeMode; import ch.njol.skript.doc.Description; import ch.njol.skript.doc.Examples; @@ -30,79 +7,75 @@ import ch.njol.skript.doc.Since; import ch.njol.skript.expressions.base.SimplePropertyExpression; import ch.njol.skript.util.Timespan; +import ch.njol.skript.util.Timespan.TimePeriod; import ch.njol.util.coll.CollectionUtils; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.Event; +import org.jetbrains.annotations.Nullable; -/** - * @author Peter Güttinger - */ @Name("Remaining Air") @Description("How much time a player has left underwater before starting to drown.") -@Examples({"player's remaining air is less than 3 seconds:", - " send \"hurry, get to the surface!\" to the player"}) -@Since("unknown (before 2.1)") +@Examples({ + "if the player's remaining air is less than 3 seconds:", + "\tsend \"hurry, get to the surface!\" to the player" +}) +@Since("2.0") public class ExprRemainingAir extends SimplePropertyExpression { static { register(ExprRemainingAir.class, Timespan.class, "remaining air", "livingentities"); } - - @Override - public Class getReturnType() { - return Timespan.class; - } - - @Override - protected String getPropertyName() { - return "remaining air"; - } - - @Override - public Timespan convert(final LivingEntity entity) { - return Timespan.fromTicks(entity.getRemainingAir()); - } - - @Nullable + @Override - public Class[] acceptChange(Changer.ChangeMode mode) { - return (mode != ChangeMode.REMOVE_ALL) ? CollectionUtils.array(Timespan.class) : null; + public Timespan convert(LivingEntity entity) { + /* + * negative values are allowed, and Minecraft itself may return a negative value from -1 to -20 + * these negative values seem to control when the entity actually takes damage + * that is, when it hits -20, the entity takes damage, and it goes back to 0 + * for simplicity, we cap it at 0 seconds (as it is still the case that the entity has no air) + */ + return new Timespan(TimePeriod.TICK, Math.max(0, entity.getRemainingAir())); } - - @SuppressWarnings("null") + @Override - public void change(Event event, @Nullable Object[] delta, Changer.ChangeMode mode) { + public Class @Nullable [] acceptChange(ChangeMode mode) { switch (mode) { case ADD: - long ticks = ((Timespan)delta[0]).getTicks(); - for (LivingEntity entity : getExpr().getArray(event)) { - int newTicks = entity.getRemainingAir() + (int) ticks; - - // Sanitize remaining air to avoid client hangs/crashes - if (newTicks > 20000) // 1000 seconds - newTicks = 20000; - entity.setRemainingAir(newTicks); - } - break; - case REMOVE: - ticks = ((Timespan)delta[0]).getTicks(); - for (LivingEntity entity : getExpr().getArray(event)) - entity.setRemainingAir(entity.getRemainingAir() - (int) ticks); - break; case SET: - ticks = ((Timespan)delta[0]).getTicks(); - // Sanitize remaining air to avoid client hangs/crashes - if (ticks > 20000) // 1000 seconds - ticks = 20000; - - for (LivingEntity entity : getExpr().getArray(event)) - entity.setRemainingAir((int) ticks); - break; + case REMOVE: case DELETE: - case REMOVE_ALL: case RESET: - for (LivingEntity entity : getExpr().getArray(event)) - entity.setRemainingAir(20 * 15); // 15 seconds of air - break; + return CollectionUtils.array(Timespan.class); + default: + return null; } } - + + @Override + public void change(Event event, Object @Nullable [] delta, ChangeMode mode) { + // default is 15 seconds of air + long changeValue = delta != null ? ((Timespan) delta[0]).getAs(TimePeriod.TICK) : 20 * 15; + if (mode == ChangeMode.REMOVE) // subtract the change value + changeValue *= -1; + for (LivingEntity entity : getExpr().getArray(event)) { + long newRemainingAir = 0; + if (mode == ChangeMode.ADD || mode == ChangeMode.REMOVE) + newRemainingAir = entity.getRemainingAir(); + // while entities have a "maximum air", the value is allowed to go past it + // while negative values are permitted, the behavior is strange + newRemainingAir = Math.max(Math.min(newRemainingAir + changeValue, Integer.MAX_VALUE), 0); + entity.setRemainingAir((int) newRemainingAir); + } + } + + @Override + public Class getReturnType() { + return Timespan.class; + } + + @Override + protected String getPropertyName() { + return "remaining air"; + } + } diff --git a/src/test/skript/tests/syntaxes/expressions/ExprRemainingAir.sk b/src/test/skript/tests/syntaxes/expressions/ExprRemainingAir.sk new file mode 100644 index 00000000000..3f9f5041db7 --- /dev/null +++ b/src/test/skript/tests/syntaxes/expressions/ExprRemainingAir.sk @@ -0,0 +1,18 @@ +test "remaining air": + + spawn a pig at location of spawn of world "world": + set {_e} to event-entity + + reset remaining air of {_e} + assert remaining air of {_e} is 15 seconds with "resetting did not set to 15 seconds" + + set remaining air of {_e} to 3 years + assert remaining air of {_e} is 3 years with "setting to 3 years did not work" + + remove 5 years from remaining air of {_e} + assert remaining air of {_e} is 0 seconds with "removing did not limit to 0 seconds" + + add 10 years to remaining air of {_e} + assert ticks of remaining air of {_e} is 2147483647 with "adding did not limit to max int value" + + delete the entity within {_e} From a93ace5e38b3e56ab628e1e81ea69daa70526cf7 Mon Sep 17 00:00:00 2001 From: sovdee <10354869+sovdeeth@users.noreply.github.com> Date: Thu, 1 Aug 2024 09:27:50 -0700 Subject: [PATCH 09/10] Fix missing EffPlaySound version checks (#6910) --- .../ch/njol/skript/effects/EffPlaySound.java | 44 ++++++++++++------- ...7-playsound entity method doesn't exist.sk | 3 ++ 2 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 src/test/skript/tests/regressions/6907-playsound entity method doesn't exist.sk diff --git a/src/main/java/ch/njol/skript/effects/EffPlaySound.java b/src/main/java/ch/njol/skript/effects/EffPlaySound.java index 88459bc44f9..686f7334671 100644 --- a/src/main/java/ch/njol/skript/effects/EffPlaySound.java +++ b/src/main/java/ch/njol/skript/effects/EffPlaySound.java @@ -44,6 +44,7 @@ import java.util.Locale; import java.util.OptionalLong; +import java.util.regex.Matcher; import java.util.regex.Pattern; @Name("Play Sound") @@ -53,7 +54,7 @@ "Spigot sound names " + "are supported. Playing resource pack sounds are supported too. The sound category is 'master' by default. ", "", - "Playing a sound from an entity directly will result in the sound coming from said entity, even while moving.", + "When running 1.18+, playing a sound from an entity directly will result in the sound coming from said entity, even while moving.", "If the sound is custom, a location emitter will follow the entity. Do note that pitch and volume ", "are reflected based on the entity, and Minecraft may not use the values from this syntax.", "", @@ -68,22 +69,27 @@ "play sound \"custom.music.1\" in jukebox category at {speakerBlock}", "play sound \"BLOCK_AMETHYST_BLOCK_RESONATE\" with seed 1 on target entity for the player #1.20.1+" }) -@RequiredPlugins("Paper 1.19.4+ or Adventure API 4.12.0+ (sound seed)") +@RequiredPlugins("Minecraft 1.18.1+ (entity emitters), Paper 1.19.4+ or Adventure API 4.12.0+ (sound seed)") @Since("2.2-dev28, 2.4 (sound categories), 2.9.0 (sound seed & entity emitter)") public class EffPlaySound extends Effect { private static final boolean ADVENTURE_API = Skript.classExists("net.kyori.adventure.sound.Sound$Builder"); - public static final Pattern KEY_PATTERN = Pattern.compile("([a-z0-9._-]+:)?[a-z0-9/._-]+"); + private static final boolean PLAYER_ENTITY_EMITTER = Skript.methodExists(Player.class, "playSound", Entity.class, Sound.class, SoundCategory.class, float.class, float.class); + private static final boolean WORLD_ENTITY_EMITTER = Skript.methodExists(World.class, "playSound", Entity.class, String.class, SoundCategory.class, float.class, float.class); + public static final Pattern KEY_PATTERN = Pattern.compile("([a-z0-9._-]+:)?([a-z0-9/._-]+)"); static { String additional = ""; if (ADVENTURE_API) additional = "[[with] seed %-number%] "; + String emitterTypes = "locations"; + if (PLAYER_ENTITY_EMITTER) + emitterTypes += "/entities"; Skript.registerEffect(EffPlaySound.class, "play sound[s] %strings% " + additional + "[(in|from) %-soundcategory%] " + - "[(at|with) volume %-number%] [(and|at|with) pitch %-number%] (at|on|from) %locations/entities% [(to|for) %-players%]", + "[(at|with) volume %-number%] [(and|at|with) pitch %-number%] (at|on|from) %" + emitterTypes + "% [(to|for) %-players%]", "play sound[s] %strings% " + additional + "[(in|from) %-soundcategory%] " + - "[(at|with) volume %-number%] [(and|at|with) pitch %-number%] [(to|for) %players%] [(at|on|from) %-locations/entities%]" + "[(at|with) volume %-number%] [(and|at|with) pitch %-number%] [(to|for) %players%] [(at|on|from) %-" + emitterTypes + "%]" ); } @@ -148,19 +154,19 @@ protected void execute(Event event) { if (players != null) { if (emitters == null) { for (Player player : players.getArray(event)) { - play(Player::playSound, Player::playSound, ADVENTURE_API ? Player::playSound : null, ADVENTURE_API ? Player::playSound : null, + play(PLAYER_ENTITY_EMITTER ? Player::playSound : null, Player::playSound, ADVENTURE_API ? Player::playSound : null, ADVENTURE_API ? Player::playSound : null, player, player.getLocation(), sounds.getArray(event), category, volume, pitch, seed); } } else { for (Player player : players.getArray(event)) { for (Object emitter : emitters.getArray(event)) { - if (emitter instanceof Entity) { + if (emitter instanceof Entity && PLAYER_ENTITY_EMITTER) { Entity entity = (Entity) emitter; play(Player::playSound, Player::playSound, ADVENTURE_API ? Player::playSound : null, ADVENTURE_API ? Player::playSound : null, player, entity, sounds.getArray(event), category, volume, pitch, seed); } else if (emitter instanceof Location) { Location location = (Location) emitter; - play(Player::playSound, Player::playSound, ADVENTURE_API ? Player::playSound : null, ADVENTURE_API ? Player::playSound : null, + play(PLAYER_ENTITY_EMITTER ? Player::playSound : null, Player::playSound, ADVENTURE_API ? Player::playSound : null, ADVENTURE_API ? Player::playSound : null, player, location, sounds.getArray(event), category, volume, pitch, seed); } } @@ -168,13 +174,13 @@ protected void execute(Event event) { } } else if (emitters != null) { for (Object emitter : emitters.getArray(event)) { - if (emitter instanceof Entity) { + if (emitter instanceof Entity && WORLD_ENTITY_EMITTER) { Entity entity = (Entity) emitter; play(World::playSound, World::playSound, ADVENTURE_API ? World::playSound : null, ADVENTURE_API ? World::playSound : null, entity.getWorld(), entity, sounds.getArray(event), category, volume, pitch, seed); } else if (emitter instanceof Location) { Location location = (Location) emitter; - play(World::playSound, World::playSound, ADVENTURE_API ? World::playSound : null, ADVENTURE_API ? World::playSound : null, + play(WORLD_ENTITY_EMITTER ? World::playSound : null, World::playSound, ADVENTURE_API ? World::playSound : null, ADVENTURE_API ? World::playSound : null, location.getWorld(), location, sounds.getArray(event), category, volume, pitch, seed); } } @@ -203,7 +209,7 @@ public String toString(@Nullable Event event, boolean debug) { return builder.toString(); } - private void play(@NotNull SoundReceiver entityReceiver, + private void play(@Nullable SoundReceiver entityReceiver, @NotNull SoundReceiver locationReceiver, @Nullable AdventureEmitterSoundReceiver adventureLocationReceiver, @Nullable AdventureEntitySoundReceiver adventureEmitterReceiver, @@ -224,7 +230,7 @@ void play( ); static void play( - @NotNull SoundReceiver entityReceiver, + @Nullable SoundReceiver entityReceiver, @NotNull SoundReceiver locationReceiver, @NotNull T receiver, @NotNull E emitter, @NotNull String[] sounds, @NotNull SoundCategory category, float volume, float pitch, OptionalLong seed @@ -236,10 +242,18 @@ static void play( key = enumSound.getKey(); } catch (IllegalArgumentException alternative) { sound = sound.toLowerCase(Locale.ENGLISH); - if (!KEY_PATTERN.matcher(sound).matches()) + Matcher keyMatcher = KEY_PATTERN.matcher(sound); + if (!keyMatcher.matches()) continue; try { - key = NamespacedKey.fromString(sound); + String namespace = keyMatcher.group(1); + String keyValue = keyMatcher.group(2); + if (namespace == null) { + key = NamespacedKey.minecraft(keyValue); + } else { + namespace = namespace.substring(0, namespace.length() - 1); + key = new NamespacedKey(namespace, keyValue); + } } catch (IllegalArgumentException argument) { // The user input invalid characters } @@ -249,7 +263,7 @@ static void play( continue; if (emitter instanceof Location) { locationReceiver.play(receiver, (Location) emitter, key.getKey(), category, volume, pitch); - } else if (emitter instanceof Entity) { + } else if (emitter instanceof Entity && entityReceiver != null) { entityReceiver.play(receiver, (Entity) emitter, key.getKey(), category, volume, pitch); } return; diff --git a/src/test/skript/tests/regressions/6907-playsound entity method doesn't exist.sk b/src/test/skript/tests/regressions/6907-playsound entity method doesn't exist.sk new file mode 100644 index 00000000000..8c14277c5b3 --- /dev/null +++ b/src/test/skript/tests/regressions/6907-playsound entity method doesn't exist.sk @@ -0,0 +1,3 @@ +test "1.17 playsound exception": + # would throw exception on <1.17 + play sound "entity.experience_orb.pickup" with volume 1 at spawn of world "world" From 72b17b22f399180c99083b4f65eb764b2672583b Mon Sep 17 00:00:00 2001 From: APickledWalrus Date: Thu, 1 Aug 2024 14:01:36 -0400 Subject: [PATCH 10/10] Prepare For Release (2.9.1) --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 80e986f1ef1..befe897fdfc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.parallel=true groupid=ch.njol name=skript -version=2.9.0 +version=2.9.1 jarName=Skript.jar testEnv=java21/paper-1.21.0 testEnvJavaVersion=21