-
-
Notifications
You must be signed in to change notification settings - Fork 9
GH-352 Add Arc Riders style flare - firework - indicating players death location #352
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
Open
CitralFlo
wants to merge
10
commits into
master
Choose a base branch
from
add-flare-from-arc-riders
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+294
β39
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
955c884
Innit
CitralFlo df8cbc9
geminaj review
CitralFlo 2b4707f
Add try catch
CitralFlo f65f021
CR
Rollczi 5e1c63b
CR 2
Rollczi 9aad758
Add flare damage cancel. Add info to config
CitralFlo b820c43
make it private
CitralFlo e24da46
Resolve ImDMK review
CitralFlo af466cd
CR
Rollczi 8a05d4c
CR
Rollczi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
...combat-plugin/src/main/java/com/eternalcode/combat/fight/death/DeathEffectController.java
This file was deleted.
Oops, something went wrong.
126 changes: 126 additions & 0 deletions
126
...lcombat-plugin/src/main/java/com/eternalcode/combat/fight/death/DeathFlareController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| package com.eternalcode.combat.fight.death; | ||
|
|
||
| import com.eternalcode.combat.config.implementation.PluginConfig; | ||
| import com.eternalcode.combat.fight.event.CauseOfUnTag; | ||
| import com.eternalcode.combat.fight.event.FightUntagEvent; | ||
| import com.eternalcode.commons.scheduler.Scheduler; | ||
| import com.eternalcode.commons.scheduler.Task; | ||
| import java.time.Duration; | ||
| import java.util.UUID; | ||
| import java.util.concurrent.atomic.AtomicReference; | ||
| import org.bukkit.Color; | ||
| import org.bukkit.FireworkEffect; | ||
| import org.bukkit.Location; | ||
| import org.bukkit.Server; | ||
| import org.bukkit.World; | ||
| import org.bukkit.entity.Firework; | ||
| import org.bukkit.entity.Player; | ||
| import org.bukkit.event.EventHandler; | ||
| import org.bukkit.event.EventPriority; | ||
| import org.bukkit.event.Listener; | ||
| import org.bukkit.event.entity.PlayerDeathEvent; | ||
| import org.bukkit.inventory.meta.FireworkMeta; | ||
|
|
||
| public class DeathFlareController implements Listener { | ||
|
|
||
| private final PluginConfig pluginConfig; | ||
| private final Server server; | ||
| private final Scheduler scheduler; | ||
|
|
||
| public DeathFlareController(PluginConfig pluginConfig, Server server, Scheduler scheduler) { | ||
| this.pluginConfig = pluginConfig; | ||
| this.server = server; | ||
| this.scheduler = scheduler; | ||
| } | ||
|
|
||
| @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
| public void onFightUntagEvent(FightUntagEvent event) { | ||
| CauseOfUnTag cause = event.getCause(); | ||
| if (!cause.equals(CauseOfUnTag.DEATH) && !cause.equals(CauseOfUnTag.DEATH_BY_PLAYER)) { | ||
CitralFlo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return; | ||
| } | ||
|
|
||
| UUID uniqueId = event.getPlayer(); | ||
| Player player = this.server.getPlayer(uniqueId); | ||
|
|
||
| if (player == null ) { | ||
| return; | ||
| } | ||
CitralFlo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if (this.pluginConfig.death.firework.inCombat && !this.pluginConfig.death.firework.afterEveryDeath) { | ||
| this.spawnFlare(player); | ||
| } | ||
CitralFlo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
| public void onPlayerDeathEventLightning(PlayerDeathEvent event) { | ||
| Player player = event.getEntity(); | ||
|
|
||
| if (this.pluginConfig.death.firework.afterEveryDeath) { | ||
| this.spawnFlare(player); | ||
| } | ||
| } | ||
|
|
||
| private void spawnFlare(Player player) { | ||
| Location deathLocation = player.getLocation(); | ||
| World world = deathLocation.getWorld(); | ||
|
|
||
| Firework flare = world.spawn(deathLocation, Firework.class); | ||
| FireworkMeta meta = flare.getFireworkMeta(); | ||
|
|
||
| FireworkEffect effect = FireworkEffect.builder() | ||
| .with(this.pluginConfig.death.firework.fireworkType) | ||
| .withColor(Color.fromRGB(Integer.decode(this.pluginConfig.death.firework.primaryColor))) | ||
| .withFade(Color.fromRGB(Integer.decode(this.pluginConfig.death.firework.fadeColor))) | ||
CitralFlo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .trail(true) | ||
| .flicker(true) | ||
| .build(); | ||
|
|
||
| meta.addEffect(effect); | ||
| meta.setPower(this.pluginConfig.death.firework.power); | ||
| flare.setFireworkMeta(meta); | ||
|
|
||
| if (this.pluginConfig.death.firework.enabled) { | ||
| AtomicReference<Task> taskRef = new AtomicReference<>(); | ||
|
|
||
| Task task = this.scheduler.timerAsync(() -> { | ||
| if (flare.isDead() || !flare.isValid()) { | ||
| Task currentTask = taskRef.get(); | ||
| if (currentTask != null) { | ||
| currentTask.cancel(); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| this.spawnParticles(world, flare); | ||
|
|
||
| }, Duration.ZERO, Duration.ofMillis(50)); | ||
|
|
||
| taskRef.set(task); | ||
| } | ||
CitralFlo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| private void spawnParticles(World world, Firework flare) { | ||
| Location location = flare.getLocation(); | ||
|
|
||
| world.spawnParticle( | ||
| this.pluginConfig.death.firework.mainParticle.get(), | ||
| location, | ||
| this.pluginConfig.death.firework.mainParticleCount, | ||
| 0.05, | ||
| 0.05, | ||
| 0.05, | ||
| 0.01 | ||
| ); | ||
|
|
||
| world.spawnParticle( | ||
| this.pluginConfig.death.firework.secondaryParticle.get(), | ||
| location, | ||
| this.pluginConfig.death.firework.secondaryParticleCount, | ||
| 0.1, | ||
| 0.1, | ||
| 0.1, | ||
| 0.01 | ||
| ); | ||
| } | ||
| } | ||
55 changes: 55 additions & 0 deletions
55
...bat-plugin/src/main/java/com/eternalcode/combat/fight/death/DeathLightningController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package com.eternalcode.combat.fight.death; | ||
|
|
||
| import com.eternalcode.combat.config.implementation.PluginConfig; | ||
| import com.eternalcode.combat.fight.event.CauseOfUnTag; | ||
| import com.eternalcode.combat.fight.event.FightUntagEvent; | ||
| import java.util.UUID; | ||
| import org.bukkit.Server; | ||
| import org.bukkit.entity.Player; | ||
| import org.bukkit.event.EventHandler; | ||
| import org.bukkit.event.EventPriority; | ||
| import org.bukkit.event.Listener; | ||
| import org.bukkit.event.entity.PlayerDeathEvent; | ||
|
|
||
| public class DeathLightningController implements Listener { | ||
|
|
||
| private final PluginConfig pluginConfig; | ||
| private final Server server; | ||
|
|
||
| public DeathLightningController(PluginConfig pluginConfig, Server server) { | ||
| this.pluginConfig = pluginConfig; | ||
| this.server = server; | ||
| } | ||
|
|
||
| @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
| public void onFightUntagEvent(FightUntagEvent event) { | ||
| CauseOfUnTag cause = event.getCause(); | ||
| if (!cause.equals(CauseOfUnTag.DEATH) && !cause.equals(CauseOfUnTag.DEATH_BY_PLAYER)) { | ||
CitralFlo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return; | ||
| } | ||
|
|
||
| UUID uniqueId = event.getPlayer(); | ||
| Player player = this.server.getPlayer(uniqueId); | ||
|
|
||
| if (player == null ) { | ||
| return; | ||
| } | ||
|
|
||
| if (this.pluginConfig.death.lightning.inCombat && !this.pluginConfig.death.lightning.afterEveryDeath) { | ||
| this.lightningStrike(player); | ||
CitralFlo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
| public void onPlayerDeathEventLightning(PlayerDeathEvent event) { | ||
| Player player = event.getEntity(); | ||
|
|
||
| if (this.pluginConfig.death.lightning.afterEveryDeath) { | ||
| lightningStrike(player); | ||
| } | ||
| } | ||
|
|
||
| private void lightningStrike(Player player) { | ||
| player.getWorld().strikeLightningEffect(player.getLocation()); | ||
| } | ||
| } | ||
71 changes: 69 additions & 2 deletions
71
eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/death/DeathSettings.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,77 @@ | ||
| package com.eternalcode.combat.fight.death; | ||
|
|
||
| import com.cryptomorin.xseries.particles.XParticle; | ||
| import eu.okaeri.configs.OkaeriConfig; | ||
| import eu.okaeri.configs.annotation.Comment; | ||
| import org.bukkit.FireworkEffect; | ||
|
|
||
| public class DeathSettings extends OkaeriConfig { | ||
|
|
||
| @Comment("Should lightning strike when a player dies") | ||
| public boolean lightning = true; | ||
| @Comment({ | ||
| "Settings related to lightning effect upon death", | ||
| "Setting afterEveryDeath and inCombat will disable this feature completely" | ||
| }) | ||
CitralFlo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public LightningSettings lightning = new LightningSettings(); | ||
|
|
||
| public static class LightningSettings extends OkaeriConfig { | ||
|
|
||
| @Comment("Should lightning spawn on every death?") | ||
| public boolean afterEveryDeath = false; | ||
|
|
||
| @Comment("Should lightning spawn on ONLY deaths in combat?") | ||
| public boolean inCombat = true; | ||
| } | ||
|
|
||
| @Comment({ | ||
| "Settings for the Arc Raiders style flare (firework)", | ||
| "Setting afterEveryDeath and inCombat will disable this feature completely" | ||
| }) | ||
CitralFlo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public FlareSettings firework = new FlareSettings(); | ||
|
|
||
| public static class FlareSettings extends OkaeriConfig { | ||
|
|
||
| @Comment("Should firework (flare) spawn on every death?") | ||
| public boolean afterEveryDeath = false; | ||
|
|
||
| @Comment("Should firework (flare) spawn on ONLY deaths in combat?") | ||
| public boolean inCombat = true; | ||
|
|
||
| @Comment("Power of firework - how long till explosion") | ||
| public int power = 2; | ||
|
|
||
| @Comment({ | ||
| "The firework (flare) effect type (BALL, BALL_LARGE, STAR, BURST, CREEPER)", | ||
| "Reference: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/FireworkEffect.Type.html" | ||
| }) | ||
| public FireworkEffect.Type fireworkType = FireworkEffect.Type.BALL; | ||
|
|
||
| @Comment("Hex color for the firework (flare)") | ||
| public String primaryColor = "#a80022"; | ||
|
|
||
| @Comment("Hex color for the fade of firework (flare)") | ||
| public String fadeColor = "#0a0a0a"; | ||
|
|
||
| @Comment("Toggle on/off additional particles spawned in the firework (flare) path") | ||
| public boolean enabled = true; | ||
|
|
||
| @Comment({ | ||
| "The main trail particle (e.g., CAMPFIRE_COSY_SMOKE, SMOKE_LARGE)", | ||
| "Reference: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html" | ||
| }) | ||
| public XParticle mainParticle = XParticle.CAMPFIRE_COSY_SMOKE; | ||
|
|
||
| @Comment("Count of main particles spawned on each tick") | ||
| public int mainParticleCount = 3; | ||
|
|
||
| @Comment({ | ||
| "The secondary trail particle (e.g., CAMPFIRE_COSY_SMOKE, SMOKE_LARGE)", | ||
| "Reference: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html" | ||
| }) | ||
|
|
||
| public XParticle secondaryParticle = XParticle.SMALL_FLAME; | ||
|
|
||
| @Comment("Count of secondary particles spawned on each tick") | ||
| public int secondaryParticleCount = 3; | ||
|
|
||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.