diff --git a/src/com/esophose/playerparticles/manager/ParticleManager.java b/src/com/esophose/playerparticles/manager/ParticleManager.java index 5154e14..f3b13ac 100644 --- a/src/com/esophose/playerparticles/manager/ParticleManager.java +++ b/src/com/esophose/playerparticles/manager/ParticleManager.java @@ -46,9 +46,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 + DataManager.getPPlayer(e.getPlayer().getUniqueId(), (pplayer) -> { }); // Loads the PPlayer from the database } /** diff --git a/src/com/esophose/playerparticles/styles/DefaultStyles.java b/src/com/esophose/playerparticles/styles/DefaultStyles.java index da03180..aa1f3f6 100644 --- a/src/com/esophose/playerparticles/styles/DefaultStyles.java +++ b/src/com/esophose/playerparticles/styles/DefaultStyles.java @@ -15,6 +15,7 @@ public class DefaultStyles { * All the styles that are available by default from this plugin */ public static final ParticleStyle ARROWS = new ParticleStyleArrows(); + public static final ParticleStyle BATMAN = new ParticleStyleBatman(); public static final ParticleStyle BEAM = new ParticleStyleBeam(); public static final ParticleStyle BLOCKBREAK = new ParticleStyleBlockBreak(); public static final ParticleStyle BLOCKEDIT = new ParticleStyleBlockEdit(); @@ -41,8 +42,8 @@ public class DefaultStyles { * Registered in alphabetical order */ public static void registerStyles() { - ParticleStyleManager.registerStyle(NORMAL); // Always display none first ParticleStyleManager.registerStyle(ARROWS); + ParticleStyleManager.registerStyle(BATMAN); ParticleStyleManager.registerStyle(BEAM); ParticleStyleManager.registerCustomHandledStyle(BLOCKBREAK); ParticleStyleManager.registerCustomHandledStyle(BLOCKEDIT); @@ -52,6 +53,7 @@ public class DefaultStyles { ParticleStyleManager.registerStyle(HALO); ParticleStyleManager.registerCustomHandledStyle(HURT); ParticleStyleManager.registerCustomHandledStyle(MOVE); + ParticleStyleManager.registerStyle(NORMAL); ParticleStyleManager.registerStyle(ORBIT); ParticleStyleManager.registerStyle(POINT); ParticleStyleManager.registerStyle(QUADHELIX); diff --git a/src/com/esophose/playerparticles/styles/ParticleStyleBatman.java b/src/com/esophose/playerparticles/styles/ParticleStyleBatman.java new file mode 100644 index 0000000..bfdf44e --- /dev/null +++ b/src/com/esophose/playerparticles/styles/ParticleStyleBatman.java @@ -0,0 +1,124 @@ +package com.esophose.playerparticles.styles; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.util.Vector; + +import com.esophose.playerparticles.particles.ParticlePair; +import com.esophose.playerparticles.styles.api.PParticle; +import com.esophose.playerparticles.styles.api.ParticleStyle; +import com.esophose.playerparticles.util.VectorUtils; + +public class ParticleStyleBatman implements ParticleStyle { + + private int step = 0; + + public List getParticles(ParticlePair particle, Location location) { + List particles = new ArrayList(); + + if (step != 0) return particles; + + // Segment 1 + for (double x = -7; x <= -3; x += 0.05) { + double y = 3 * Math.sqrt(-Math.pow(x / 7, 2) + 1); + Vector segment = new Vector(x, y, 0).multiply(0.3); + VectorUtils.rotateAroundAxisY(segment, -Math.toRadians(location.getYaw())); + particles.add(new PParticle(location.clone().add(segment).add(0, 3, 0))); + } + for (double x = 3; x <= 7; x += 0.05) { + double y = 3 * Math.sqrt(-Math.pow(x / 7, 2) + 1); + Vector segment = new Vector(x, y, 0).multiply(0.3); + VectorUtils.rotateAroundAxisY(segment, -Math.toRadians(location.getYaw())); + particles.add(new PParticle(location.clone().add(segment).add(0, 3, 0))); + } + + // Segment 2 + for (double x = -7; x <= -4; x += 0.05) { + double y = -3 * Math.sqrt(-Math.pow(x / 7, 2) + 1); + Vector segment = new Vector(x, y, 0).multiply(0.3); + VectorUtils.rotateAroundAxisY(segment, -Math.toRadians(location.getYaw())); + particles.add(new PParticle(location.clone().add(segment).add(0, 3, 0))); + } + for (double x = 4; x <= 7; x += 0.05) { + double y = -3 * Math.sqrt(-Math.pow(x / 7, 2) + 1); + Vector segment = new Vector(x, y, 0).multiply(0.3); + VectorUtils.rotateAroundAxisY(segment, -Math.toRadians(location.getYaw())); + particles.add(new PParticle(location.clone().add(segment).add(0, 3, 0))); + } + + // Segment 3 + for (double x = -4; x <= 4; x += 0.125) { + double y = Math.abs(x / 2) - ((3 * Math.sqrt(33) - 7) / 112) * Math.pow(x, 2) + Math.sqrt(1 - Math.pow(Math.abs(Math.abs(x) - 2) - 1, 2)) - 3; + Vector segment = new Vector(x, y, 0).multiply(0.3); + VectorUtils.rotateAroundAxisY(segment, -Math.toRadians(location.getYaw())); + particles.add(new PParticle(location.clone().add(segment).add(0, 3, 0))); + } + + // Segment 4 + for (double x = -1; x <= -0.75; x += 0.025) { + double y = 9 - 8 * Math.abs(x); + Vector segment = new Vector(x, y, 0).multiply(0.3); + VectorUtils.rotateAroundAxisY(segment, -Math.toRadians(location.getYaw())); + particles.add(new PParticle(location.clone().add(segment).add(0, 3, 0))); + } + for (double x = 0.75; x <= 1; x += 0.025) { + double y = 9 - 8 * Math.abs(x); + Vector segment = new Vector(x, y, 0).multiply(0.3); + VectorUtils.rotateAroundAxisY(segment, -Math.toRadians(location.getYaw())); + particles.add(new PParticle(location.clone().add(segment).add(0, 3, 0))); + } + + // Segment 5 + for (double x = -0.75; x <= -0.5; x += 0.05) { + double y = 3 * Math.abs(x) + 0.75; + Vector segment = new Vector(x, y, 0).multiply(0.3); + VectorUtils.rotateAroundAxisY(segment, -Math.toRadians(location.getYaw())); + particles.add(new PParticle(location.clone().add(segment).add(0, 3, 0))); + } + for (double x = 0.5; x <= 0.75; x += 0.05) { + double y = 3 * Math.abs(x) + 0.75; + Vector segment = new Vector(x, y, 0).multiply(0.3); + VectorUtils.rotateAroundAxisY(segment, -Math.toRadians(location.getYaw())); + particles.add(new PParticle(location.clone().add(segment).add(0, 3, 0))); + } + + // Segment 6 + for (double x = -0.5; x <= 0.5; x += 0.2) { + double y = 2.25; + Vector segment = new Vector(x, y, 0).multiply(0.3); + VectorUtils.rotateAroundAxisY(segment, -Math.toRadians(location.getYaw())); + particles.add(new PParticle(location.clone().add(segment).add(0, 3, 0))); + } + + // Segment 7 + for (double x = -3; x <= -1; x += 0.02) { + double y = 1.5 - 0.5 * Math.abs(x) - ((6 * Math.sqrt(10)) / 14) * (Math.sqrt(3 - Math.pow(x, 2) + 2 * Math.abs(x)) - 2); + Vector segment = new Vector(x, y, 0).multiply(0.3); + VectorUtils.rotateAroundAxisY(segment, -Math.toRadians(location.getYaw())); + particles.add(new PParticle(location.clone().add(segment).add(0, 3, 0))); + } + for (double x = 1; x <= 3; x += 0.02) { + double y = 1.5 - 0.5 * Math.abs(x) - ((6 * Math.sqrt(10)) / 14) * (Math.sqrt(3 - Math.pow(x, 2) + 2 * Math.abs(x)) - 2); + Vector segment = new Vector(x, y, 0).multiply(0.3); + VectorUtils.rotateAroundAxisY(segment, -Math.toRadians(location.getYaw())); + particles.add(new PParticle(location.clone().add(segment).add(0, 3, 0))); + } + + return particles; + } + + public void updateTimers() { + step = (step + 1) % 20; // Only spawn once per second + } + + public String getName() { + return "batman"; + } + + public boolean canBeFixed() { + return true; + } + +} diff --git a/src/com/esophose/playerparticles/styles/ParticleStyleNormal.java b/src/com/esophose/playerparticles/styles/ParticleStyleNormal.java index 4ccb10d..fb4e9e1 100644 --- a/src/com/esophose/playerparticles/styles/ParticleStyleNormal.java +++ b/src/com/esophose/playerparticles/styles/ParticleStyleNormal.java @@ -51,7 +51,7 @@ public class ParticleStyleNormal implements ParticleStyle { case DUST: return Collections.singletonList(new PParticle(location, 0.5, 0.5, 0.5, 0.0)); case ENCHANT: - return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.05)); + return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 1.0)); case ENCHANTED_HIT: return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); case END_ROD: @@ -93,13 +93,13 @@ public class ParticleStyleNormal implements ParticleStyle { case MYCELIUM: return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); case NAUTILUS: - return Collections.singletonList(new PParticle(location, 0.5, 0.5, 0.5, 0.05)); + return Collections.singletonList(new PParticle(location, 0.5, 0.5, 0.5, 1.0)); case NOTE: return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0)); case POOF: return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); case PORTAL: - return Collections.singletonList(new PParticle(location, 0.5, 0.5, 0.5, 0.05)); + return Collections.singletonList(new PParticle(location, 0.5, 0.5, 0.5, 1.0)); case RAIN: return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); case SMOKE: @@ -132,7 +132,7 @@ public class ParticleStyleNormal implements ParticleStyle { } public String getName() { - return "none"; + return "normal"; } public boolean canBeFixed() { diff --git a/src/com/esophose/playerparticles/styles/ParticleStyleRings.java b/src/com/esophose/playerparticles/styles/ParticleStyleRings.java index 4031e3a..6759872 100644 --- a/src/com/esophose/playerparticles/styles/ParticleStyleRings.java +++ b/src/com/esophose/playerparticles/styles/ParticleStyleRings.java @@ -37,6 +37,12 @@ public class ParticleStyleRings implements ParticleStyle { return particles; } + /** + * Wraps an index around the cos/sin array length + * + * @param index The index to wrap + * @return The wrapped index + */ private int wrap(int index) { return index % cos.length; } diff --git a/src/config.yml b/src/config.yml index 0ebf03e..3552d92 100644 --- a/src/config.yml +++ b/src/config.yml @@ -159,7 +159,6 @@ gui-icon: LAVA: MAGMA_CREAM MYCELIUM: MYCELIUM NAUTILUS: HEART_OF_THE_SEA - NONE: GLASS_PANE NOTE: NOTE_BLOCK POOF: FIREWORK_STAR PORTAL: OBSIDIAN @@ -206,7 +205,6 @@ gui-icon: LARGE_SMOKE: WEB LAVA: MAGMA_CREAM MYCELIUM: MYCEL - NONE: THIN_GLASS NOTE: NOTE_BLOCK POOF: FIREWORK_CHARGE PORTAL: OBSIDIAN @@ -221,19 +219,22 @@ gui-icon: WITCH: CAULDRON style: # 1.13 and up ARROWS: BOW + BATMAN: COAL BEAM: POWERED_RAIL BLOCKBREAK: IRON_PICKAXE BLOCKEDIT: DISPENSER BLOCKPLACE: OAK_PLANKS CUBE: STONE FEET: GRASS - HALO: ENDER_PORTAL_FRAME + HALO: END_PORTAL_FRAME HURT: CACTUS MOVE: PISTON NONE: GLASS_PANE ORBIT: ENCHANTING_TABLE POINT: STONE_BUTTON QUADHELIX: NAUTILUS_SHELL + NORMAL: DIRT + RINGS: STRING SPHERE: HEART_OF_THE_SEA SPIN: BEACON SPIRAL: HOPPER @@ -242,6 +243,7 @@ gui-icon: WINGS: ELYTRA style-legacy: # 1.9 to 1.12 ARROWS: BOW + BATMAN: COAL BEAM: POWERED_RAIL BLOCKBREAK: IRON_PICKAXE BLOCKEDIT: DISPENSER @@ -251,10 +253,11 @@ gui-icon: HALO: ENDER_PORTAL_FRAME HURT: CACTUS MOVE: PISTON_BASE - NONE: THIN_GLASS + NORMAL: DIRT ORBIT: ENCHANTMENT_TABLE POINT: STONE_BUTTON QUADHELIX: ACTIVATOR_RAIL + RINGS: STRING SPHERE: SNOW_BALL SPIN: BEACON SPIRAL: HOPPER