Added setting to hide preset group descriptions, added preset lore

This commit is contained in:
Esophose 2020-09-17 22:02:47 -06:00
parent 99daf94112
commit 4ce525785a
5 changed files with 40 additions and 17 deletions

View file

@ -49,21 +49,21 @@ public class GuiInventoryLoadPresetGroups extends GuiInventory {
List<ParticlePair> particles = new ArrayList<>(group.getGroup().getParticles().values());
particles.sort(Comparator.comparingInt(ParticlePair::getId));
String[] lore = new String[particles.size() + 1];
lore[0] = localeManager.getLocaleMessage("gui-color-subtext") + localeManager.getLocaleMessage("gui-click-to-load", StringPlaceholders.single("amount", particles.size()));
int n = 1;
for (ParticlePair particle : particles) {
StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", particle.getId())
.addPlaceholder("effect", ParticleUtils.formatName(particle.getEffect().getName()))
.addPlaceholder("style", ParticleUtils.formatName(particle.getStyle().getName()))
.addPlaceholder("data", particle.getDataString())
.build();
lore[n] = localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-particle-info", stringPlaceholders);
n++;
List<String> lore = new ArrayList<>(group.getLore());
if (!Setting.GUI_PRESETS_HIDE_PARTICLES_DESCRIPTIONS.getBoolean()) {
lore.add(localeManager.getLocaleMessage("gui-color-subtext") + localeManager.getLocaleMessage("gui-click-to-load", StringPlaceholders.single("amount", particles.size())));
for (ParticlePair particle : particles) {
StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", particle.getId())
.addPlaceholder("effect", ParticleUtils.formatName(particle.getEffect().getName()))
.addPlaceholder("style", ParticleUtils.formatName(particle.getStyle().getName()))
.addPlaceholder("data", particle.getDataString())
.build();
lore.add(localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-particle-info", stringPlaceholders));
}
}
// Load Group Buttons
GuiActionButton groupButton = new GuiActionButton(slot, group.getGuiIcon(), localeManager.getLocaleMessage("gui-color-icon-name") + group.getDisplayName(), lore, (button, isShiftClick) -> {
GuiActionButton groupButton = new GuiActionButton(slot, group.getGuiIcon(), localeManager.getLocaleMessage("gui-color-icon-name") + group.getDisplayName(), lore.toArray(new String[0]), (button, isShiftClick) -> {
ParticleGroup activeGroup = pplayer.getActiveParticleGroup();
activeGroup.getParticles().clear();
for (ParticlePair particle : particles) {

View file

@ -39,6 +39,7 @@ public class ConfigurationManager extends Manager {
GUI_REQUIRE_PERMISSION("gui-require-permission", false, "If the GUI should require the permission playerparticles.gui to open"),
GUI_REQUIRE_EFFECTS_AND_STYLES("gui-require-effects-and-styles", true, "If the GUI should require the player to have permission for at least", "one effect and one style to be able to open the GUI"),
GUI_PRESETS_ONLY("gui-presets-only", false, "If true, only the preset groups will be available in the GUI", "Permissions to open the GUI will change to only open if the user has any preset groups available"),
GUI_PRESETS_HIDE_PARTICLES_DESCRIPTIONS("gui-presets-hide-particles-descriptions", false, "If true, the particle descriptions in the item lore for preset groups will be hidden"),
GUI_CLOSE_AFTER_GROUP_SELECTED("gui-close-after-group-selected", true, "If true, the GUI will close after selecting a group (either saved or preset)"),
GUI_BUTTON_SOUND("gui-button-sound", true, "If clicking a GUI button should make a noise"),
TOGGLE_ON_MOVE("toggle-on-move", "NONE", "Valid values: DISPLAY_FEET, DISPLAY_NORMAL, DISPLAY_OVERHEAD, HIDE, NONE", "DISPLAY_FEET will display particles using the feet style while moving", "DISPLAY_NORMAL will display particles using the normal style while moving", "DISPLAY_OVERHEAD will display particles using the overhead style while moving", "HIDE will hide particles while moving", "NONE will make this setting do nothing", "Note: You can change what styles follow this setting in their individual setting files"),

View file

@ -84,6 +84,7 @@ public class ParticleGroupPresetManager extends Manager {
String displayName = "";
Material guiIcon = Material.ENDER_CHEST;
int guiSlot = -1;
List<String> lore = new ArrayList<>();
String permission = "";
boolean allowPermissionOverride = false;
ConfigurationSection groupSection = presetsSection.getConfigurationSection(groupName);
@ -91,7 +92,7 @@ public class ParticleGroupPresetManager extends Manager {
Set<String> particleKeys = groupSection.getKeys(false);
for (String stringId : particleKeys) {
if (stringId.equalsIgnoreCase("display-name")) {
displayName = groupSection.getString(stringId);
displayName = HexUtils.colorify(groupSection.getString(stringId));
continue;
}
@ -105,6 +106,12 @@ public class ParticleGroupPresetManager extends Manager {
continue;
}
if (stringId.equalsIgnoreCase("lore")) {
lore = groupSection.getStringList("lore");
lore.replaceAll(HexUtils::colorify);
continue;
}
if (stringId.equalsIgnoreCase("permission")) {
permission = groupSection.getString(stringId);
continue;
@ -175,7 +182,7 @@ public class ParticleGroupPresetManager extends Manager {
particles.put(id, new ParticlePair(null, id, effect, style, itemData, blockData, colorData, noteColorData));
}
presets.add(new ParticleGroupPreset(HexUtils.colorify(displayName), guiIcon, guiSlot, permission, allowPermissionOverride, new ParticleGroup(groupName, particles)));
presets.add(new ParticleGroupPreset(displayName, guiIcon, guiSlot, lore, permission, allowPermissionOverride, new ParticleGroup(groupName, particles)));
}
}

View file

@ -4,6 +4,7 @@ import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleGroup;
import java.util.List;
import org.bukkit.Material;
public class ParticleGroupPreset {
@ -11,14 +12,16 @@ public class ParticleGroupPreset {
private final String displayName;
private final Material guiIcon;
private final int guiSlot;
private final List<String> lore;
private final String permission;
private final boolean allowPermissionOverride;
private final ParticleGroup group;
public ParticleGroupPreset(String displayName, Material guiIcon, int guiSlot, String permission, boolean allowPermissionOverride, ParticleGroup group) {
public ParticleGroupPreset(String displayName, Material guiIcon, int guiSlot, List<String> lore, String permission, boolean allowPermissionOverride, ParticleGroup group) {
this.displayName = displayName;
this.guiIcon = guiIcon;
this.guiSlot = guiSlot;
this.lore = lore;
this.permission = permission;
this.allowPermissionOverride = allowPermissionOverride;
this.group = group;
@ -50,6 +53,15 @@ public class ParticleGroupPreset {
public int getGuiSlot() {
return this.guiSlot;
}
/**
* Gets the GUI lore for this particle group
*
* @return The GUI lore for this particle group
*/
public List<String> getLore() {
return this.lore;
}
/**
* Checks if a player has permission to use this particle group

View file

@ -10,7 +10,7 @@
# want to reset the file to its defaults, simply #
# delete it and run the command '/pp reload'. #
# ==================================================== #
#
# What everything means:
# The top-level items are separators and represent each individual page. The pages will be in the same order
# that they appear in the config. The title is what will be displayed as the title of the GUI for that given page.
@ -18,13 +18,13 @@
# display-name: The display name of the group, how it will show up in the GUI.
# gui-icon: The icon to use for the GUI.
# gui-slot: The slot that will be filled in the GUI.
# lore: Extra text that will appear on the preset group button.
# permission: The permission that the player must have to see this group, may be left blank as ''. The player must still have permission for all effects/styles within the group in order to use it.
# allow-permission-override: Allow the player to see and apply the group even if they don't have access to all the effects/styles within it. This does nothing if the permission is set to ''.
# 1 (or any positive whole number n): The particle ID. You may have as many of these as you want, they must contain an effect, style, and data property below them.
# effect: The effect that the particle will have.
# style: The style that the particle will have.
# data: The data that the particle will have.
# GUI Icons MUST use the names found at the link below:
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
#
@ -38,6 +38,9 @@ page1:
display-name: 'Raincloud'
gui-icon: 'ENDER_CHEST'
gui-slot: 10
lore:
- '&cExample extra lore'
- '&cAnother extra lore line'
permission: ''
allow-permission-override: false
1: