Add new setting 'toggle-on-move', change version to v6.0

This commit is contained in:
Esophose 2018-11-16 03:26:08 -07:00
parent f14af99fe1
commit 46f5107270
36 changed files with 246 additions and 23 deletions

12
pom.xml
View file

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.esophose.playerparticles</groupId>
<artifactId>PlayerParticles</artifactId>
<version>5.3</version>
<version>6.0</version>
<name>PlayerParticles</name>
<url>https://github.com/Esophose/PlayerParticles</url>
<description>Display particles around your player using customized styles and data!</description>
@ -54,7 +54,7 @@
</excludes>
</filter>
</filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.13\plugins\update\PlayerParticles v5.3.jar</outputFile>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.13\plugins\update\PlayerParticles v6.0.jar</outputFile>
</configuration>
</execution>
<execution>
@ -81,7 +81,7 @@
</excludes>
</filter>
</filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.12\plugins\update\PlayerParticles v5.3.jar</outputFile>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.12\plugins\update\PlayerParticles v6.0.jar</outputFile>
</configuration>
</execution>
<execution>
@ -108,7 +108,7 @@
</excludes>
</filter>
</filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.11\plugins\update\PlayerParticles v5.3.jar</outputFile>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.11\plugins\update\PlayerParticles v6.0.jar</outputFile>
</configuration>
</execution>
<execution>
@ -135,7 +135,7 @@
</excludes>
</filter>
</filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.10\plugins\update\PlayerParticles v5.3.jar</outputFile>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.10\plugins\update\PlayerParticles v6.0.jar</outputFile>
</configuration>
</execution>
<execution>
@ -162,7 +162,7 @@
</excludes>
</filter>
</filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.9\plugins\update\PlayerParticles v5.3.jar</outputFile>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.9\plugins\update\PlayerParticles v6.0.jar</outputFile>
</configuration>
</execution>
</executions>

View file

