Add new style 'celebration', add configuration rainbow speed to config.yml

This commit is contained in:
Esophose 2018-11-29 18:02:40 -07:00
parent b2cb8eb5dc
commit fc8999f628
7 changed files with 120 additions and 3 deletions

View file

@ -1,5 +1,8 @@
== UPDATING WILL DELETE YOUR CONFIG.YML ==
* Create a backup of your config.yml if you wish to import all your old settings!
=== v6.0 ===
* Many other changes, the changelog will be updated once the plugin update is about to be released
+ Added setting in config.yml to control how fast the rainbow hue cycles
=== v5.2 ===
* Added native support for Minecraft 1.13.x
* Still compatible with Minecraft 1.9 through Minecraft 1.12!

View file

@ -2,7 +2,7 @@
* TODO: v6.0
* + Add new style 'tornado'
* + Add new style 'doubleorbit'
* + Add new style 'wings_<type>', multiple new wing types
* + Add new style 'wings_<type>', multiple new wing types: fairy, demon
* * Adjust style positioning around central point based on if they are being spawned for a player or fixed effect
* * Display a note in the GUI under event-based styles
*

View file

@ -91,10 +91,10 @@ public class ParticleManager extends BukkitRunnable implements Listener {
public void run() {
ParticleStyleManager.updateTimers();
hue++;
hue += PSetting.RAINBOW_CYCLE_SPEED.getInt();
hue %= 360;
if (hue % 5 == 0) { // Only increment note by 4 notes per second
if (hue % 4 == 0) { // Only increment note by 5 notes per second
note++;
note %= 25;
}

View file

@ -55,6 +55,8 @@ public class SettingManager {
MAX_GROUPS(PSettingType.INTEGER),
RAINBOW_CYCLE_SPEED(PSettingType.INTEGER),
DISABLED_WORLDS(PSettingType.STRING_LIST),
LANG_FILE(PSettingType.STRING);

View file

@ -20,6 +20,7 @@ public class DefaultStyles {
public static final ParticleStyle BLOCKBREAK = new ParticleStyleBlockBreak();
public static final ParticleStyle BLOCKEDIT = new ParticleStyleBlockEdit();
public static final ParticleStyle BLOCKPLACE = new ParticleStyleBlockPlace();
public static final ParticleStyle CELEBRATION = new ParticleStyleCelebration();
public static final ParticleStyle CHAINS = new ParticleStyleChains();
public static final ParticleStyle COMPANION = new ParticleStyleCompanion();
public static final ParticleStyle CUBE = new ParticleStyleCube();
@ -53,6 +54,7 @@ public class DefaultStyles {
ParticleStyleManager.registerCustomHandledStyle(BLOCKBREAK);
ParticleStyleManager.registerCustomHandledStyle(BLOCKEDIT);
ParticleStyleManager.registerCustomHandledStyle(BLOCKPLACE);
ParticleStyleManager.registerStyle(CELEBRATION);
ParticleStyleManager.registerStyle(CHAINS);
ParticleStyleManager.registerStyle(COMPANION);
ParticleStyleManager.registerStyle(CUBE);

View file

@ -0,0 +1,104 @@
package com.esophose.playerparticles.styles;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import com.esophose.playerparticles.PlayerParticles;
import com.esophose.playerparticles.manager.ParticleManager;
import com.esophose.playerparticles.particles.PPlayer;
import com.esophose.playerparticles.particles.ParticleEffect;
import com.esophose.playerparticles.particles.ParticlePair;
import com.esophose.playerparticles.styles.api.PParticle;
import com.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleCelebration implements ParticleStyle {
private int step = 0;
private final int spawnTime = 15;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
return null;
}
/**
* Spawns fireworks every spawnTime number of ticks
* This style uses two different effects, one is always 'firework'
*/
public void updateTimers() {
step++;
if (step == spawnTime) {
step = 0;
final Random random = new Random();
for (PPlayer pplayer : ParticleManager.getPPlayers()) {
final Player player = pplayer.getPlayer();
for (ParticlePair particle : pplayer.getActiveParticles()) {
if (particle.getStyle() != this) continue;
double angle = random.nextDouble() * Math.PI * 2;
double distanceFrom = 1.25 + random.nextDouble() * 1.5;
double dx = Math.sin(angle) * distanceFrom;
double dz = Math.cos(angle) * distanceFrom;
final Location loc = player.getLocation().clone().add(dx, 1, dz);
final int fuse = 3 + random.nextInt(3);
new BukkitRunnable() {
private Location location = loc;
private int fuseLength = fuse;
private int fuseTimer = 0;
public void run() {
if (this.fuseTimer < this.fuseLength) {
ParticlePair trail = ParticlePair.getNextDefault(pplayer);
trail.setEffect(ParticleEffect.FIREWORK);
trail.setStyle(DefaultStyles.CELEBRATION);
ParticleManager.displayParticles(trail, Collections.singletonList(new PParticle(this.location)));
this.location.add(0, 0.25, 0);
} else {
List<PParticle> particles = new ArrayList<PParticle>();
for (int i = 0; i < 40; i++) { // Copied directly from PlayerParticles source
double radius = 0.6 + random.nextDouble() * 0.2;
double u = random.nextDouble();
double v = random.nextDouble();
double theta = 2 * Math.PI * u;
double phi = Math.acos(2 * v - 1);
double dx = radius * Math.sin(phi) * Math.cos(theta);
double dy = radius * Math.sin(phi) * Math.sin(theta);
double dz = radius * Math.cos(phi);
particles.add(new PParticle(this.location.clone().add(dx, dy, dz)));
}
ParticleManager.displayParticles(particle, particles);
this.cancel();
}
this.fuseTimer++;
}
}.runTaskTimer(PlayerParticles.getPlugin(), 0, 1);
}
}
}
}
public String getName() {
return "celebration";
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -90,6 +90,12 @@ particle-render-range-player: 48
# Default: 192
particle-render-range-fixed-effect: 192
# How many out of 360 hue ticks to move per game tick
# Higher values make the rainbow cycle faster
# Note: Must be positive whole numbers
# Default: 2
rainbow-cycle-speed: 2
# ================================================================ #
# DATABASE CONFIGURATION #
# Information: #