Add initial settings files for particle styles

This commit is contained in:
Esophose 2020-01-10 05:05:22 -07:00
parent f7b4a38b68
commit 950a39f6d6
43 changed files with 660 additions and 451 deletions

View file

@ -2,17 +2,19 @@
* TODO: v7.0
* + Add ability to create/manage fixed effects from the GUI
* * Convert fixed effect ids into names
* + Add command '/pp fixed teleport <id>' that requires the permission playerparticles.fixed.teleport
* + Add named colors to the color data autocomplete
* * Clean up duplicated command parsing
* + Add effect/style name customization through config files
* + Add effect/style settings folder that lets you disable effects/style and edit style properties
* + Add setting to disable particles while in combat
* + Add a command aliases section to the config
* * /ppo now uses your permissions instead of the player you are targetting
*
*/
/*
* + Added a setting 'dust-size' to change the size of dust particles in 1.13+
* * Cleaned up duplicated command parsing
* + Added command '/pp fixed teleport <id>' that requires the permission playerparticles.fixed.teleport
* + Added named colors to the color data autocomplete
* + Added an API, accessible through the dev.esophose.playerparticles.api.PlayerParticlesAPI class
* * Refactored the DataManager to only handle saving/loading data
* * Refactored and cleaned up code to remove static abuse
@ -30,9 +32,7 @@
* Renamed command-error-no-effects to command-error-missing-effects-or-styles
* Changed message for command-error-missing-effects-or-styles
* Added message gui-no-permission
*
* NEEDS TRANSLATING:
* SECTION TITLED this.put("#23.5", "Fixed Teleport Message");
* Added messages for fixed particles under the section #23.5
*/
package dev.esophose.playerparticles;

View file