@ -1,9 +1,11 @@
/*
* TODO: v5.3 (actually v6)
* TODO: v6.0
* + Add new style 'tornado'
* + Add new style 'doubleorbit'
* * Adjust PParticles to use a Vector instead of a Location
* * Setting in config.yml to make non-event styles display particles using DefaultStyles.FEET while the player is moving
* * Adjust style positioning around central point based on if they are being spawned for a player or fixed effect
* * Write a class called ConfigManager which manages updating the config.yml between versions so it doesn't have to be deleted every time
* * Clean up the '/pp help' menu and command descriptions so each command fits on one line
* * Display a note in the GUI under event-based styles
*/
package com.esophose.playerparticles;
@ -25,6 +27,7 @@ import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.ParticleManager;
import com.esophose.playerparticles.manager.SettingManager;
import com.esophose.playerparticles.manager.SettingManager.PSetting;
import com.esophose.playerparticles.particles.PPlayerMovementListener;
import com.esophose.playerparticles.particles.ParticleGroup;
import com.esophose.playerparticles.styles.DefaultStyles;
import com.esophose.playerparticles.updater.PluginUpdateListener;
@ -62,6 +65,7 @@ public class PlayerParticles extends JavaPlugin {
Bukkit.getPluginManager().registerEvents(new ParticleManager(), this);
Bukkit.getPluginManager().registerEvents(new PluginUpdateListener(), this);
Bukkit.getPluginManager().registerEvents(new GuiHandler(), this);
Bukkit.getPluginManager().registerEvents(new PPlayerMovementListener(), this);
saveDefaultConfig();
double configVersion = PSetting.VERSION.getDouble();

View file

@ -16,12 +16,14 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitRunnable;
import com.esophose.playerparticles.manager.SettingManager.PSetting;
import com.esophose.playerparticles.particles.FixedParticleEffect;
import com.esophose.playerparticles.particles.PPlayer;
import com.esophose.playerparticles.particles.ParticleEffect;
import com.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import com.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import com.esophose.playerparticles.particles.ParticlePair;
import com.esophose.playerparticles.styles.DefaultStyles;
import com.esophose.playerparticles.styles.api.PParticle;
import com.esophose.playerparticles.styles.api.ParticleStyleManager;
@ -106,7 +108,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
// Don't spawn particles if the world doesn't allow it
if (player != null && player.getGameMode() != GameMode.SPECTATOR && !PermissionManager.isWorldDisabled(player.getWorld().getName()))
for (ParticlePair particles : pplayer.getActiveParticles())
displayParticles(particles, player.getLocation().clone().add(0, 1, 0));
displayParticles(pplayer, particles, player.getLocation().clone().add(0, 1, 0));
// Loop for FixedParticleEffects
// Don't spawn particles if the world doesn't allow it
@ -119,13 +121,20 @@ public class ParticleManager extends BukkitRunnable implements Listener {
/**
* Displays particles at the given player location with their settings
*
* @param pplayer The PPlayer to spawn the particles for
* @param particle The ParticlePair to use for getting particle settings
* @param location The location to display at
*/
private void displayParticles(ParticlePair particle, Location location) {
if (!ParticleStyleManager.isCustomHandled(particle.getStyle()))
for (PParticle pparticle : particle.getStyle().getParticles(particle, location))
ParticleEffect.display(particle, pparticle, false);
private void displayParticles(PPlayer pplayer, ParticlePair particle, Location location) {
if (!ParticleStyleManager.isCustomHandled(particle.getStyle())) {
if (PSetting.TOGGLE_ON_MOVE.getBoolean() && particle.getStyle().canToggleWithMovement() && pplayer.isMoving()) {
for (PParticle pparticle : DefaultStyles.FEET.getParticles(particle, location))
ParticleEffect.display(particle, pparticle, false);
} else {
for (PParticle pparticle : particle.getStyle().getParticles(particle, location))
ParticleEffect.display(particle, pparticle, false);
}
}
}
/**

View file

@ -32,6 +32,7 @@ public class SettingManager {
TICKS_PER_PARTICLE(PSettingType.LONG),
CHECK_UPDATES(PSettingType.BOOLEAN),
GUI_ENABLED(PSettingType.BOOLEAN),
TOGGLE_ON_MOVE(PSettingType.BOOLEAN),
PARTICLE_RENDER_RANGE_PLAYER(PSettingType.INTEGER),
PARTICLE_RENDER_RANGE_FIXED_EFFECT(PSettingType.INTEGER),

View file

@ -31,6 +31,11 @@ public class PPlayer {
* If True, the player will not see any particles spawned by the plugin
*/
private boolean particlesHidden;
/**
* If the player is moving
*/
private boolean isMoving;
/**
* Constructs a new PPlayer
@ -44,7 +49,9 @@ public class PPlayer {
this.playerUUID = uuid;
this.particleGroups = particleGroups;
this.fixedParticles = fixedParticles;
this.particlesHidden = particlesHidden;
this.isMoving = false;
}
/**
@ -91,6 +98,19 @@ public class PPlayer {
public List<ParticleGroup> getParticleGroups() {
return this.particleGroups;
}
/**
* Sets the player's movement state
*
* @param isMoving True if the player is moving, otherwise false if they are standing still
*/
public void setMoving(boolean isMoving) {
this.isMoving = isMoving;
}
public boolean isMoving() {
return this.isMoving;
}
/**
* Gets a ParticleGroup this player has by its name

View file

@ -0,0 +1,68 @@
package com.esophose.playerparticles.particles;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.scheduler.BukkitRunnable;
import com.esophose.playerparticles.PlayerParticles;
import com.esophose.playerparticles.manager.DataManager;
import com.esophose.playerparticles.manager.SettingManager.PSetting;
public class PPlayerMovementListener implements Listener {
private static Map<UUID, Integer> timeSinceLastMovement = new HashMap<UUID, Integer>();
private static final int STANDING_TIME = 9;
private static final int CHECK_INTERVAL = 3;
public PPlayerMovementListener() {
new BukkitRunnable() {
public void run() {
if (!PSetting.TOGGLE_ON_MOVE.getBoolean()) return;
List<UUID> toRemove = new ArrayList<UUID>();
for (UUID uuid : timeSinceLastMovement.keySet()) {
PPlayer pplayer = DataManager.getPPlayer(uuid);
if (pplayer == null) {
toRemove.add(uuid);
} else {
int standingTime = timeSinceLastMovement.get(uuid);
pplayer.setMoving(standingTime < STANDING_TIME);
if (standingTime < STANDING_TIME)
timeSinceLastMovement.replace(uuid, standingTime + CHECK_INTERVAL);
}
}
for (UUID uuid : toRemove)
timeSinceLastMovement.remove(uuid);
}
}.runTaskTimer(PlayerParticles.getPlugin(), 0, CHECK_INTERVAL);
}
/**
* Used to detect if the player is moving
*
* @param event The event
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent event) {
if (!PSetting.TOGGLE_ON_MOVE.getBoolean()) return;
if (event.getTo().getBlockX() == event.getFrom().getBlockX() && event.getTo().getBlockY() == event.getFrom().getBlockY() && event.getTo().getBlockZ() == event.getFrom().getBlockZ()) return;
UUID playerUUID = event.getPlayer().getUniqueId();
if (!timeSinceLastMovement.containsKey(playerUUID)) {
timeSinceLastMovement.put(playerUUID, 0);
} else {
timeSinceLastMovement.replace(playerUUID, 0);
}
}
}

View file

@ -49,6 +49,10 @@ public class ParticleStyleArrows implements ParticleStyle, Listener {
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return false;
}
/**
* The event used to get all arrows fired by players
@ -68,7 +72,8 @@ public class ParticleStyleArrows implements ParticleStyle, Listener {
}
}
if (match) arrows.add((Arrow) e.getProjectile());
if (match)
arrows.add((Arrow) e.getProjectile());
}
}

View file

@ -120,5 +120,9 @@ public class ParticleStyleBatman implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -58,5 +58,9 @@ public class ParticleStyleBeam implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -41,6 +41,10 @@ public class ParticleStyleBlockBreak implements ParticleStyle, Listener {
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return false;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event) {

View file

@ -35,6 +35,10 @@ public class ParticleStyleBlockEdit implements ParticleStyle, Listener {
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return false;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event) {

View file

@ -41,6 +41,10 @@ public class ParticleStyleBlockPlace implements ParticleStyle, Listener {
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return false;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPlace(BlockPlaceEvent event) {

View file

@ -35,5 +35,9 @@ public class ParticleStyleChains implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -73,5 +73,9 @@ public class ParticleStyleCompanion implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return false;
}
}

View file

@ -98,5 +98,9 @@ public class ParticleStyleCube implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -28,5 +28,9 @@ public class ParticleStyleFeet implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return false;
}
}

View file

@ -56,5 +56,9 @@ public class ParticleStyleHalo implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return false;
}
}

View file

@ -42,6 +42,10 @@ public class ParticleStyleHurt implements ParticleStyle, Listener {
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return false;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDamage(EntityDamageEvent event) {

View file

@ -98,5 +98,9 @@ public class ParticleStyleInvocation implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -32,6 +32,10 @@ public class ParticleStyleMove implements ParticleStyle, Listener {
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return false;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent e) {

View file

@ -138,5 +138,9 @@ public class ParticleStyleNormal implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return false;
}
}

View file

@ -52,5 +52,9 @@ public class ParticleStyleOrbit implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -29,5 +29,9 @@ public class ParticleStyleOverhead implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return false;
}
}

View file

@ -26,5 +26,9 @@ public class ParticleStylePoint implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return false;
}
}

View file

@ -64,5 +64,9 @@ public class ParticleStyleQuadhelix implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -58,5 +58,9 @@ public class ParticleStyleRings implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -41,5 +41,9 @@ public class ParticleStyleSphere implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -46,5 +46,9 @@ public class ParticleStyleSpin implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -35,5 +35,9 @@ public class ParticleStyleSpiral implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -51,6 +51,10 @@ public class ParticleStyleSwords implements ParticleStyle, Listener {
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return false;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDamageEntity(EntityDamageByEntityEvent event) {

View file

@ -34,5 +34,9 @@ public class ParticleStyleThick implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -66,5 +66,9 @@ public class ParticleStyleVortex implements ParticleStyle {
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -40,5 +40,9 @@ public class ParticleStyleWings implements ParticleStyle {
public boolean canBeFixed() {
return false;
}
public boolean canToggleWithMovement() {
return true;
}
}

View file

@ -36,6 +36,12 @@ public interface ParticleStyle {
*/
public boolean canBeFixed();
/**
* Gets if the style can be replaced with DefaultStyles.FEET when the player is moving
*
* @return True if it can be, otherwise False
*/
public boolean canToggleWithMovement();
/**
* Gets the ParticleStyle with the name given, returns null if not found

View file

@ -1,8 +1,8 @@
# __________ __ __________ __ __ __ ________
# \______ \ | _____ ___ __ __________\______ \_____ ________/ |_|__| ____ | | ____ ______ ___ _| ____/
# | ___/ | \__ \< | |/ __ \_ __ \ ___/\__ \\_ __ \ __\ |/ ___\| | _/ __ \ / ___/ \ \/ /____ \
# | | | |__/ __ \\___ \ ___/| | \/ | / __ \| | \/| | | \ \___| |_\ ___/ \___ \ \ // \
# |____| |____(____ / ____|\___ >__| |____| (____ /__| |__| |__|\___ >____/\___ >____ > \_//______ /
# \______ \ | _____ ___ __ __________\______ \_____ ________/ |_|__| ____ | | ____ ______ ___ __/ _____/
# | ___/ | \__ \< | |/ __ \_ __ \ ___/\__ \\_ __ \ __\ |/ ___\| | _/ __ \ / ___/ \ \/ / __ \
# | | | |__/ __ \\___ \ ___/| | \/ | / __ \| | \/| | | \ \___| |_\ ___/ \___ \ \ /\ |__\ \
# |____| |____(____ / ____|\___ >__| |____| (____ /__| |__| |__|\___ >____/\___ >____ > \_/ \_____ /
# \/\/ \/ \/ \/ \/ \/ \/
# ==================================================== #
@ -11,9 +11,9 @@
# ==================================================== #
# This value is the version of the plugin that last modified the config file
# Changing this value will reset your config on the next server reload / restart.
# I don't recommend changing it
version: 5.3
# Changing this value manually will likely result in data loss and errors!
# Do not change this manually unless specifically told to by the plugin author
version: 6.0
# Check for new versions of the plugin
# Default: true
@ -41,6 +41,12 @@ message-prefix: '&7[&3PlayerParticles&7]'
# Default: true
gui-enabled: true
# If true, styles will not display while the player is moving
# They will instead have the effect displayed at their feet
# Note: Not all styles abide by this rule, but most will
# Default: false
toggle-on-move: false
# The worlds which this plugin is disabled in
# Remove the [] before you enter world names
# Default: []

View file

@ -1,6 +1,6 @@
name: PlayerParticles
main: com.esophose.playerparticles.PlayerParticles
version: 5.3
version: 6.0
api-version: 1.13
description: Display particles around your player using customized styles and data!
author: Esophose