1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00
This commit is contained in:
TheBusyBiscuit 2020-07-02 11:50:07 +02:00
parent 527ffdd742
commit 548e3586ae
3 changed files with 7 additions and 4 deletions

View File

@ -72,6 +72,7 @@
* Fixed Grappling hooks making Bat sounds
* Fixed #1959
* Fixed Melon Juice requiring Melons instead of Melon Slices
* Fixed #2066
## Release Candidate 13 (16 Jun 2020)
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#13

View File

@ -4,6 +4,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.meta.ItemMeta;
@ -26,7 +27,8 @@ import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
final class RechargeableHelper {
private static final NamespacedKey CHARGE_KEY = new NamespacedKey(SlimefunPlugin.instance, "item_charge");
private static final String LORE_PREFIX = ChatColors.color("&c&o&8\u21E8 &e\u26A1 &7");
private static final String LORE_PREFIX = ChatColors.color("&8\u21E8 &e\u26A1 &7");
private static final Pattern REGEX = Pattern.compile(ChatColors.color("(&c&o)?" + LORE_PREFIX) + "[0-9\\.]+ \\/ [0-9\\.]+ J");
private RechargeableHelper() {}
@ -42,7 +44,7 @@ final class RechargeableHelper {
for (int i = 0; i < lore.size(); i++) {
String line = lore.get(i);
if (line.startsWith(LORE_PREFIX)) {
if (REGEX.matcher(line).matches()) {
lore.set(i, LORE_PREFIX + value + " / " + capacity + " J");
meta.setLore(lore);
return;
@ -66,7 +68,7 @@ final class RechargeableHelper {
// If no persistent data exists, we will just fall back to the lore
if (meta.hasLore()) {
for (String line : meta.getLore()) {
if (line.startsWith(LORE_PREFIX) && line.contains(" / ") && line.endsWith(" J")) {
if (REGEX.matcher(line).matches()) {
return Float.parseFloat(PatternUtils.SLASH_SEPARATOR.split(line)[0].replace(LORE_PREFIX, ""));
}
}

View File

@ -39,7 +39,7 @@ public final class LoreBuilder {
}
public static String powerCharged(int charge, int capacity) {
return "&c&o&8\u21E8 &e\u26A1 &7" + charge + " / " + capacity + " J";
return "&8\u21E8 &e\u26A1 &7" + charge + " / " + capacity + " J";
}
public static String material(String material) {