Bug fix relating to opening GUI without a particle of ID 1

This commit is contained in:
Esophose 2018-12-03 01:38:56 -07:00
parent b9e8aa3028
commit c71bd75b53
3 changed files with 21 additions and 3 deletions

View file

@ -1,9 +1,15 @@
/* /*
* TODO: v6.1 * TODO: v6.1
* * Write a class called ConfigManager which manages updating the config.yml between versions so it doesn't have to be deleted every time * + Add \n support for GUI messages to break lore onto a new line
* * Make the GUI ignore empty lore lines rather than putting an empty line there
*
* TODO: v6.2
* + Add new style 'tornado' * + Add new style 'tornado'
* + Add new style 'doubleorbit' * + Add new style 'doubleorbit'
* + Add new style 'wings_<type>', multiple new wing types: fairy, demon * + Add new style 'wings_<type>', multiple new wing types: fairy, demon
* * Create lore line parser
* * Make it so lore lines of the GUI are removed if the string is empty in the config
* * Add ability to add line breaks to the lore with \n
*/ */
package com.esophose.playerparticles; package com.esophose.playerparticles;

View file

@ -82,8 +82,8 @@ public class GuiInventoryDefault extends GuiInventory {
}); });
this.actionButtons.add(loadPresetGroups); this.actionButtons.add(loadPresetGroups);
final ParticlePair editingParticle = pplayer.getActiveParticles().isEmpty() ? ParticlePair.getNextDefault(pplayer) : pplayer.getActiveParticle(1); final ParticlePair editingParticle = pplayer.getPrimaryParticle();
boolean canEditPrimaryStyleAndData = !pplayer.getActiveParticles().isEmpty(); boolean canEditPrimaryStyleAndData = pplayer.getActiveParticle(1) != null;
boolean doesEffectUseData = editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA); boolean doesEffectUseData = editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA);
// Edit Primary Effect // Edit Primary Effect

View file

@ -256,4 +256,16 @@ public class PPlayer {
return ParticleUtils.getSmallestPositiveInt(ids); return ParticleUtils.getSmallestPositiveInt(ids);
} }
/**
* Gets the primary particle (ID 1) for the PPlayer
* @return
*/
public ParticlePair getPrimaryParticle() {
ParticlePair primaryParticle = this.getActiveParticle(1);
if (primaryParticle == null) {
primaryParticle = ParticlePair.getNextDefault(this);
}
return primaryParticle;
}
} }