mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-02-11 11:40:21 +00:00
Added style 'trail'
This commit is contained in:
parent
dfb39e006c
commit
80a4613725
4 changed files with 74 additions and 0 deletions
|
@ -135,6 +135,7 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
|
|||
* @param args The arguments following the command
|
||||
* @return true
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
|
||||
|
@ -188,6 +189,7 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
|
|||
* @param args All arguments following the command
|
||||
* @return A list of commands available to the sender
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
if (cmd.getName().equalsIgnoreCase("pp")) {
|
||||
PPlayer pplayer = PlayerParticlesAPI.getInstance().getPPlayer(sender);
|
||||
|
|
|
@ -180,6 +180,7 @@ public class ConfigurationManager extends Manager {
|
|||
GUI_ICON_STYLE_SPIRAL("gui-icon.style.spiral", Collections.singletonList("HOPPER")),
|
||||
GUI_ICON_STYLE_SWORDS("gui-icon.style.swords", Collections.singletonList("IRON_SWORD")),
|
||||
GUI_ICON_STYLE_THICK("gui-icon.style.thick", Arrays.asList("COBWEB", "WEB")),
|
||||
GUI_ICON_STYLE_TRAIL("gui-icon.style.trail", Collections.singletonList("GHAST_TEAR")),
|
||||
GUI_ICON_STYLE_TWINS("gui-icon.style.twins", Arrays.asList("OAK_FENCE", "FENCE")),
|
||||
GUI_ICON_STYLE_VORTEX("gui-icon.style.vortex", Collections.singletonList("GLOWSTONE_DUST")),
|
||||
GUI_ICON_STYLE_WHIRL("gui-icon.style.whirl", Collections.singletonList("FEATHER")),
|
||||
|
|
|
@ -38,6 +38,7 @@ public class DefaultStyles {
|
|||
public static final ParticleStyle SPIRAL = new ParticleStyleSpiral();
|
||||
public static final ParticleStyle SWORDS = new ParticleStyleSwords();
|
||||
public static final ParticleStyle THICK = new ParticleStyleThick();
|
||||
public static final ParticleStyle TRAIL = new ParticleStyleTrail();
|
||||
public static final ParticleStyle TWINS = new ParticleStyleTwins();
|
||||
public static final ParticleStyle VORTEX = new ParticleStyleVortex();
|
||||
public static final ParticleStyle WHIRL = new ParticleStyleWhirl();
|
||||
|
@ -78,6 +79,7 @@ public class DefaultStyles {
|
|||
particleStyleManager.registerStyle(SPIRAL);
|
||||
particleStyleManager.registerEventStyle(SWORDS);
|
||||
particleStyleManager.registerStyle(THICK);
|
||||
particleStyleManager.registerEventStyle(TRAIL);
|
||||
particleStyleManager.registerStyle(TWINS);
|
||||
particleStyleManager.registerStyle(VORTEX);
|
||||
particleStyleManager.registerStyle(WHIRL);
|
||||
|
@ -93,6 +95,7 @@ public class DefaultStyles {
|
|||
pluginManager.registerEvents((Listener) HURT, playerParticles);
|
||||
pluginManager.registerEvents((Listener) MOVE, playerParticles);
|
||||
pluginManager.registerEvents((Listener) SWORDS, playerParticles);
|
||||
pluginManager.registerEvents((Listener) TRAIL, playerParticles);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
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;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
import dev.esophose.playerparticles.particles.ParticlePair;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class ParticleStyleTrail extends DefaultParticleStyle implements Listener {
|
||||
|
||||
private double offset;
|
||||
private double spread;
|
||||
private double speed;
|
||||
|
||||
public ParticleStyleTrail() {
|
||||
super("trail", false, false, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
||||
return Collections.singletonList(new PParticle(location.clone().add(0.0, this.offset, 0.0), this.spread, this.spread, this.spread, this.speed));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTimers() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setDefaultSettings(CommentedFileConfiguration config) {
|
||||
this.setIfNotExists("player-offset", 0.0, "How far to offset the player location vertically");
|
||||
this.setIfNotExists("spread", 0.1, "How much to spread the particles");
|
||||
this.setIfNotExists("speed", 0.01, "If the particle supports speed, how much speed to apply");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadSettings(CommentedFileConfiguration config) {
|
||||
this.offset = config.getDouble("player-offset");
|
||||
this.spread = config.getDouble("spread");
|
||||
this.speed = config.getDouble("speed");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
|
||||
|
||||
Player player = event.getPlayer();
|
||||
PPlayer pplayer = PlayerParticles.getInstance().getManager(DataManager.class).getPPlayer(player.getUniqueId());
|
||||
if (pplayer != null) {
|
||||
for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.TRAIL)) {
|
||||
Location loc = player.getLocation().clone();
|
||||
loc.setY(loc.getY() + 1);
|
||||
particleManager.displayParticles(player, player.getWorld(), particle, DefaultStyles.TRAIL.getParticles(particle, loc), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue