Create lore prefix and suffix for enchanted items

(except books because it looks ugly on them and makes no sense)
This commit is contained in:
NicoNekoDev 2022-01-15 19:24:08 +02:00
parent 35629b28b5
commit 51ee56e548
3 changed files with 29 additions and 5 deletions

View File

@ -12,6 +12,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
import com.willfp.ecoenchants.enchantments.util.ItemConversionOptions;
import lombok.Getter;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
@ -177,6 +178,13 @@ public class EnchantDisplay extends DisplayModule {
}
}
if (itemStack.getType() != Material.ENCHANTED_BOOK) {
if (!enchantments.isEmpty()) {
lore.addAll(0, options.getLorePrefix());
lore.addAll(options.getLoreSuffix());
}
}
if (this.getOptions().isAboveLore()) {
lore.addAll(itemLore);
} else {

View File

@ -2,6 +2,8 @@ package com.willfp.ecoenchants.display.options;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.PluginDependent;
import com.willfp.eco.core.display.Display;
import com.willfp.eco.util.StringUtils;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
import com.willfp.ecoenchants.display.options.sorting.SortParameters;
import com.willfp.ecoenchants.display.options.sorting.SorterManager;
@ -11,11 +13,7 @@ import lombok.Getter;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
public class DisplayOptions extends PluginDependent<EcoPlugin> {
@ -72,6 +70,17 @@ public class DisplayOptions extends PluginDependent<EcoPlugin> {
@Getter
private boolean aboveLore = true;
/**
* Lore prefix (above enchantments)
*/
@Getter
private List<String> lorePrefix;
/**
* Lore suffix (below enchantments)
*/
@Getter
private List<String> loreSuffix;
/**
* Instantiate new display options.
*
@ -110,6 +119,9 @@ public class DisplayOptions extends PluginDependent<EcoPlugin> {
requireTarget = this.getPlugin().getConfigYml().getBool("lore.require-target");
aboveLore = this.getPlugin().getConfigYml().getBool("lore.above-other-lore");
lorePrefix = this.getPlugin().getConfigYml().getStrings("lore.prefix").stream().map(s -> Display.PREFIX + StringUtils.format(s, StringUtils.FormatOption.WITHOUT_PLACEHOLDERS)).collect(Collectors.toList());
loreSuffix = this.getPlugin().getConfigYml().getStrings("lore.suffix").stream().map(s -> Display.PREFIX + StringUtils.format(s, StringUtils.FormatOption.WITHOUT_PLACEHOLDERS)).collect(Collectors.toList());
boolean byType = this.getPlugin().getConfigYml().getBool("lore.sort-by-type");
boolean byLength = this.getPlugin().getConfigYml().getBool("lore.sort-by-length");
boolean byRarity = this.getPlugin().getConfigYml().getBool("lore.sort-by-rarity");

View File

@ -72,6 +72,10 @@ lore:
after-lines: 9 # Collapse after number of enchantments
maximum-per-line: 2 # Maximum number of enchantments to have in 1 line
prefix: # Lines used above the enchantments
- ""
suffix: [] # Lines used below the enchantments
enchanting-table:
enabled: true # Enable EcoEnchants through an enchanting table
book-times-less-likely: 2 # Times less likely to get an EcoEnchant on a book to balance them out. Don't recommend editing.