From c71bd75b5311c39cb88d28c16dd9d096d4b34fcb Mon Sep 17 00:00:00 2001 From: Esophose Date: Mon, 3 Dec 2018 01:38:56 -0700 Subject: [PATCH] Bug fix relating to opening GUI without a particle of ID 1 --- .../esophose/playerparticles/PlayerParticles.java | 8 +++++++- .../playerparticles/gui/GuiInventoryDefault.java | 4 ++-- .../esophose/playerparticles/particles/PPlayer.java | 12 ++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/com/esophose/playerparticles/PlayerParticles.java b/src/com/esophose/playerparticles/PlayerParticles.java index c6177a0..d3b1ab5 100644 --- a/src/com/esophose/playerparticles/PlayerParticles.java +++ b/src/com/esophose/playerparticles/PlayerParticles.java @@ -1,9 +1,15 @@ /* * 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 'doubleorbit' * + Add new style 'wings_', 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; diff --git a/src/com/esophose/playerparticles/gui/GuiInventoryDefault.java b/src/com/esophose/playerparticles/gui/GuiInventoryDefault.java index 1ace0c6..e7d989b 100644 --- a/src/com/esophose/playerparticles/gui/GuiInventoryDefault.java +++ b/src/com/esophose/playerparticles/gui/GuiInventoryDefault.java @@ -82,8 +82,8 @@ public class GuiInventoryDefault extends GuiInventory { }); this.actionButtons.add(loadPresetGroups); - final ParticlePair editingParticle = pplayer.getActiveParticles().isEmpty() ? ParticlePair.getNextDefault(pplayer) : pplayer.getActiveParticle(1); - boolean canEditPrimaryStyleAndData = !pplayer.getActiveParticles().isEmpty(); + final ParticlePair editingParticle = pplayer.getPrimaryParticle(); + boolean canEditPrimaryStyleAndData = pplayer.getActiveParticle(1) != null; boolean doesEffectUseData = editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA); // Edit Primary Effect diff --git a/src/com/esophose/playerparticles/particles/PPlayer.java b/src/com/esophose/playerparticles/particles/PPlayer.java index 2d68198..09d26f9 100644 --- a/src/com/esophose/playerparticles/particles/PPlayer.java +++ b/src/com/esophose/playerparticles/particles/PPlayer.java @@ -255,5 +255,17 @@ public class PPlayer { ids[i] = activeParticles.get(i).getId(); 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; + } }