Skip to content

Commit

Permalink
Additional style settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Esophose committed Feb 6, 2020
1 parent 48eca45 commit ae8db5a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public enum Setting {
PARTICLE_RENDER_RANGE_PLAYER("particle-render-range-player", 48, "From how many blocks away should a player be able to see the particles from another player?"),
PARTICLE_RENDER_RANGE_FIXED_EFFECT("particle-render-range-fixed-effect", 192, "From how many blocks away should a player be able to see the particles from a fixed effect?"),
RAINBOW_CYCLE_SPEED("rainbow-cycle-speed", 2, "How many out of 360 hue ticks to move per game tick", "Higher values make the rainbow cycle faster", "Note: Must be a positive whole number"),
DUST_SIZE("dust-size", 1, "How large should dust particles appear?", "Note: Can include decimals", "Only works in 1.13+"),
DUST_SIZE("dust-size", 1.0, "How large should dust particles appear?", "Note: Can include decimals", "Only works in 1.13+"),

MYSQL_SETTINGS("mysql-settings", null, "Settings for if you want to use MySQL for data management"),
MYSQL_ENABLED("mysql-settings.enabled", false, "Enable MySQL", "If false, SQLite will be used instead"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@
import java.util.Arrays;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;

public class ParticleStyleArrows extends DefaultParticleStyle implements Listener {

private static final String[] arrowEntityNames = new String[] { "ARROW", "SPECTRAL_ARROW", "TIPPED_ARROW" };
private List<Projectile> arrows = new ArrayList<>();

private int maxArrowsPerPlayer;
private boolean onlySpawnIfFlying;
private List<String> arrowEntityNames;

public ParticleStyleArrows() {
super("arrows", false, false, 0);
Expand Down Expand Up @@ -61,31 +60,30 @@ public void updateTimers() {
}

/**
* The event used to get all arrows fired by players
* Adds all arrows fired from players to the array
*
* @param e The EntityShootBowEvent
* The event used to get all projectiles fired by players
* Adds all projectiles fired from players to the array
*
* @param event The ProjectileLaunchEvent
*/
@EventHandler
public void onArrowFired(EntityShootBowEvent e) {
if (e.getEntityType() != EntityType.PLAYER)
return;

String entityName = e.getProjectile().getType().toString();
if (Arrays.stream(arrowEntityNames).anyMatch(entityName::equalsIgnoreCase))
this.arrows.add((Projectile) e.getProjectile());
public void onProjectileLaunch(ProjectileLaunchEvent event) {
String entityName = event.getEntity().getType().name();
if (this.arrowEntityNames.contains(entityName))
this.arrows.add(event.getEntity());
}

@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
this.setIfNotExists("max-arrows-per-player", 10, "The max number of arrows that will spawn particles per player");
this.setIfNotExists("only-spawn-if-flying", false, "Only spawn particles while the arrow is still in the air");
this.setIfNotExists("arrow-entities", Arrays.asList("ARROW", "SPECTRAL_ARROW", "TIPPED_ARROW"), "The name of the projectile entities that are counted as arrows");
}

@Override
protected void loadSettings(CommentedFileConfiguration config) {
this.maxArrowsPerPlayer = config.getInt("max-arrows-per-player");
this.onlySpawnIfFlying = config.getBoolean("only-spawn-if-flying");
this.arrowEntityNames = config.getStringList("arrow-entities");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class ParticleStyleOrbit extends DefaultParticleStyle {

private int orbs;
private int numSteps;
private double radius;

public ParticleStyleOrbit() {
super("orbit", true, true, 0);
Expand All @@ -23,8 +24,8 @@ public ParticleStyleOrbit() {
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
for (int i = 0; i < this.orbs; i++) {
double dx = -(MathL.cos((this.step / (double) this.numSteps) * (Math.PI * 2) + (((Math.PI * 2) / this.orbs) * i)));
double dz = -(MathL.sin((this.step / (double) this.numSteps) * (Math.PI * 2) + (((Math.PI * 2) / this.orbs) * i)));
double dx = -(MathL.cos((this.step / (double) this.numSteps) * (Math.PI * 2) + (((Math.PI * 2) / this.orbs) * i))) * this.radius;
double dz = -(MathL.sin((this.step / (double) this.numSteps) * (Math.PI * 2) + (((Math.PI * 2) / this.orbs) * i))) * this.radius;
particles.add(new PParticle(location.clone().add(dx, 0, dz)));
}
return particles;
Expand All @@ -39,12 +40,14 @@ public void updateTimers() {
protected void setDefaultSettings(CommentedFileConfiguration config) {
this.setIfNotExists("orbs", 3, "The number of orbs that orbit the player");
this.setIfNotExists("steps", 120, "The number of spawning steps around the player");
this.setIfNotExists("radius", 1.0, "The radius for spawning the orbs");
}

@Override
protected void loadSettings(CommentedFileConfiguration config) {
this.orbs = config.getInt("orbs");
this.numSteps = config.getInt("steps");
this.radius = config.getDouble("radius");
}

}

0 comments on commit ae8db5a

Please sign in to comment.