diff --git a/src/com/esophose/playerparticles/command/AddCommandModule.java b/src/com/esophose/playerparticles/command/AddCommandModule.java index 44ab723..82a7b04 100644 --- a/src/com/esophose/playerparticles/command/AddCommandModule.java +++ b/src/com/esophose/playerparticles/command/AddCommandModule.java @@ -4,6 +4,7 @@ import java.util.List; import org.bukkit.Material; +import com.esophose.playerparticles.manager.DataManager; import com.esophose.playerparticles.manager.LangManager; import com.esophose.playerparticles.manager.ParticleManager; import com.esophose.playerparticles.manager.PermissionManager; @@ -13,6 +14,8 @@ 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.ParticleEffect.ParticleProperty; +import com.esophose.playerparticles.particles.ParticleGroup; +import com.esophose.playerparticles.particles.ParticlePair; import com.esophose.playerparticles.styles.api.ParticleStyle; import com.esophose.playerparticles.styles.api.ParticleStyleManager; import com.esophose.playerparticles.util.ParticleUtils; @@ -114,7 +117,9 @@ public class AddCommandModule implements CommandModule { } } - // TODO: Update active group and save + ParticleGroup group = pplayer.getActiveParticleGroup(); + group.getParticles().add(new ParticlePair(pplayer.getUniqueId(), pplayer.getNextActiveParticleId(), effect, style, blockData, blockData, colorData, noteColorData)); + DataManager.saveParticleGroup(pplayer.getUniqueId(), group); } } diff --git a/src/com/esophose/playerparticles/particles/PPlayer.java b/src/com/esophose/playerparticles/particles/PPlayer.java index 37ca783..a79bbb0 100644 --- a/src/com/esophose/playerparticles/particles/PPlayer.java +++ b/src/com/esophose/playerparticles/particles/PPlayer.java @@ -75,7 +75,8 @@ public class PPlayer { */ public ParticleGroup getParticlesByName(String name) { for (ParticleGroup group : this.particleGroups) - if (group.getName().equalsIgnoreCase(name)) return group; + if (group.getName().equalsIgnoreCase(name)) + return group; return null; } @@ -85,8 +86,18 @@ public class PPlayer { * @return A List of all particles this player has set */ public List getActiveParticles() { + return this.getActiveParticleGroup().getParticles(); + } + + /** + * Get the PPlayer's active ParticleGroup + * + * @return A ParticleGroup of this player's active particles + */ + public ParticleGroup getActiveParticleGroup() { for (ParticleGroup group : this.particleGroups) - if (group.getName() == null) return group.getParticles(); + if (group.getName() == null) + return group; return null; // This should never return null, there will always be at least one ParticleGroup } @@ -99,7 +110,8 @@ public class PPlayer { public List getActiveParticlesForStyle(ParticleStyle style) { List matches = new ArrayList(); for (ParticlePair pair : this.getActiveParticles()) - if (pair.getStyle().equals(style)) matches.add(pair); + if (pair.getStyle().equals(style)) + matches.add(pair); return matches; } @@ -111,7 +123,8 @@ public class PPlayer { */ public ParticlePair getActiveParticle(int id) { for (ParticlePair particle : this.getActiveParticles()) - if (particle.getId() == id) return particle; + if (particle.getId() == id) + return particle; return null; } @@ -132,7 +145,8 @@ public class PPlayer { */ public FixedParticleEffect getFixedEffectById(int id) { for (FixedParticleEffect fixedEffect : this.fixedParticles) - if (fixedEffect.getId() == id) return fixedEffect; + if (fixedEffect.getId() == id) + return fixedEffect; return null; } @@ -164,13 +178,13 @@ public class PPlayer { */ public void removeFixedEffect(int id) { for (int i = this.fixedParticles.size() - 1; i >= 0; i--) - if (this.fixedParticles.get(i).getId() == id) this.fixedParticles.remove(i); + if (this.fixedParticles.get(i).getId() == id) + this.fixedParticles.remove(i); } /** * Gets the next Id for a player's fixed effects * - * @param pplayerUUID The player to get the Id for * @return The next available fixed effect id */ public int getNextFixedEffectId() { @@ -181,4 +195,17 @@ public class PPlayer { return ParticleUtils.getSmallestPositiveInt(ids); } + /** + * Gets the next Id for a player's active particles + * + * @return The next available active particle id + */ + public int getNextActiveParticleId() { + List activeParticles = this.getActiveParticles(); + int[] ids = new int[activeParticles.size()]; + for (int i = 0; i < activeParticles.size(); i++) + ids[i] = activeParticles.get(i).getId(); + return ParticleUtils.getSmallestPositiveInt(ids); + } + } diff --git a/src/lang/en_US.lang b/src/lang/en_US.lang index 290f5db..b67ed7d 100644 --- a/src/lang/en_US.lang +++ b/src/lang/en_US.lang @@ -54,12 +54,12 @@ style-list: '&eYou can use the following styles: &b{0}' # Data data-usage-none: '&eYour current effect does not use any data!' -data-usage-block: '&eThe effect &b{0} requires &bblock &edata! &bFormat: ' -data-usage-item: '&eThe effect &b{0} requires &bitem &edata! &bFormat: ' +data-usage-block: '&eThe effect &b{0} requires &bblock &edata! &bFormat: ' +data-usage-item: '&eThe effect &b{0} requires &bitem &edata! &bFormat: ' data-usage-color: '&eThe effect &b{0} requires &bcolor &edata! &bFormat: [<0-255> <0-255> <0-255>]|[]' data-usage-note: '&eThe effect &b{0} requires &bnote &edata! &bFormat: <0-23>/' -data-invalid-block: '&cThe &bblock &cdata you entered is invalid! &bFormat: ' -data-invalid-item: '&cThe &bitem &cdata you entered is invalid! &bFormat: ' +data-invalid-block: '&cThe &bblock &cdata you entered is invalid! &bFormat: ' +data-invalid-item: '&cThe &bitem &cdata you entered is invalid! &bFormat: ' data-invalid-color: '&cThe &bcolor &cdata you entered is invalid! &bFormat: [<0-255> <0-255> <0-255>]|[]' data-invalid-note: '&cThe &bitem &cdata you entered is invalid! &bFormat: <0-23>/' data-invalid-material-not-item: '&cThe &bitem &cmaterial &b{0} &cyou entered is not an item!'