From 200103a5c9e02af4e13ca8f762f578a95085f643 Mon Sep 17 00:00:00 2001 From: Esophose Date: Sat, 13 Oct 2018 16:38:01 -0600 Subject: [PATCH] Add style 'rings', code cleanup --- .../playerparticles/PlayerParticles.java | 14 ++++- .../command/AddCommandModule.java | 3 +- .../command/FixedCommandModule.java | 2 +- .../gui/PlayerParticlesGui.java | 4 +- .../playerparticles/manager/DataManager.java | 28 ++++++++-- .../manager/ParticleManager.java | 41 +++----------- .../particles/ParticleEffect.java | 2 - .../playerparticles/styles/DefaultStyles.java | 2 + .../styles/ParticleStyleBeam.java | 21 +++++-- .../styles/ParticleStyleCube.java | 2 +- .../styles/ParticleStyleHalo.java | 24 ++++++-- .../styles/ParticleStyleOrbit.java | 24 ++++++-- .../styles/ParticleStyleQuadhelix.java | 25 +++++++-- .../styles/ParticleStyleRings.java | 56 +++++++++++++++++++ .../styles/ParticleStyleSpin.java | 26 ++++++--- src/lang/default.lang | 2 +- 16 files changed, 196 insertions(+), 80 deletions(-) create mode 100644 src/com/esophose/playerparticles/styles/ParticleStyleRings.java diff --git a/src/com/esophose/playerparticles/PlayerParticles.java b/src/com/esophose/playerparticles/PlayerParticles.java index ef5b5b5..7315bd7 100644 --- a/src/com/esophose/playerparticles/PlayerParticles.java +++ b/src/com/esophose/playerparticles/PlayerParticles.java @@ -3,7 +3,6 @@ * + Add new style 'tornado' * + Add new style 'companion' * + Add new style 'atom' - * + Add new style 'rings' */ package com.esophose.playerparticles; @@ -42,7 +41,7 @@ public class PlayerParticles extends JavaPlugin { /** * The database connection manager */ - public static DatabaseConnector databaseConnector = null; + private static DatabaseConnector databaseConnector = null; /** * Registers all the styles available by default @@ -81,6 +80,7 @@ public class PlayerParticles extends JavaPlugin { LangManager.setup(); configureDatabase(getConfig().getBoolean("database-enable")); + ParticleManager.refreshData(); startParticleTask(); if (shouldCheckUpdates()) { @@ -117,6 +117,15 @@ public class PlayerParticles extends JavaPlugin { public static Plugin getPlugin() { return pluginInstance; } + + /** + * Gets the DatabaseConnector that allows querying the database + * + * @return The DatabaseConnector + */ + public static DatabaseConnector getDBConnector() { + return databaseConnector; + } /** * Checks the config if the plugin can look for updates @@ -214,7 +223,6 @@ public class PlayerParticles extends JavaPlugin { final Plugin playerParticles = this; new BukkitRunnable() { public void run() { - ParticleManager.refreshPPlayers(); // Add any online players who have particles PlayerParticlesGui.setup(); long ticks = getConfig().getLong("ticks-per-particle"); diff --git a/src/com/esophose/playerparticles/command/AddCommandModule.java b/src/com/esophose/playerparticles/command/AddCommandModule.java index 35550be..7cd213b 100644 --- a/src/com/esophose/playerparticles/command/AddCommandModule.java +++ b/src/com/esophose/playerparticles/command/AddCommandModule.java @@ -10,7 +10,6 @@ import org.bukkit.util.StringUtil; import com.esophose.playerparticles.manager.DataManager; import com.esophose.playerparticles.manager.LangManager; import com.esophose.playerparticles.manager.LangManager.Lang; -import com.esophose.playerparticles.manager.ParticleManager; import com.esophose.playerparticles.manager.PermissionManager; import com.esophose.playerparticles.particles.PPlayer; import com.esophose.playerparticles.particles.ParticleEffect; @@ -31,7 +30,7 @@ public class AddCommandModule implements CommandModule { return; } - ParticleEffect effect = ParticleManager.effectFromString(args[0]); + ParticleEffect effect = ParticleEffect.fromName(args[0]); if (effect == null) { LangManager.sendMessage(pplayer, Lang.EFFECT_INVALID, args[0]); return; diff --git a/src/com/esophose/playerparticles/command/FixedCommandModule.java b/src/com/esophose/playerparticles/command/FixedCommandModule.java index f494c7b..3d62b3e 100644 --- a/src/com/esophose/playerparticles/command/FixedCommandModule.java +++ b/src/com/esophose/playerparticles/command/FixedCommandModule.java @@ -133,7 +133,7 @@ public class FixedCommandModule implements CommandModule { return; } - ParticleEffect effect = ParticleManager.effectFromString(args[3]); + ParticleEffect effect = ParticleEffect.fromName(args[3]); if (effect == null) { LangManager.sendMessage(p, Lang.FIXED_CREATE_EFFECT_INVALID, args[3]); return; diff --git a/src/com/esophose/playerparticles/gui/PlayerParticlesGui.java b/src/com/esophose/playerparticles/gui/PlayerParticlesGui.java index 726b33a..50a7d8f 100644 --- a/src/com/esophose/playerparticles/gui/PlayerParticlesGui.java +++ b/src/com/esophose/playerparticles/gui/PlayerParticlesGui.java @@ -519,7 +519,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener { List effectsUserHasPermissionFor = PermissionManager.getEffectsUserHasPermissionFor(player); for (int i = 0; i < effectsUserHasPermissionFor.size(); i++) { String s = effectsUserHasPermissionFor.get(i); - ParticleEffect effect = ParticleManager.effectFromString(s); + ParticleEffect effect = ParticleEffect.fromName(s); inventory.setItem(i, getItemForEffect(effect, effect == getPPlayerEffect(pplayer))); } @@ -706,7 +706,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener { } break; case EFFECT: - setPPlayerEffect(pplayer, ParticleManager.effectFromString(name)); + setPPlayerEffect(pplayer, ParticleEffect.fromName(name)); changeState(pplayer, GuiState.DEFAULT); break; case STYLE: diff --git a/src/com/esophose/playerparticles/manager/DataManager.java b/src/com/esophose/playerparticles/manager/DataManager.java index 00ecee5..beb10b1 100644 --- a/src/com/esophose/playerparticles/manager/DataManager.java +++ b/src/com/esophose/playerparticles/manager/DataManager.java @@ -81,7 +81,7 @@ public class DataManager { List groups = new ArrayList(); List fixedParticles = new ArrayList(); - PlayerParticles.databaseConnector.connect((connection) -> { + PlayerParticles.getDBConnector().connect((connection) -> { // Load particle groups String groupQuery = "SELECT * FROM pp_group g " + // @formatter:off "JOIN pp_particle p ON g.uuid = p.group_uuid " + @@ -167,6 +167,24 @@ public class DataManager { }); }); } + + /** + * Loads all PPlayers from the database that own FixedParticleEffects + */ + public static void loadFixedEffects() { + async(() -> { + PlayerParticles.getDBConnector().connect((connection) -> { + String query = "SELECT DISTINCT owner_uuid FROM pp_fixed"; + try (PreparedStatement statement = connection.prepareStatement(query)) { + ResultSet result = statement.executeQuery(); + while (result.next()) { + UUID playerUUID = UUID.fromString(result.getString("owner_uuid")); + getPPlayer(playerUUID, (pplayer) -> { }); + } + } + }); + }); + } /** * Saves a ParticleGroup. If it already exists, update it. @@ -176,7 +194,7 @@ public class DataManager { */ public static void saveParticleGroup(UUID playerUUID, ParticleGroup group) { async(() -> { - PlayerParticles.databaseConnector.connect((connection) -> { + PlayerParticles.getDBConnector().connect((connection) -> { String groupUUIDQuery = "SELECT uuid FROM pp_group WHERE owner_uuid = ? AND name = ?"; try (PreparedStatement statement = connection.prepareStatement(groupUUIDQuery)) { statement.setString(1, playerUUID.toString()); @@ -247,7 +265,7 @@ public class DataManager { */ public static void removeParticleGroup(UUID playerUUID, ParticleGroup group) { async(() -> { - PlayerParticles.databaseConnector.connect((connection) -> { + PlayerParticles.getDBConnector().connect((connection) -> { String groupQuery = "SELECT * FROM pp_group WHERE owner_uuid = ? AND name = ?"; String particleDeleteQuery = "DELETE FROM pp_particle WHERE group_uuid = ?"; String groupDeleteQuery = "DELETE FROM pp_group WHERE uuid = ?"; @@ -291,7 +309,7 @@ public class DataManager { */ public static void saveFixedEffect(FixedParticleEffect fixedEffect) { async(() -> { - PlayerParticles.databaseConnector.connect((connection) -> { + PlayerParticles.getDBConnector().connect((connection) -> { String particleUUID = UUID.randomUUID().toString(); String particleQuery = "INSERT INTO pp_particle (uuid, group_uuid, id, effect, style, item_material, block_material, note, r, g, b) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; @@ -339,7 +357,7 @@ public class DataManager { */ public static void removeFixedEffect(UUID playerUUID, int id) { async(() -> { - PlayerParticles.databaseConnector.connect((connection) -> { + PlayerParticles.getDBConnector().connect((connection) -> { String particleUUID = null; String particleUUIDQuery = "SELECT particle_uuid FROM pp_fixed WHERE owner_uuid = ? AND id = ?"; diff --git a/src/com/esophose/playerparticles/manager/ParticleManager.java b/src/com/esophose/playerparticles/manager/ParticleManager.java index e34cb2f..5154e14 100644 --- a/src/com/esophose/playerparticles/manager/ParticleManager.java +++ b/src/com/esophose/playerparticles/manager/ParticleManager.java @@ -47,6 +47,7 @@ public class ParticleManager extends BukkitRunnable implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(PlayerJoinEvent e) { DataManager.getPPlayer(e.getPlayer().getUniqueId(), (pplayer) -> { + System.out.println("Loaded"); }); // Loads the PPlayer from the database } @@ -58,7 +59,7 @@ public class ParticleManager extends BukkitRunnable implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onPlayerQuit(PlayerQuitEvent e) { PPlayer pplayer = DataManager.getPPlayer(e.getPlayer().getUniqueId()); - if (pplayer != null) particlePlayers.remove(pplayer); + if (pplayer != null && pplayer.getFixedEffectIds().isEmpty()) particlePlayers.remove(pplayer); } /** @@ -71,43 +72,17 @@ public class ParticleManager extends BukkitRunnable implements Listener { } /** - * Load a PPlayer for all players on the server who have active particles or fixed effects + * Loads all FixedParticleEffects from the database + * Loads all online PPlayers from the database */ - public static void refreshPPlayers() { + public static void refreshData() { particlePlayers.clear(); - for (Player player : Bukkit.getOnlinePlayers()) - DataManager.getPPlayer(player.getUniqueId(), (pplayer) -> { - }); // Loads the PPlayer from the database - } - - /** - * Overrides an existing PPlayer with the same UUID - * - * @param pplayer The PPlayer to override - */ - public static void updateIfContains(PPlayer pplayer) { - for (PPlayer pp : particlePlayers) { - if (pp.getUniqueId() == pplayer.getUniqueId()) { - particlePlayers.remove(pp); - particlePlayers.add(pplayer); - break; - } + DataManager.loadFixedEffects(); + for (Player player : Bukkit.getOnlinePlayers()) { + DataManager.getPPlayer(player.getUniqueId(), (pplayer) -> { }); // Loads the PPlayer from the database } } - /** - * Gets an effect type from a string, used for getting ParticleEffects from the saved data - * - * @param effectName The name of the particle to check for - * @return The ParticleEffect with the given name, will be null if name was not found - */ - public static ParticleEffect effectFromString(String effectName) { - for (ParticleEffect effect : ParticleEffect.getSupportedEffects()) { - if (effect.getName().equalsIgnoreCase(effectName)) return effect; - } - return null; - } - /** * The main loop to display all the particles * Does not display particles if the world is disabled or if the player is in spectator mode diff --git a/src/com/esophose/playerparticles/particles/ParticleEffect.java b/src/com/esophose/playerparticles/particles/ParticleEffect.java index b78cdbb..9bd21c4 100644 --- a/src/com/esophose/playerparticles/particles/ParticleEffect.java +++ b/src/com/esophose/playerparticles/particles/ParticleEffect.java @@ -206,7 +206,6 @@ public enum ParticleEffect { for (Player player : getPlayersInRange(center)) { player.spawnParticle(internalEnum, center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed); } - } /** @@ -272,7 +271,6 @@ public enum ParticleEffect { } else if (internalEnum.getDataType() == MaterialData.class) { extraData = new MaterialData(spawnMaterial); // Deprecated, only used in versions < 1.13 } else { - System.out.println(internalEnum.getDataType()); extraData = null; } diff --git a/src/com/esophose/playerparticles/styles/DefaultStyles.java b/src/com/esophose/playerparticles/styles/DefaultStyles.java index ba66556..da03180 100644 --- a/src/com/esophose/playerparticles/styles/DefaultStyles.java +++ b/src/com/esophose/playerparticles/styles/DefaultStyles.java @@ -28,6 +28,7 @@ public class DefaultStyles { public static final ParticleStyle ORBIT = new ParticleStyleOrbit(); public static final ParticleStyle POINT = new ParticleStylePoint(); public static final ParticleStyle QUADHELIX = new ParticleStyleQuadhelix(); + public static final ParticleStyle RINGS = new ParticleStyleRings(); public static final ParticleStyle SPHERE = new ParticleStyleSphere(); public static final ParticleStyle SPIN = new ParticleStyleSpin(); public static final ParticleStyle SPIRAL = new ParticleStyleSpiral(); @@ -54,6 +55,7 @@ public class DefaultStyles { ParticleStyleManager.registerStyle(ORBIT); ParticleStyleManager.registerStyle(POINT); ParticleStyleManager.registerStyle(QUADHELIX); + ParticleStyleManager.registerStyle(RINGS); ParticleStyleManager.registerStyle(SPHERE); ParticleStyleManager.registerStyle(SPIN); ParticleStyleManager.registerStyle(SPIRAL); diff --git a/src/com/esophose/playerparticles/styles/ParticleStyleBeam.java b/src/com/esophose/playerparticles/styles/ParticleStyleBeam.java index c1cfedb..4065c65 100644 --- a/src/com/esophose/playerparticles/styles/ParticleStyleBeam.java +++ b/src/com/esophose/playerparticles/styles/ParticleStyleBeam.java @@ -11,19 +11,30 @@ import com.esophose.playerparticles.styles.api.ParticleStyle; public class ParticleStyleBeam implements ParticleStyle { + private static double[] cos, sin; + private static final int points = 16; private int step = 0; private boolean reversed = false; + + static { + cos = new double[points]; + sin = new double[points]; + + int i = 0; + for (double n = 0; n < Math.PI * 2; n += Math.PI * 2 / points) { + cos[i] = Math.cos(n); + sin[i] = Math.sin(n); + i++; + } + } public List getParticles(ParticlePair particle, Location location) { - int points = 16; double radius = 1; - double slice = 2 * Math.PI / points; List particles = new ArrayList(); for (int i = 0; i < points; i++) { - double angle = slice * i; - double newX = location.getX() + radius * Math.cos(angle); + double newX = location.getX() + radius * cos[i]; double newY = location.getY() + (step / 10D) - 1; - double newZ = location.getZ() + radius * Math.sin(angle); + double newZ = location.getZ() + radius * sin[i]; particles.add(new PParticle(new Location(location.getWorld(), newX, newY, newZ))); } return particles; diff --git a/src/com/esophose/playerparticles/styles/ParticleStyleCube.java b/src/com/esophose/playerparticles/styles/ParticleStyleCube.java index 27fda78..f6f5eea 100644 --- a/src/com/esophose/playerparticles/styles/ParticleStyleCube.java +++ b/src/com/esophose/playerparticles/styles/ParticleStyleCube.java @@ -52,7 +52,7 @@ public class ParticleStyleCube implements ParticleStyle { public List getParticles(ParticlePair particle, Location location) { List pparticles = new ArrayList(); - if (!skipNextStep) { + if (!skipNextStep) { // TODO: relative position lookup tables double xRotation = 0, yRotation = 0, zRotation = 0; xRotation = step * angularVelocityX; yRotation = step * angularVelocityY; diff --git a/src/com/esophose/playerparticles/styles/ParticleStyleHalo.java b/src/com/esophose/playerparticles/styles/ParticleStyleHalo.java index 3248b0f..8e54273 100644 --- a/src/com/esophose/playerparticles/styles/ParticleStyleHalo.java +++ b/src/com/esophose/playerparticles/styles/ParticleStyleHalo.java @@ -11,21 +11,33 @@ import com.esophose.playerparticles.styles.api.ParticleStyle; public class ParticleStyleHalo implements ParticleStyle { + private static double[] cos, sin; + private static final int points = 16; private int step = 0; + + static { + cos = new double[points]; + sin = new double[points]; + + int i = 0; + for (double n = 0; n < Math.PI * 2; n += Math.PI * 2 / points) { + cos[i] = Math.cos(n); + sin[i] = Math.sin(n); + i++; + } + } public List getParticles(ParticlePair particle, Location location) { if (step % 2 == 0) return new ArrayList(); int points = 16; double radius = .65; - double slice = 2 * Math.PI / points; List particles = new ArrayList(); for (int i = 0; i < points; i++) { - double angle = slice * i; - double newX = location.getX() + radius * Math.cos(angle); - double newY = location.getY() + 1.5; - double newZ = location.getZ() + radius * Math.sin(angle); - particles.add(new PParticle(new Location(location.getWorld(), newX, newY, newZ))); + double dx = location.getX() + radius * cos[i]; + double dy = location.getY() + 1.5; + double dz = location.getZ() + radius * sin[i]; + particles.add(new PParticle(location.clone().add(dx, dy, dz))); } return particles; } diff --git a/src/com/esophose/playerparticles/styles/ParticleStyleOrbit.java b/src/com/esophose/playerparticles/styles/ParticleStyleOrbit.java index 2b9d17d..ff8b3c5 100644 --- a/src/com/esophose/playerparticles/styles/ParticleStyleOrbit.java +++ b/src/com/esophose/playerparticles/styles/ParticleStyleOrbit.java @@ -11,22 +11,36 @@ import com.esophose.playerparticles.styles.api.ParticleStyle; public class ParticleStyleOrbit implements ParticleStyle { + private static double[] cos, sin; + private static final int orbs = 3; + private static final int numSteps = 120; private int step = 0; + + static { + cos = new double[120]; + sin = new double[120]; + + int i = 0; + for (double n = 0; n < numSteps; n++) { + cos[i] = -Math.cos(n / numSteps * Math.PI * 2); + sin[i] = -Math.sin(n / numSteps * Math.PI * 2); + i++; + } + } public List getParticles(ParticlePair particle, Location location) { - int orbs = 3; List particles = new ArrayList(); for (int i = 0; i < orbs; i++) { - double dx = -(Math.cos((step / 120D) * (Math.PI * 2) + (((Math.PI * 2) / orbs) * i))); - double dz = -(Math.sin((step / 120D) * (Math.PI * 2) + (((Math.PI * 2) / orbs) * i))); - particles.add(new PParticle(new Location(location.getWorld(), location.getX() + dx, location.getY(), location.getZ() + dz))); + double dx = cos[(step + (numSteps / orbs * i)) % numSteps]; + double dz = sin[(step + (numSteps / orbs * i)) % numSteps]; + particles.add(new PParticle(location.clone().add(dx, 0, dz))); } return particles; } public void updateTimers() { step++; - if (step > 120) { + if (step > numSteps) { step = 0; } } diff --git a/src/com/esophose/playerparticles/styles/ParticleStyleQuadhelix.java b/src/com/esophose/playerparticles/styles/ParticleStyleQuadhelix.java index 9b11b69..bcf75ad 100644 --- a/src/com/esophose/playerparticles/styles/ParticleStyleQuadhelix.java +++ b/src/com/esophose/playerparticles/styles/ParticleStyleQuadhelix.java @@ -11,18 +11,33 @@ import com.esophose.playerparticles.styles.api.ParticleStyle; public class ParticleStyleQuadhelix implements ParticleStyle { + private static double[] cos, sin; + private static final int orbs = 4; + private static int maxStepX = 80; + private static int maxStepY = 60; private int stepX = 0; - private int maxStepX = 90; private int stepY = 0; - private int maxStepY = 60; private boolean reverse = false; + + static { + cos = new double[maxStepX]; + sin = new double[maxStepX]; + + int i = 0; + for (double n = 0; n < maxStepX; n++) { + cos[i] = -Math.cos(n / maxStepX * Math.PI * 2); + sin[i] = -Math.sin(n / maxStepX * Math.PI * 2); + i++; + } + } public List getParticles(ParticlePair particle, Location location) { List particles = new ArrayList(); - for (int i = 0; i < 4; i++) { - double dx = -(Math.cos((stepX / (double)maxStepX) * (Math.PI * 2) + ((Math.PI / 2) * i))) * ((60 - Math.abs(stepY)) / (double)maxStepY); + for (int i = 0; i < orbs; i++) { + int step = (stepX + (maxStepX / orbs) * i) % maxStepX; + double dx = cos[step] * ((60 - Math.abs(stepY)) / (double)maxStepY); double dy = (stepY / (double)maxStepY) * 1.5; - double dz = -(Math.sin((stepX / (double)maxStepX) * (Math.PI * 2) + ((Math.PI / 2) * i))) * ((60 - Math.abs(stepY)) / (double)maxStepY); + double dz = sin[step] * ((60 - Math.abs(stepY)) / (double)maxStepY); particles.add(new PParticle(location.clone().add(dx, dy, dz))); } return particles; diff --git a/src/com/esophose/playerparticles/styles/ParticleStyleRings.java b/src/com/esophose/playerparticles/styles/ParticleStyleRings.java new file mode 100644 index 0000000..4031e3a --- /dev/null +++ b/src/com/esophose/playerparticles/styles/ParticleStyleRings.java @@ -0,0 +1,56 @@ +package com.esophose.playerparticles.styles; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; + +import com.esophose.playerparticles.particles.ParticlePair; +import com.esophose.playerparticles.styles.api.PParticle; +import com.esophose.playerparticles.styles.api.ParticleStyle; + +public class ParticleStyleRings implements ParticleStyle { + + private static double[] cos, sin; + private int index = 0; + + static { + cos = new double[32]; + sin = new double[32]; + + int i = 0; + for (double n = 0; n < Math.PI * 2; n += Math.PI / 16) { + cos[i] = Math.sin(n); + sin[i] = Math.cos(n); + i++; + } + } + + public List getParticles(ParticlePair particle, Location location) { + List particles = new ArrayList(); + + particles.add(new PParticle(location.clone().add(cos[index], sin[index], sin[index]))); + particles.add(new PParticle(location.clone().add(cos[wrap(index + 16)], sin[wrap(index + 16)], sin[wrap(index + 16)]))); + particles.add(new PParticle(location.clone().add(cos[wrap(index + 16)], sin[index], sin[wrap(index + 16)]))); + particles.add(new PParticle(location.clone().add(cos[index], sin[wrap(index + 16)], sin[index]))); + + return particles; + } + + private int wrap(int index) { + return index % cos.length; + } + + public void updateTimers() { + index = (index + 1) % cos.length; + } + + public String getName() { + return "rings"; + } + + public boolean canBeFixed() { + return true; + } + +} diff --git a/src/com/esophose/playerparticles/styles/ParticleStyleSpin.java b/src/com/esophose/playerparticles/styles/ParticleStyleSpin.java index 4ce6aa4..92e9f1c 100644 --- a/src/com/esophose/playerparticles/styles/ParticleStyleSpin.java +++ b/src/com/esophose/playerparticles/styles/ParticleStyleSpin.java @@ -11,24 +11,32 @@ import com.esophose.playerparticles.styles.api.ParticleStyle; public class ParticleStyleSpin implements ParticleStyle { + private static double[] cos, sin; + private static final int maxSteps = 30; private int step = 0; + + static { + cos = new double[maxSteps]; + sin = new double[maxSteps]; + + int i = 0; + for (double n = 0; n < Math.PI * 2; n += Math.PI * 2 / maxSteps) { + cos[i] = Math.cos(n); + sin[i] = Math.sin(n); + i++; + } + } public List getParticles(ParticlePair particle, Location location) { - int points = 15; double radius = .5; - double slice = 2 * Math.PI / points; - double angle = slice * (step % 15); - double newX = location.getX() + radius * Math.cos(angle); + double newX = location.getX() + radius * cos[step]; double newY = location.getY() + 1.5; - double newZ = location.getZ() + radius * Math.sin(angle); + double newZ = location.getZ() + radius * sin[step]; return Collections.singletonList(new PParticle(new Location(location.getWorld(), newX, newY, newZ))); } public void updateTimers() { - step++; - if (step > 30) { - step = 0; - } + step = (step + 1) % maxSteps; } public String getName() { diff --git a/src/lang/default.lang b/src/lang/default.lang index e23b59b..08a5665 100644 --- a/src/lang/default.lang +++ b/src/lang/default.lang @@ -68,7 +68,7 @@ rainbow: '&cr&6a&ei&an&bb&9o&dw' effect-no-permission: '&cYou do not have permission to use the effect &b{0} &c!' effect-invalid: '&cThe effect &b{0} &cdoes not exist! Use &b/pp effects &cfor a list of effects you can use.' effect-list: '&eYou can use the following effects: &b{0}' -effect-list-empoty: '&cYou do not have permission to use any effects!' +effect-list-empty: '&cYou do not have permission to use any effects!' # Styles style-no-permission: '&cYou do not have permission to use the style &b{0} &c!'