mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-07-27 07:51:45 +00:00
Add lore parsing for \n, change version to v6.1
This commit is contained in:
parent
c71bd75b53
commit
a95aaa52d2
7 changed files with 39 additions and 6 deletions
2
pom.xml
2
pom.xml
|
@ -2,7 +2,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.esophose.playerparticles</groupId>
|
<groupId>com.esophose.playerparticles</groupId>
|
||||||
<artifactId>PlayerParticles</artifactId>
|
<artifactId>PlayerParticles</artifactId>
|
||||||
<version>6.0</version>
|
<version>6.1</version>
|
||||||
<name>PlayerParticles</name>
|
<name>PlayerParticles</name>
|
||||||
<url>https://github.com/Esophose/PlayerParticles</url>
|
<url>https://github.com/Esophose/PlayerParticles</url>
|
||||||
<description>Display particles around your player using customized styles and data!</description>
|
<description>Display particles around your player using customized styles and data!</description>
|
||||||
|
|
|
@ -39,6 +39,8 @@ public class DataUpdater {
|
||||||
updateFrom_legacy_to_current();
|
updateFrom_legacy_to_current();
|
||||||
} else if (configVersion == 5.3) {
|
} else if (configVersion == 5.3) {
|
||||||
updateFrom_5_3_to_current();
|
updateFrom_5_3_to_current();
|
||||||
|
} else if (configVersion == 6.0) {
|
||||||
|
PlayerParticles.getPlugin().getLogger().warning("Found nothing to update.");
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerParticles.getPlugin().getLogger().warning("Finished updating SQLite/MySQL data from " + (configVersion < 5.3 ? "a legacy version" : "v" + configVersion) + " to v" + PlayerParticles.getPlugin().getDescription().getVersion());
|
PlayerParticles.getPlugin().getLogger().warning("Finished updating SQLite/MySQL data from " + (configVersion < 5.3 ? "a legacy version" : "v" + configVersion) + " to v" + PlayerParticles.getPlugin().getDescription().getVersion());
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package com.esophose.playerparticles.gui;
|
package com.esophose.playerparticles.gui;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
@ -112,7 +114,7 @@ public class GuiActionButton {
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
|
|
||||||
itemMeta.setDisplayName(this.name);
|
itemMeta.setDisplayName(this.name);
|
||||||
itemMeta.setLore(Arrays.asList(this.lore));
|
itemMeta.setLore(parseLore(this.lore));
|
||||||
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_POTION_EFFECTS);
|
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_POTION_EFFECTS);
|
||||||
|
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
|
@ -147,6 +149,34 @@ public class GuiActionButton {
|
||||||
return this.icons != null ? this.icons.length > 1 : this.colors.length > 1;
|
return this.icons != null ? this.icons.length > 1 : this.colors.length > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds lore from a list of Strings
|
||||||
|
* Parses \n as a new lore line
|
||||||
|
* Ignores empty lore lines
|
||||||
|
*
|
||||||
|
* @param lore The lines of lore
|
||||||
|
* @return A parsed list of lore text
|
||||||
|
*/
|
||||||
|
private List<String> parseLore(String... lore) {
|
||||||
|
List<String> parsedLore = new ArrayList<String>();
|
||||||
|
for (String line : lore) {
|
||||||
|
// Try to maintain the color going to the next line if it's split
|
||||||
|
// If there is no color, just ignore it
|
||||||
|
String lineColor = "";
|
||||||
|
if (line.length() >= 2 && line.charAt(0) == ChatColor.COLOR_CHAR) {
|
||||||
|
lineColor = line.substring(0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split the lore along \n onto a new line if any exist
|
||||||
|
String[] splitLines = line.split("\\\\n");
|
||||||
|
for (String parsedLine : splitLines) {
|
||||||
|
if (ChatColor.stripColor(parsedLine).isEmpty()) continue;
|
||||||
|
parsedLore.add(lineColor + parsedLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parsedLore;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows button click callbacks as parameters
|
* Allows button click callbacks as parameters
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class GuiInventoryDefault extends GuiInventory {
|
||||||
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, callbacks, 1)));
|
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, callbacks, 1)));
|
||||||
callbacks.add(() -> {
|
callbacks.add(() -> {
|
||||||
ParticleGroup group = pplayer.getActiveParticleGroup();
|
ParticleGroup group = pplayer.getActiveParticleGroup();
|
||||||
if (!group.getParticles().isEmpty()) {
|
if (canEditPrimaryStyleAndData) {
|
||||||
for (ParticlePair particle : group.getParticles()) {
|
for (ParticlePair particle : group.getParticles()) {
|
||||||
if (particle.getId() == editingParticle.getId()) {
|
if (particle.getId() == editingParticle.getId()) {
|
||||||
particle.setEffect(editingParticle.getEffect());
|
particle.setEffect(editingParticle.getEffect());
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# This value is the version of the plugin that last modified the config file
|
# This value is the version of the plugin that last modified the config file
|
||||||
# Changing this value manually will likely result in data loss and errors!
|
# 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
|
# Do not change this manually unless specifically told to by the plugin author
|
||||||
version: 6.0
|
version: 6.1
|
||||||
|
|
||||||
# Check for new versions of the plugin
|
# Check for new versions of the plugin
|
||||||
# Default: true
|
# Default: true
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
# Important Notes: #
|
# Important Notes: #
|
||||||
# * You can use the & symbol to color the messages #
|
# * You can use the & symbol to color the messages #
|
||||||
# * {#} Will be replaced with whatever that message requires #
|
# * {#} Will be replaced with whatever that message requires #
|
||||||
|
# * \n Will split the lore line in the #GUI section #
|
||||||
# * Do NOT use the apostrophe character in any message! ( ' ) #
|
# * Do NOT use the apostrophe character in any message! ( ' ) #
|
||||||
# * PLEASE MAKE YOUR OWN .lang FILE IF YOU WANT CUSTOM MESSAGES! #
|
# * PLEASE MAKE YOUR OWN .lang FILE IF YOU WANT CUSTOM MESSAGES! #
|
||||||
# * This file will be overridden almost every plugin update! #
|
# * This file will be overridden almost every plugin update! #
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: PlayerParticles
|
name: PlayerParticles
|
||||||
main: com.esophose.playerparticles.PlayerParticles
|
main: com.esophose.playerparticles.PlayerParticles
|
||||||
version: 6.0
|
version: 6.1
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
description: Display particles around your player using customized styles and data!
|
description: Display particles around your player using customized styles and data!
|
||||||
author: Esophose
|
author: Esophose
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue