From 3604220cf5788b4322d733a308c514c2c150ad21 Mon Sep 17 00:00:00 2001 From: NemesisMate Date: Wed, 20 Feb 2019 20:22:05 +0100 Subject: [PATCH] Change some overloads of ParticleEmitterNode.removeInfluencer methods to return the removed influencer --- .../java/tonegod/emitter/ParticleEmitterNode.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/tonegod/emitter/ParticleEmitterNode.java b/src/main/java/tonegod/emitter/ParticleEmitterNode.java index 5996c7b..934f7e8 100644 --- a/src/main/java/tonegod/emitter/ParticleEmitterNode.java +++ b/src/main/java/tonegod/emitter/ParticleEmitterNode.java @@ -1408,13 +1408,14 @@ public void removeInfluencer(@NotNull ParticleInfluencer influencer) { * * @param index the influencer's index. */ - public void removeInfluencer(int index) { - + public ParticleInfluencer removeInfluencer(int index) { + ParticleInfluencer influencer = influencers.get(index); + if (index < 0) { return; } - storeInfluencerData(influencers.get(index), index); + storeInfluencerData(influencer, index); for (int i = index, length = influencers.size(); i < length; i++) { moveInfluencerData(i + 1, i); @@ -1422,6 +1423,8 @@ public void removeInfluencer(int index) { influencers.remove(index); requiresUpdate = true; + + return influencer; } /** @@ -1529,14 +1532,16 @@ protected void storeInfluencerData(@NotNull ParticleInfluencer influencer, in * @param the influencer's type. * @param type the class of the influencer to remove. */ - public > void removeInfluencer(@NotNull Class type) { - + public > T removeInfluencer(@NotNull Class type) { T influencer = getInfluencer(type); + if (influencer == null) { return; } removeInfluencer(influencer); + + return influencer; } /**