Removed debug messages

This commit is contained in:
Auxilor 2021-08-28 21:40:52 +01:00
parent 8bf70bb0fc
commit 385e186066
2 changed files with 43 additions and 25 deletions

View File

@ -12,7 +12,6 @@ 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.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
@ -141,8 +140,6 @@ public class EnchantDisplay extends DisplayModule {
requirementLore.addAll(StringUtils.formatList(EnchantmentCache.getEntry(enchantment).getRequirementLore(), player));
}
}
Bukkit.getLogger().info((player == null) + " name: " + name + " requirementLore " + requirementLore);
});
if (options.getShrinkOptions().isEnabled() && (enchantments.size() > options.getShrinkOptions().getThreshold())) {

View File

@ -92,10 +92,10 @@ public class EnchantmentCache {
CACHE.put(enchantment.getKey(), new CacheEntry(
enchantment,
"&4INVALID ENCHANTMENT",
"INVALID",
new HashMap<>(Map.of(1, Collections.singletonList(Display.PREFIX + "INVALID ENCHANTMENT: " + enchantment.getClass().getName()))),
EnchantmentType.NORMAL,
EnchantmentRarity.getByName(PLUGIN.getConfigYml().getString("rarity.vanilla-rarity"))
EnchantmentRarity.getByName(PLUGIN.getConfigYml().getString("rarity.vanilla-rarity")),
"&7"
));
return;
}
@ -138,15 +138,6 @@ public class EnchantmentCache {
color = rarity.getCustomColor();
}
String rawName = name;
if (color.contains("{}")) {
name = color.replace("{}", name);
} else {
name = color + name;
}
name = StringUtils.format(name);
description.replaceAll(line -> line.replace("§r", "§r" + PLUGIN.getDisplayModule().getOptions().getDescriptionOptions().getColor()));
description.replaceAll(line -> Display.PREFIX + PLUGIN.getDisplayModule().getOptions().getDescriptionOptions().getColor() + line);
@ -169,7 +160,7 @@ public class EnchantmentCache {
levelDescription.put(i, description);
}
}
CACHE.put(enchantment.getKey(), new CacheEntry(enchantment, name, rawName, levelDescription, type, rarity));
CACHE.put(enchantment.getKey(), new CacheEntry(enchantment, name, levelDescription, type, rarity, color));
}
@ToString
@ -181,16 +172,15 @@ public class EnchantmentCache {
private final Enchantment enchantment;
/**
* The formatted name of the enchantment.
* The name of the enchantment.
*/
@Getter
private final String name;
/**
* The raw (unformatted) name of the enchantment.
* The default color of the enchantment.
*/
@Getter
private final String rawName;
private final String color;
/**
* The description, line-wrapped.
@ -222,16 +212,16 @@ public class EnchantmentCache {
private CacheEntry(@NotNull final Enchantment enchantment,
@NotNull final String name,
@NotNull final String rawName,
@NotNull final Map<Integer, List<String>> description,
@NotNull final EnchantmentType type,
@NotNull final EnchantmentRarity rarity) {
@NotNull final EnchantmentRarity rarity,
@NotNull final String color) {
this.enchantment = enchantment;
this.name = name;
this.rawName = rawName;
this.description = description;
this.type = type;
this.rarity = rarity;
this.color = color;
this.stringDescription = new HashMap<>();
this.requirementLore = new ArrayList<>();
if (enchantment instanceof EcoEnchant ecoEnchant) {
@ -257,7 +247,7 @@ public class EnchantmentCache {
/**
* Get the name with the level.
*
* @param level The level.
* @param level The level.
* @return The name with the level.
*/
public String getNameWithLevel(final int level) {
@ -267,14 +257,14 @@ public class EnchantmentCache {
/**
* Get enchantment with level.
*
* @param level The level.
* @param level The level.
* @param player The player.
* @return The name with the level.
*/
public String getNameWithLevel(final int level,
@Nullable final Player player) {
String unformattedName = rawName;
String formattedName = name;
String unformattedName = name;
if (enchantment instanceof EcoEnchant enchant && player != null) {
if (!enchant.doesPlayerMeetRequirements(player)) {
String color = PLUGIN.getDisplayModule().getOptions().getRequirementsOptions().getRequirementColor();
@ -287,6 +277,12 @@ public class EnchantmentCache {
}
}
}
if (color.contains("{}")) {
formattedName = color.replace("{}", formattedName);
} else {
formattedName = color + formattedName;
}
formattedName = StringUtils.format(formattedName);
if (!(enchantment.getMaxLevel() == 1 && level == 1)) {
String numberString = " ";
@ -404,5 +400,30 @@ public class EnchantmentCache {
public String getStringDescription() {
return getStringDescription(1);
}
/**
* Get the unformatted name of the enchantment.
*
* @return The raw name.
*/
public String getRawName() {
return name;
}
/**
* Get the formatted name of the enchantment.
*
* @return The name.
*/
public String getName() {
String formattedName = name;
if (color.contains("{}")) {
formattedName = color.replace("{}", formattedName);
} else {
formattedName = color + formattedName;
}
return StringUtils.format(formattedName);
}
}
}