Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firework effect section #5542

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
be31180
Added Firework Launch Effect Section and removed Firework Launch effect.
TFSMads Jun 9, 2022
e90f26e
Merge branch 'master' into feature/laucnhEffSec
TFSMads Jun 9, 2022
08c9164
Update src/main/java/ch/njol/skript/sections/EffSecFireworkLaunch.java
TFSMads Jun 9, 2022
2c89cba
Update src/main/java/ch/njol/skript/sections/EffSecFireworkLaunch.java
TFSMads Jun 9, 2022
ef7885b
Update src/main/java/ch/njol/skript/sections/EffSecFireworkLaunch.java
TFSMads Jun 10, 2022
50e0a26
Update src/test/skript/tests/syntaxes/sections/EffSecFireworkLaunch.sk
TFSMads Jun 10, 2022
d3bf799
Update src/main/java/ch/njol/skript/sections/EffSecFireworkLaunch.java
TFSMads Jun 10, 2022
33d8f6a
Update EffSecFireworkLaunch.java
TFSMads Jun 10, 2022
99be168
Update EffSecFireworkLaunch.java
TFSMads Jun 10, 2022
ae10ac5
Merge branch 'master' into feature/laucnhEffSec
TFSMads Jun 10, 2022
b13ad8c
Merge branch 'master' into feature/laucnhEffSec
TheLimeGlass Jun 30, 2022
9b189d6
Changed from %number% to %-number%
TFSMads Jul 14, 2022
6dc151c
Update EffSecFireworkLaunch.java
TFSMads Jul 14, 2022
6235d08
Update src/main/java/ch/njol/skript/sections/EffSecFireworkLaunch.java
TFSMads Jul 14, 2022
6f0157d
Update src/test/skript/tests/syntaxes/sections/EffSecFireworkLaunch.sk
TFSMads Jul 14, 2022
c46239a
Merge branch 'master' into feature/laucnhEffSec
TFSMads Jul 14, 2022
6157d51
Update src/main/java/ch/njol/skript/sections/EffSecFireworkLaunch.java
TFSMads Jul 15, 2022
456282a
Update src/main/java/ch/njol/skript/sections/EffSecFireworkLaunch.java
TFSMads Jul 15, 2022
8fc13c0
Update EffSecFireworkLaunch.java
TFSMads Jul 15, 2022
242717b
Check if varibles from section is carried over to the initial section
TFSMads Jul 15, 2022
ff2a955
Added requested changes:
TFSMads Jul 18, 2022
a4d5d81
Merge branch 'master' into feature/laucnhEffSec
TFSMads Jul 18, 2022
251c06e
Apply suggestions from code review
TFSMads Jul 28, 2022
31b8dc6
Take over stale pull request
TheLimeGlass Mar 21, 2023
fc358a2
Apply changes to the new class
TheLimeGlass Mar 21, 2023
28222cc
Final touches
TheLimeGlass Mar 21, 2023
28eef10
Fix incorrect examples
TheLimeGlass Mar 21, 2023
384be9f
Merge branch 'dev/feature' into feature/firework-effect-section
TheLimeGlass Apr 29, 2024
9559c50
Change collect order of local variables
TheLimeGlass Apr 29, 2024
2fa34d4
Fix old bukkit consumer issues with spawning firework
TheLimeGlass Apr 29, 2024
3ff79b4
Change collect order of local variables
TheLimeGlass Apr 29, 2024
3277e4b
Merge branch 'dev/feature' into feature/firework-effect-section
sovdeeth Jun 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 0 additions & 94 deletions src/main/java/ch/njol/skript/effects/EffFireworkLaunch.java

This file was deleted.

11 changes: 9 additions & 2 deletions src/main/java/ch/njol/skript/entity/EntityData.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.eclipse.jdt.annotation.Nullable;
import org.jetbrains.annotations.ApiStatus.ScheduledForRemoval;

import ch.njol.skript.Skript;
import ch.njol.skript.SkriptAPIException;
Expand Down Expand Up @@ -674,8 +675,14 @@ protected boolean deserialize(final String s) {
return false;
}