@ -25,8 +25,8 @@ public class ListCommandModule implements CommandModule {
localeManager.sendMessage(pplayer, "list-you-have");
for (ParticlePair particle : particles) {
StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", particle.getId())
.addPlaceholder("effect", particle.getEffect())
.addPlaceholder("style", particle.getStyle())
.addPlaceholder("effect", particle.getEffect().getName())
.addPlaceholder("style", particle.getStyle().getName())
.addPlaceholder("data", particle.getDataString())
.build();
localeManager.sendMessage(pplayer, "list-output", stringPlaceholders);

View file

@ -2,19 +2,23 @@ package dev.esophose.playerparticles.command;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.ParticleStyleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.styles.DefaultStyles;
import java.util.ArrayList;
import java.util.List;
public class ReloadCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
if (PlayerParticles.getInstance().getManager(PermissionManager.class).canReloadPlugin(pplayer.getMessageDestination())) {
PlayerParticles.getInstance().reload();
PlayerParticles playerParticles = PlayerParticles.getInstance();
LocaleManager localeManager = playerParticles.getManager(LocaleManager.class);
if (playerParticles.getManager(PermissionManager.class).canReloadPlugin(pplayer.getMessageDestination())) {
playerParticles.reload();
DefaultStyles.reloadSettings(playerParticles.getManager(ParticleStyleManager.class));
localeManager.sendMessage(pplayer, "reload-success");
PlayerParticles.getInstance().getLogger().info("Reloaded configuration.");
playerParticles.getLogger().info("Reloaded configuration.");
} else {
localeManager.sendMessage(pplayer, "reload-no-permission");
}

View file

@ -50,7 +50,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_FIXED_EFFECT("particle-render-range-fixed-effect", 32, "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"),
DUST_SIZE("dust-size", 1, "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"),

View file

@ -18,7 +18,9 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
@ -136,6 +138,7 @@ public class DataManager extends Manager {
try (PreparedStatement statement = connection.prepareStatement(groupQuery)) {
statement.setString(1, playerUUID.toString());
Set<String> modifiedGroups = new HashSet<>();
ResultSet result = statement.executeQuery();
while (result.next()) {
// Group properties
@ -151,11 +154,16 @@ public class DataManager extends Manager {
OrdinaryColor color = new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b"));
ParticlePair particle = new ParticlePair(playerUUID, id, effect, style, itemMaterial, blockMaterial, color, noteColor);
boolean invalid = effect == null || style == null;
if (invalid) // Effect or style is now missing or disabled, remove the particle
modifiedGroups.add(groupName);
// Try to add particle to an existing group
boolean groupAlreadyExists = false;
for (ParticleGroup group : groups.values()) {
if (group.getName().equalsIgnoreCase(groupName)) {
group.getParticles().put(particle.getId(), particle);
if (!invalid)
group.getParticles().put(particle.getId(), particle);
groupAlreadyExists = true;
break;
}
@ -164,11 +172,20 @@ public class DataManager extends Manager {
// Add the particle to a new group if one didn't already exist
if (!groupAlreadyExists) {
HashMap<Integer, ParticlePair> particles = new HashMap<>();
particles.put(particle.getId(), particle);
if (!invalid)
particles.put(particle.getId(), particle);
ParticleGroup newGroup = new ParticleGroup(groupName, particles);
groups.put(newGroup.getName().toLowerCase(), newGroup);
}
}
// Update modified groups
for (String modifiedGroup : modifiedGroups) {
ParticleGroup group = groups.get(modifiedGroup.toLowerCase());
this.saveParticleGroup(playerUUID, group);
if (group.getParticles().isEmpty() && !group.getName().equals(ParticleGroup.DEFAULT_NAME))
groups.remove(modifiedGroup);
}
}
// Load fixed effects
@ -202,6 +219,12 @@ public class DataManager extends Manager {
OrdinaryColor color = new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b"));
ParticlePair particle = new ParticlePair(playerUUID, particleId, effect, style, itemMaterial, blockMaterial, color, noteColor);
// Effect or style is now missing or disabled, remove the fixed effect
if (effect == null || style == null) {
this.removeFixedEffect(playerUUID, fixedEffectId);
continue;
}
fixedParticles.put(fixedEffectId, new FixedParticleEffect(playerUUID, fixedEffectId, new Location(world, xPos, yPos, zPos), particle));
}
}
@ -270,12 +293,17 @@ public class DataManager extends Manager {
}
/**
* Saves a ParticleGroup. If it already exists, update it.
* Saves a ParticleGroup. If it already exists, update it. If it's empty, delete it.
*
* @param playerUUID The owner of the group
* @param group The group to create/update
*/
public void saveParticleGroup(UUID playerUUID, ParticleGroup group) {
if (group.getParticles().isEmpty() && !group.getName().equals(ParticleGroup.DEFAULT_NAME)) {
this.removeParticleGroup(playerUUID, group.getName());
return;
}
this.async(() -> this.databaseConnector.connect((connection) -> {
String groupUUID;

View file

@ -5,6 +5,7 @@ import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.styles.ParticleStyle;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class ParticleStyleManager extends Manager {
@ -82,11 +83,16 @@ public class ParticleStyleManager extends Manager {
}
/**
* Gets all registered styles
*
* @return A List of ParticleStyles that are registered
* @return A List of styles that are registered and enabled
*/
public List<ParticleStyle> getStyles() {
return this.styles.stream().filter(ParticleStyle::isEnabled).collect(Collectors.toList());
}
/**
* @return all registered styles, regardless if they are enabled or not
*/
public List<ParticleStyle> getStylesWithDisabled() {
return this.styles;
}

View file

@ -200,7 +200,7 @@ public class PermissionManager extends Manager {
*/
public List<String> getEffectNamesUserHasPermissionFor(Player p) {
List<String> list = new ArrayList<>();
for (ParticleEffect pe : ParticleEffect.getSupportedEffects())
for (ParticleEffect pe : ParticleEffect.getEnabledEffects())
if (this.hasEffectPermission(p, pe))
list.add(pe.getName());
return list;
@ -242,7 +242,7 @@ public class PermissionManager extends Manager {
*/
public List<ParticleEffect> getEffectsUserHasPermissionFor(Player p) {
List<ParticleEffect> list = new ArrayList<>();
for (ParticleEffect pe : ParticleEffect.getSupportedEffects())
for (ParticleEffect pe : ParticleEffect.getEnabledEffects())
if (this.hasEffectPermission(p, pe))
list.add(pe);
return list;

View file

@ -141,11 +141,11 @@ public enum ParticleEffect {
}
/**
* Returns a ParticleEffect List of all supported effects for the server version
* Returns a ParticleEffect List of all enabled effects for the server version
*
* @return Supported effects
* @return Enabled effects
*/
public static List<ParticleEffect> getSupportedEffects() {
public static List<ParticleEffect> getEnabledEffects() {
List<ParticleEffect> effects = new ArrayList<>();
for (ParticleEffect pe : values())
if (pe.isSupported())

View file

@ -0,0 +1,127 @@
package dev.esophose.playerparticles.styles;
import com.google.common.collect.ObjectArrays;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.util.ParticleUtils;
import java.io.File;
public abstract class DefaultParticleStyle implements ParticleStyle {
protected PlayerParticles playerParticles;
private CommentedFileConfiguration config;
private String styleName;
private boolean canBeFixedByDefault;
private boolean canToggleWithMovementByDefault;
private double fixedEffectOffsetByDefault;
private boolean enabled;
private boolean canBeFixed;
private boolean canToggleWithMovement;
private double fixedEffectOffset;
public DefaultParticleStyle(String styleName, boolean canBeFixedByDefault, boolean canToggleWithMovementByDefault, double fixedEffectOffsetByDefault) {
this.styleName = styleName;
this.canBeFixedByDefault = canBeFixedByDefault;
this.canToggleWithMovementByDefault = canToggleWithMovementByDefault;
this.fixedEffectOffsetByDefault = fixedEffectOffsetByDefault;
this.playerParticles = PlayerParticles.getInstance();
this.setDefaultSettings();
this.loadSettings(false);
}
/**
* Sets the default settings shared for each style then calls setDefaultSettings(CommentedFileConfiguration)
*/
private void setDefaultSettings() {
File directory = new File(this.playerParticles.getDataFolder(), "styles");
directory.mkdirs();
File file = new File(directory, this.getName() + ".yml");
this.config = CommentedFileConfiguration.loadConfiguration(PlayerParticles.getInstance(), file);
this.setIfNotExists("enabled", true, "If the style is enabled or not");
this.setIfNotExists("can-be-fixed", this.canBeFixedByDefault, "If the style can be used in /pp fixed");
this.setIfNotExists("can-toggle-with-movement", this.canToggleWithMovementByDefault, "If the style will only be shown at the player's feet while moving");
this.setIfNotExists("fixed-effect-offset", this.fixedEffectOffsetByDefault, "How far vertically to offset the style position for fixed effects");
this.setDefaultSettings(this.config);
this.config.save();
}
/**
* Loads the settings shared for each style then calls loadSettings(CommentedFileConfiguration)
*/
public final void loadSettings(boolean reloadConfig) {
if (reloadConfig)
this.config.reloadConfig();
this.enabled = this.config.getBoolean("enabled");
this.canBeFixed = this.config.getBoolean("can-be-fixed");
this.canToggleWithMovement = this.config.getBoolean("can-toggle-with-movement");
this.fixedEffectOffset = this.config.getDouble("fixed-effect-offset");
this.loadSettings(this.config);
}
/**
* Sets a value to the config if it doesn't already exist
*
* @param setting The setting name
* @param value The setting value
*/
protected final void setIfNotExists(String setting, Object value, String... comments) {
if (this.config.get(setting) != null)
return;
String defaultMessage = "Default: ";
if (value instanceof String && ParticleUtils.containsConfigSpecialCharacters((String) value)) {
defaultMessage += "'" + value + "'";
} else {
defaultMessage += value;
}
this.config.set(setting, value, ObjectArrays.concat(comments, new String[] { defaultMessage }, String.class));
}
@Override
public final boolean isEnabled() {
return this.enabled;
}
@Override
public final String getName() {
return this.styleName;
}
@Override
public final boolean canBeFixed() {
return this.canBeFixed;
}
@Override
public final boolean canToggleWithMovement() {
return this.canToggleWithMovement;
}
@Override
public final double getFixedEffectOffset() {
return this.fixedEffectOffset;
}
/**
* Sets the default settings for this style
*
* @param config The config to save to
*/
protected abstract void setDefaultSettings(CommentedFileConfiguration config);
/**
* Loads the settings for this style
*
* @param config The config to load from
*/
protected abstract void loadSettings(CommentedFileConfiguration config);
}

View file

@ -93,4 +93,13 @@ public class DefaultStyles {
pluginManager.registerEvents((Listener) SWORDS, playerParticles);
}
/**
* Reloads the settings for all default styles
*/
public static void reloadSettings(ParticleStyleManager particleStyleManager) {
for (ParticleStyle style : particleStyleManager.getStylesWithDisabled())
if (style instanceof DefaultParticleStyle)
((DefaultParticleStyle) style).loadSettings(true);
}
}

View file

@ -23,6 +23,11 @@ public interface ParticleStyle {
*/
void updateTimers();
/**
* @return true if the style is enabled, false otherwise
*/
boolean isEnabled();
/**
* The name of the style
*

View file

@ -1,5 +1,6 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
@ -13,12 +14,17 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityShootBowEvent;
public class ParticleStyleArrows implements ParticleStyle, Listener {
public class ParticleStyleArrows extends DefaultParticleStyle implements Listener {
private static final String[] arrowEntityNames = new String[] { "ARROW", "SPECTRAL_ARROW", "TIPPED_ARROW" };
private static final int MAX_ARROWS_PER_PLAYER = 10;
private List<Projectile> arrows = new ArrayList<>();
public ParticleStyleArrows() {
super("arrows", false, false, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
@ -40,6 +46,7 @@ public class ParticleStyleArrows implements ParticleStyle, Listener {
/**
* Removes all arrows that are considered dead
*/
@Override
public void updateTimers() {
for (int i = this.arrows.size() - 1; i >= 0; i--) {
Projectile arrow = this.arrows.get(i);
@ -48,22 +55,6 @@ public class ParticleStyleArrows implements ParticleStyle, Listener {
}
}
public String getName() {
return "arrows";
}
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return false;
}
public double getFixedEffectOffset() {
return 0;
}
/**
* The event used to get all arrows fired by players
* Adds all arrows fired from players to the array
@ -80,4 +71,14 @@ public class ParticleStyleArrows implements ParticleStyle, Listener {
this.arrows.add((Projectile) e.getProjectile());
}
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,5 +1,6 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.VectorUtils;
@ -8,10 +9,15 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.util.Vector;
public class ParticleStyleBatman implements ParticleStyle {
public class ParticleStyleBatman extends DefaultParticleStyle {
private int step = 0;
public ParticleStyleBatman() {
super("batman", true, true, -1);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
@ -106,24 +112,19 @@ public class ParticleStyleBatman implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
step = (step + 1) % 20; // Only spawn once per second
}
public String getName() {
return "batman";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return -1;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,12 +1,13 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleBeam implements ParticleStyle {
public class ParticleStyleBeam extends DefaultParticleStyle {
private static double[] cos, sin;
private static final int points = 16;
@ -25,6 +26,11 @@ public class ParticleStyleBeam implements ParticleStyle {
}
}
public ParticleStyleBeam() {
super("beam", true, true, 0.5);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
double radius = 1;
List<PParticle> particles = new ArrayList<>();
@ -37,6 +43,7 @@ public class ParticleStyleBeam implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
if (!reversed) step++;
else step--;
@ -48,20 +55,14 @@ public class ParticleStyleBeam implements ParticleStyle {
}
}
public String getName() {
return "beam";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0.5;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,6 +1,7 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PParticle;
@ -15,8 +16,13 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
public class ParticleStyleBlockBreak implements ParticleStyle, Listener {
public class ParticleStyleBlockBreak extends DefaultParticleStyle implements Listener {
public ParticleStyleBlockBreak() {
super("blockbreak", false, false, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
@ -28,24 +34,19 @@ public class ParticleStyleBlockBreak implements ParticleStyle, Listener {
return particles;
}
@Override
public void updateTimers() {
}
public String getName() {
return "blockbreak";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return false;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
@EventHandler(priority = EventPriority.MONITOR)

View file

@ -1,6 +1,7 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PParticle;
@ -15,8 +16,13 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
public class ParticleStyleBlockPlace implements ParticleStyle, Listener {
public class ParticleStyleBlockPlace extends DefaultParticleStyle implements Listener {
public ParticleStyleBlockPlace() {
super("blockplace", false, false, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
@ -28,24 +34,19 @@ public class ParticleStyleBlockPlace implements ParticleStyle, Listener {
return particles;
}
@Override
public void updateTimers() {
}
public String getName() {
return "blockplace";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return false;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
@EventHandler(priority = EventPriority.MONITOR)

View file

@ -1,6 +1,7 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.FixedParticleEffect;
@ -17,11 +18,16 @@ import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class ParticleStyleCelebration implements ParticleStyle {
public class ParticleStyleCelebration extends DefaultParticleStyle {
private int step = 0;
private final int spawnTime = 15;
public ParticleStyleCelebration() {
super("celebration", true, true, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
return new ArrayList<>();
}
@ -30,6 +36,7 @@ public class ParticleStyleCelebration implements ParticleStyle {
* Spawns fireworks every spawnTime number of ticks
* This style uses two different effects, one is always 'firework'
*/
@Override
public void updateTimers() {
PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class);
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
@ -52,6 +59,16 @@ public class ParticleStyleCelebration implements ParticleStyle {
}
}
}
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
private void spawnFirework(final Location location, final PPlayer pplayer, final ParticlePair particle, final Random random) {
double angle = random.nextDouble() * Math.PI * 2;
@ -99,20 +116,4 @@ public class ParticleStyleCelebration implements ParticleStyle {
}.runTaskTimer(PlayerParticles.getInstance(), 0, 1);
}
public String getName() {
return "celebration";
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0;
}
}

View file

@ -1,13 +1,19 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleChains implements ParticleStyle {
public class ParticleStyleChains extends DefaultParticleStyle {
public ParticleStyleChains() {
super("chains", true, true, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
@ -21,24 +27,19 @@ public class ParticleStyleChains implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
}
public String getName() {
return "chains";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -23,6 +23,7 @@
*/
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
@ -30,7 +31,7 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.util.Vector;
public class ParticleStyleCompanion implements ParticleStyle {
public class ParticleStyleCompanion extends DefaultParticleStyle {
private int numParticles = 150;
private int particlesPerIteration = 5;
@ -39,6 +40,11 @@ public class ParticleStyleCompanion implements ParticleStyle {
private double xOffset = 0.0, yOffset = -0.75, zOffset = 0.0;
private int step = 0;
public ParticleStyleCompanion() {
super("companion", true, false, 1);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
@ -59,24 +65,19 @@ public class ParticleStyleCompanion implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
step++;
}
public String getName() {
return "companion";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return false;
}
public double getFixedEffectOffset() {
return 1;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -23,6 +23,7 @@
*/
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.VectorUtils;
@ -36,7 +37,7 @@ import org.bukkit.util.Vector;
* The project this is from is called EffectLib and can be found here:
* https://github.com/Slikey/EffectLib
*/
public class ParticleStyleCube implements ParticleStyle {
public class ParticleStyleCube extends DefaultParticleStyle {
private double edgeLength = 2;
private double angularVelocityX = (Math.PI / 200) / 5;
@ -46,6 +47,11 @@ public class ParticleStyleCube implements ParticleStyle {
private int step = 0;
private boolean skipNextStep = false; // Only spawn every 2 ticks
public ParticleStyleCube() {
super("cube", true, true, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> pparticles = new ArrayList<>();
@ -83,25 +89,20 @@ public class ParticleStyleCube implements ParticleStyle {
return pparticles;
}
@Override
public void updateTimers() {
skipNextStep = !skipNextStep;
step++;
}
public String getName() {
return "cube";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,37 +1,38 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleFeet implements ParticleStyle {
public class ParticleStyleFeet extends DefaultParticleStyle {
public ParticleStyleFeet() {
super("feet", true, false, 0.5);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
particles.add(new PParticle(location.clone().subtract(0, 0.95, 0), 0.4F, 0.0F, 0.4F, 0.0F));
return particles;
}
@Override
public void updateTimers() {
}
public String getName() {
return "feet";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return false;
}
public double getFixedEffectOffset() {
return 0.5;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,12 +1,13 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleHalo implements ParticleStyle {
public class ParticleStyleHalo extends DefaultParticleStyle {
private static double[] cos, sin;
private static final int points = 16;
@ -24,6 +25,11 @@ public class ParticleStyleHalo implements ParticleStyle {
}
}
public ParticleStyleHalo() {
super("halo", true, false, -0.5);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
if (step % 2 == 0) return new ArrayList<>();
@ -39,6 +45,7 @@ public class ParticleStyleHalo implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
step++;
if (step > 30) {
@ -46,20 +53,14 @@ public class ParticleStyleHalo implements ParticleStyle {
}
}
public String getName() {
return "halo";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return false;
}
public double getFixedEffectOffset() {
return -0.5;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,6 +1,7 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PParticle;
@ -15,8 +16,13 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
public class ParticleStyleHurt implements ParticleStyle, Listener {
public class ParticleStyleHurt extends DefaultParticleStyle implements Listener {
public ParticleStyleHurt() {
super("hurt", false, false, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> baseParticles = DefaultStyles.THICK.getParticles(particle, location);
@ -29,26 +35,11 @@ public class ParticleStyleHurt implements ParticleStyle, Listener {
return particles;
}
@Override
public void updateTimers() {
}
public String getName() {
return "hurt";
}
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return false;
}
public double getFixedEffectOffset() {
return 0;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDamage(EntityDamageEvent event) {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
@ -65,4 +56,14 @@ public class ParticleStyleHurt implements ParticleStyle, Listener {
}
}
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,5 +1,6 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticlePair;
@ -7,7 +8,7 @@ import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleInvocation implements ParticleStyle {
public class ParticleStyleInvocation extends DefaultParticleStyle {
private int points = 6;
private double radius = 3.5;
@ -15,6 +16,10 @@ public class ParticleStyleInvocation implements ParticleStyle {
private int circleStep = 0;
private int numSteps = 120;
public ParticleStyleInvocation() {
super("invocation", true, true, 0.5);
}
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
double speed = getSpeedByEffect(particle.getEffect());
@ -88,20 +93,14 @@ public class ParticleStyleInvocation implements ParticleStyle {
circleStep = (circleStep + 1) % numSteps;
}
public String getName() {
return "invocation";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0.5;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,6 +1,7 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PParticle;
@ -13,30 +14,30 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
public class ParticleStyleMove implements ParticleStyle, Listener {
public class ParticleStyleMove extends DefaultParticleStyle implements Listener {
public ParticleStyleMove() {
super("move", false, false, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
return DefaultStyles.NORMAL.getParticles(particle, location);
}
@Override
public void updateTimers() {
}
public String getName() {
return "move";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return false;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
@EventHandler(priority = EventPriority.MONITOR)

View file

@ -1,5 +1,6 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticlePair;
@ -8,8 +9,13 @@ import java.util.Collections;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleNormal implements ParticleStyle {
public class ParticleStyleNormal extends DefaultParticleStyle {
public ParticleStyleNormal() {
super("normal", true, false, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
ParticleEffect particleEffect = particle.getEffect();
List<PParticle> particles = new ArrayList<>();
@ -124,24 +130,19 @@ public class ParticleStyleNormal implements ParticleStyle {
}
}
@Override
public void updateTimers() {
}
public String getName() {
return "normal";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return false;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,12 +1,13 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleOrbit implements ParticleStyle {
public class ParticleStyleOrbit extends DefaultParticleStyle {
private static double[] cos, sin;
private static final int orbs = 3;
@ -25,6 +26,11 @@ public class ParticleStyleOrbit implements ParticleStyle {
}
}
public ParticleStyleOrbit() {
super("orbit", true, true, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
for (int i = 0; i < orbs; i++) {
@ -35,6 +41,7 @@ public class ParticleStyleOrbit implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
step++;
if (step > numSteps) {
@ -42,20 +49,14 @@ public class ParticleStyleOrbit implements ParticleStyle {
}
}
public String getName() {
return "orbit";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,13 +1,19 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleOverhead implements ParticleStyle {
public class ParticleStyleOverhead extends DefaultParticleStyle {
public ParticleStyleOverhead() {
super("overhead", true, false, -0.5);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
particles.add(new PParticle(location.clone().add(0, 1.75, 0), 0.4F, 0.1F, 0.4F, 0.0F));
@ -15,24 +21,19 @@ public class ParticleStyleOverhead implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
}
public String getName() {
return "overhead";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return false;
}
public double getFixedEffectOffset() {
return -0.5;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,35 +1,36 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.Collections;
import java.util.List;
import org.bukkit.Location;
public class ParticleStylePoint implements ParticleStyle {
public class ParticleStylePoint extends DefaultParticleStyle {
public ParticleStylePoint() {
super("point", true, false, -0.5);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
return Collections.singletonList(new PParticle(location.clone().add(0.0, 1.5, 0.0)));
}
@Override
public void updateTimers() {
}
public String getName() {
return "point";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return false;
}
public double getFixedEffectOffset() {
return -0.5;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,5 +1,6 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
@ -7,7 +8,7 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.util.Vector;
public class ParticleStylePopper implements ParticleStyle {
public class ParticleStylePopper extends DefaultParticleStyle {
private double grow = 0.08f;
private double radials = Math.PI / 16;
@ -15,6 +16,11 @@ public class ParticleStylePopper implements ParticleStyle {
private int step = 0;
private int maxStep = 35;
public ParticleStylePopper() {
super("popper", true, true, 0.5);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
@ -35,24 +41,19 @@ public class ParticleStylePopper implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
step = (step + 1) % maxStep;
}
public String getName() {
return "popper";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0.5;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,5 +1,6 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticlePair;
@ -7,13 +8,18 @@ import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStylePulse implements ParticleStyle {
public class ParticleStylePulse extends DefaultParticleStyle {
private int points = 50;
private double radius = 0.5;
private double step = 0;
private int numSteps = 15;
public ParticleStylePulse() {
super("pulse", true, true, 0.5);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
double speed = getSpeedByEffect(particle.getEffect());
@ -62,24 +68,19 @@ public class ParticleStylePulse implements ParticleStyle {
}
}
@Override
public void updateTimers() {
step = (step + 1) % numSteps;
}
public String getName() {
return "pulse";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
@Override
protected void loadSettings(CommentedFileConfiguration config) {
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0.5;
}
}

View file

@ -1,12 +1,13 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleQuadhelix implements ParticleStyle {
public class ParticleStyleQuadhelix extends DefaultParticleStyle {
private static double[] cos, sin;
private static final int orbs = 4;
@ -28,6 +29,11 @@ public class ParticleStyleQuadhelix implements ParticleStyle {
}
}
public ParticleStyleQuadhelix() {
super("quadhelix", true, true, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
for (int i = 0; i < orbs; i++) {
@ -40,6 +46,7 @@ public class ParticleStyleQuadhelix implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
stepX++;
if (stepX > maxStepX) {
@ -54,20 +61,14 @@ public class ParticleStyleQuadhelix implements ParticleStyle {
}
}
public String getName() {
return "quadhelix";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,12 +1,13 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleRings implements ParticleStyle {
public class ParticleStyleRings extends DefaultParticleStyle {
private static double[] cos, sin;
private int index = 0;
@ -23,6 +24,11 @@ public class ParticleStyleRings implements ParticleStyle {
}
}
public ParticleStyleRings() {
super("rings", true, true, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
@ -44,24 +50,19 @@ public class ParticleStyleRings implements ParticleStyle {
return index % cos.length;
}
@Override
public void updateTimers() {
index = (index + 1) % cos.length;
}
public String getName() {
return "rings";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,13 +1,19 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleSphere implements ParticleStyle {
public class ParticleStyleSphere extends DefaultParticleStyle {
public ParticleStyleSphere() {
super("sphere", true, true, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
int density = 15;
double radius = 1.5f;
@ -27,24 +33,19 @@ public class ParticleStyleSphere implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
}
public String getName() {
return "sphere";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,12 +1,13 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.Collections;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleSpin implements ParticleStyle {
public class ParticleStyleSpin extends DefaultParticleStyle {
private static double[] cos, sin;
private static final int maxSteps = 30;
@ -24,6 +25,11 @@ public class ParticleStyleSpin implements ParticleStyle {
}
}
public ParticleStyleSpin() {
super("spin", true, true, -0.5);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
double radius = .5;
double newX = location.getX() + radius * cos[step];
@ -32,24 +38,19 @@ public class ParticleStyleSpin implements ParticleStyle {
return Collections.singletonList(new PParticle(new Location(location.getWorld(), newX, newY, newZ)));
}
@Override
public void updateTimers() {
step = (step + 1) % maxSteps;
}
public String getName() {
return "spin";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return -0.5;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,15 +1,21 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleSpiral implements ParticleStyle {
public class ParticleStyleSpiral extends DefaultParticleStyle {
private int stepX = 0;
public ParticleStyleSpiral() {
super("spiral", true, true, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
for (int stepY = -60; stepY < 60; stepY += 10) {
@ -21,24 +27,19 @@ public class ParticleStyleSpiral implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
stepX++;
}
public String getName() {
return "spiral";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,6 +1,7 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.manager.DataManager;
import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PParticle;
@ -17,7 +18,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
public class ParticleStyleSwords implements ParticleStyle, Listener {
public class ParticleStyleSwords extends DefaultParticleStyle implements Listener {
private static final List<String> SWORD_NAMES;
@ -26,6 +27,11 @@ public class ParticleStyleSwords implements ParticleStyle, Listener {
SWORD_NAMES.addAll(Arrays.asList("WOOD_SWORD", "STONE_SWORD", "IRON_SWORD", "GOLD_SWORD", "GOLDEN_SWORD", "DIAMOND_SWORD", "TRIDENT"));
}
public ParticleStyleSwords() {
super("swords", false, false, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> baseParticles = DefaultStyles.NORMAL.getParticles(particle, location);
@ -38,24 +44,19 @@ public class ParticleStyleSwords implements ParticleStyle, Listener {
return particles;
}
@Override
public void updateTimers() {
}
public String getName() {
return "swords";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return false;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
@EventHandler(priority = EventPriority.MONITOR)

View file

@ -1,13 +1,19 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleThick implements ParticleStyle {
public class ParticleStyleThick extends DefaultParticleStyle {
public ParticleStyleThick() {
super("thick", true, true, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> baseParticles = DefaultStyles.NORMAL.getParticles(particle, location);
@ -20,24 +26,19 @@ public class ParticleStyleThick implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
}
public String getName() {
return "thick";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,12 +1,13 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleTwins implements ParticleStyle {
public class ParticleStyleTwins extends DefaultParticleStyle {
private static double[] cos, sin;
private static final int orbs = 2;
@ -28,6 +29,11 @@ public class ParticleStyleTwins implements ParticleStyle {
}
}
public ParticleStyleTwins() {
super("twins", true, true, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
for (int i = 0; i < orbs; i++) {
@ -39,6 +45,7 @@ public class ParticleStyleTwins implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
stepX++;
if (stepX > numSteps) {
@ -54,20 +61,14 @@ public class ParticleStyleTwins implements ParticleStyle {
}
}
public String getName() {
return "twins";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -23,6 +23,7 @@
*/
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList;
@ -30,7 +31,7 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.util.Vector;
public class ParticleStyleVortex implements ParticleStyle {
public class ParticleStyleVortex extends DefaultParticleStyle {
private double grow = .05f;
private double radials = Math.PI / 16;
@ -38,6 +39,11 @@ public class ParticleStyleVortex implements ParticleStyle {
private int step = 0;
private int maxStep = 70;
public ParticleStyleVortex() {
super("vortex", true, true, 0.5);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
@ -52,24 +58,19 @@ public class ParticleStyleVortex implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
step = (step + 1) % maxStep;
}
public String getName() {
return "vortex";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0.5;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,5 +1,6 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticlePair;
@ -7,12 +8,17 @@ import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleWhirl implements ParticleStyle {
public class ParticleStyleWhirl extends DefaultParticleStyle {
private int points = 2;
private double step = 0;
private int numSteps = 40;
public ParticleStyleWhirl() {
super("whirl", true, true, 0.5);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
double speed = getSpeedByEffect(particle.getEffect());
@ -59,24 +65,19 @@ public class ParticleStyleWhirl implements ParticleStyle {
}
}
@Override
public void updateTimers() {
step = (step + Math.PI * 2 / numSteps) % numSteps;
}
public String getName() {
return "whirl";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0.5;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,5 +1,6 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticlePair;
@ -7,12 +8,17 @@ import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
public class ParticleStyleWhirlwind implements ParticleStyle {
public class ParticleStyleWhirlwind extends DefaultParticleStyle {
private int points = 3;
private double step = 0;
private int numSteps = 40;
public ParticleStyleWhirlwind() {
super("whirlwind", true, true, 0.5);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
double speed = getSpeedByEffect(particle.getEffect()) * 2.5;
@ -60,24 +66,19 @@ public class ParticleStyleWhirlwind implements ParticleStyle {
}
}
@Override
public void updateTimers() {
step = (step + Math.PI * 2 / numSteps) % numSteps;
}
public String getName() {
return "whirlwind";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0.5;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}

View file

@ -1,5 +1,6 @@
package dev.esophose.playerparticles.styles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.VectorUtils;
@ -8,10 +9,15 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.util.Vector;
public class ParticleStyleWings implements ParticleStyle {
public class ParticleStyleWings extends DefaultParticleStyle {
private int spawnTimer = 0; // Spawn particles every 3 ticks
public ParticleStyleWings() {
super("wings", false, true, 0);
}
@Override
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<>();
if (spawnTimer == 0) {
@ -26,25 +32,20 @@ public class ParticleStyleWings implements ParticleStyle {
return particles;
}
@Override
public void updateTimers() {
spawnTimer++;
spawnTimer %= 3;
}
public String getName() {
return "wings";
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
}
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0;
@Override
protected void loadSettings(CommentedFileConfiguration config) {
}
}