Additional style settings

This commit is contained in:
Esophose 2020-02-06 04:37:50 -07:00
parent 48eca45e6a
commit ae8db5a33a
3 changed files with 18 additions and 17 deletions

View file

@ -54,7 +54,7 @@ public class ConfigurationManager extends Manager {
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_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?"), 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"), 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_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"), MYSQL_ENABLED("mysql-settings.enabled", false, "Enable MySQL", "If false, SQLite will be used instead"),

View file

@ -7,20 +7,19 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileLaunchEvent;
public class ParticleStyleArrows extends DefaultParticleStyle implements Listener { 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 List<Projectile> arrows = new ArrayList<>();
private int maxArrowsPerPlayer; private int maxArrowsPerPlayer;
private boolean onlySpawnIfFlying; private boolean onlySpawnIfFlying;
private List<String> arrowEntityNames;
public ParticleStyleArrows() { public ParticleStyleArrows() {
super("arrows", false, false, 0); super("arrows", false, false, 0);
@ -61,31 +60,30 @@ public class ParticleStyleArrows extends DefaultParticleStyle implements Listene
} }
/** /**
* The event used to get all arrows fired by players * The event used to get all projectiles fired by players
* Adds all arrows fired from players to the array * Adds all projectiles fired from players to the array
* *
* @param e The EntityShootBowEvent * @param event The ProjectileLaunchEvent
*/ */
@EventHandler @EventHandler
public void onArrowFired(EntityShootBowEvent e) { public void onProjectileLaunch(ProjectileLaunchEvent event) {
if (e.getEntityType() != EntityType.PLAYER) String entityName = event.getEntity().getType().name();
return; if (this.arrowEntityNames.contains(entityName))
this.arrows.add(event.getEntity());
String entityName = e.getProjectile().getType().toString();
if (Arrays.stream(arrowEntityNames).anyMatch(entityName::equalsIgnoreCase))
this.arrows.add((Projectile) e.getProjectile());
} }
@Override @Override
protected void setDefaultSettings(CommentedFileConfiguration config) { 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("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("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 @Override
protected void loadSettings(CommentedFileConfiguration config) { protected void loadSettings(CommentedFileConfiguration config) {
this.maxArrowsPerPlayer = config.getInt("max-arrows-per-player"); this.maxArrowsPerPlayer = config.getInt("max-arrows-per-player");
this.onlySpawnIfFlying = config.getBoolean("only-spawn-if-flying"); this.onlySpawnIfFlying = config.getBoolean("only-spawn-if-flying");
this.arrowEntityNames = config.getStringList("arrow-entities");
} }
} }

View file

@ -14,6 +14,7 @@ public class ParticleStyleOrbit extends DefaultParticleStyle {
private int orbs; private int orbs;
private int numSteps; private int numSteps;
private double radius;
public ParticleStyleOrbit() { public ParticleStyleOrbit() {
super("orbit", true, true, 0); super("orbit", true, true, 0);
@ -23,8 +24,8 @@ public class ParticleStyleOrbit extends DefaultParticleStyle {
public List<PParticle> getParticles(ParticlePair particle, Location location) { public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>(); List<PParticle> particles = new ArrayList<>();
for (int i = 0; i < this.orbs; i++) { 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 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))); 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))); particles.add(new PParticle(location.clone().add(dx, 0, dz)));
} }
return particles; return particles;
@ -39,12 +40,14 @@ public class ParticleStyleOrbit extends DefaultParticleStyle {
protected void setDefaultSettings(CommentedFileConfiguration config) { protected void setDefaultSettings(CommentedFileConfiguration config) {
this.setIfNotExists("orbs", 3, "The number of orbs that orbit the player"); 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("steps", 120, "The number of spawning steps around the player");
this.setIfNotExists("radius", 1.0, "The radius for spawning the orbs");
} }
@Override @Override
protected void loadSettings(CommentedFileConfiguration config) { protected void loadSettings(CommentedFileConfiguration config) {
this.orbs = config.getInt("orbs"); this.orbs = config.getInt("orbs");
this.numSteps = config.getInt("steps"); this.numSteps = config.getInt("steps");
this.radius = config.getDouble("radius");
} }
} }