@SuppressWarnings({"unchecked", "deprecation"})
protected static <E extends Entity> @Nullable E spawn(Location location, Class<E> type, Consumer<E> consumer) {
/**
* Utility method to handle Bukkit changing from org.bukkit.util.Consumer to java Consumer.
* Subject to removal in the future, when some older versions get dropped.
*/
@Deprecated
@ScheduledForRemoval
@SuppressWarnings("unchecked")
public static <E extends Entity> @Nullable E spawn(Location location, Class<E> type, Consumer<E> consumer) {
World world = location.getWorld();
if (world == null)
return null;
Expand Down
60 changes: 31 additions & 29 deletions src/main/java/ch/njol/skript/expressions/ExprLastSpawnedEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

import java.lang.reflect.Array;

import ch.njol.skript.effects.EffFireworkLaunch;
import ch.njol.skript.sections.EffSecSpawn;
import ch.njol.util.coll.CollectionUtils;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Item;
Expand All @@ -44,12 +41,18 @@
import ch.njol.skript.lang.Literal;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.skript.sections.EffSecFireworkLaunch;
import ch.njol.skript.sections.EffSecSpawn;
import ch.njol.util.Kleenean;

@Name("Last Spawned Entity")
@Description("Holds the entity that was spawned most recently with the spawn effect (section), dropped with the <a href='../effects/#EffDrop'>drop effect</a>, shot with the <a href='../effects/#EffShoot'>shoot effect</a> or created with the <a href='../effects/#EffLightning'>lightning effect</a>. " +
"Please note that even though you can spawn multiple mobs simultaneously (e.g. with 'spawn 5 creepers'), only the last spawned mob is saved and can be used. " +
"If you spawn an entity, shoot a projectile and drop an item you can however access all them together.")
@Description({
"Holds the entity that was spawned most recently with the spawn effect (section), dropped with the <a href='../effects/#EffDrop'>drop effect</a>,",
"shot with the <a href='../effects/#EffShoot'>shoot effect</a>, launched firework <a href='../sections/#EffSecFireworkLaunch'>firework launch effect section</a>,",
"or created with the <a href='../effects/#EffLightning'>lightning effect</a>.",
"Please note that even though you can spawn multiple mobs simultaneously (e.g. with 'spawn 5 creepers'), only the last spawned mob is saved and can be used.",
"If you spawn an entity, shoot a projectile and drop an item you can however access all them together."
})
@Examples({
"spawn a priest",
"set {healer::%spawned priest%} to true",
Expand All @@ -62,16 +65,15 @@
})
@Since("1.3 (spawned entity), 2.0 (shot entity), 2.2-dev26 (dropped item), 2.7 (struck lightning, firework)")
public class ExprLastSpawnedEntity extends SimpleExpression<Entity> {

static {
Skript.registerExpression(ExprLastSpawnedEntity.class, Entity.class, ExpressionType.SIMPLE,
"[the] [last[ly]] (0:spawned|1:shot) %*entitydata%",
"[the] [last[ly]] dropped (2:item)",
"[the] [last[ly]] (created|struck) (3:lightning)",
"[the] [last[ly]] (launched|deployed) (4:firework)");
"[the] [last[ly]] (0:spawned|1:shot) %*entitydata%",
"[the] [last[ly]] dropped (2:item)",
"[the] [last[ly]] (created|struck) (3:lightning)",
"[the] [last[ly]] (launched|deployed) (4:firework)");
}

@SuppressWarnings("NotNullFieldNotInitialized")

private EntityData<?> type;
private int from;

Expand All @@ -90,51 +92,51 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
}
return true;
}

@Override
@Nullable
protected Entity[] get(Event event) {
Entity en;
Entity entity;
switch (from) {
case 0:
en = EffSecSpawn.lastSpawned;
entity = EffSecSpawn.lastSpawned;
break;
case 1:
en = EffShoot.lastSpawned;
entity = EffShoot.lastSpawned;
break;
case 2:
en = EffDrop.lastSpawned;
entity = EffDrop.lastSpawned;
break;
case 3:
en = EffLightning.lastSpawned;
entity = EffLightning.lastSpawned;
break;
case 4:
en = EffFireworkLaunch.lastSpawned;
entity = EffSecFireworkLaunch.lastSpawned;
break;
default:
en = null;
entity = null;
}

if (en == null)
if (entity == null)
return null;
if (!type.isInstance(en))
if (!type.isInstance(entity))
return null;

Entity[] one = (Entity[]) Array.newInstance(type.getType(), 1);
one[0] = en;
one[0] = entity;
return one;
}

@Override
public boolean isSingle() {
return true;
}

@Override
public Class<? extends Entity> getReturnType() {
return type.getType();
}

@Override
public String toString(@Nullable Event event, boolean debug) {
String word = "";
Expand All @@ -157,7 +159,7 @@ public String toString(@Nullable Event event, boolean debug) {
default:
assert false;
}
return "the last " + word + " " + type;
return "last " + word + " " + type;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "last " + word + " " + type;
return "the last " + word + " " + type;

it's better to be verbose for toString IMO

}

}
Loading
Loading