Merge pull request #57

Fixed a NPE and added a simple rarity placeholder
This commit is contained in:
Will FP 2021-09-03 11:08:54 +01:00 committed by GitHub
commit 828557e5e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import com.willfp.eco.util.StringUtils;
import com.willfp.ecoenchants.display.EnchantmentCache; import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity;
import org.apache.commons.lang.WordUtils; import org.apache.commons.lang.WordUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -139,12 +140,14 @@ public class CommandEnchantinfo extends PluginCommand {
final String finalName = EnchantmentCache.getEntry(enchantment).getName(); final String finalName = EnchantmentCache.getEntry(enchantment).getName();
final String finalDescription = EnchantmentCache.getEntry(enchantment).getStringDescription(1); final String finalDescription = EnchantmentCache.getEntry(enchantment).getStringDescription(1);
final EnchantmentRarity finalRarity = enchantment.getRarity();
final String finalTargets = allTargets; final String finalTargets = allTargets;
final String finalConflicts = allConflicts; final String finalConflicts = allConflicts;
final String finalMaxLevel = maxLevel; final String finalMaxLevel = maxLevel;
Arrays.asList(this.getPlugin().getLangYml().getMessage("enchantinfo").split("\\r?\\n")).forEach((string -> { Arrays.asList(this.getPlugin().getLangYml().getMessage("enchantinfo").split("\\r?\\n")).forEach((string -> {
string = string.replace("%name%", finalName) string = string.replace("%name%", finalName)
.replace("%description%", finalDescription) .replace("%description%", finalDescription)
.replace("%rarity%", finalRarity.getName())
.replace("%target%", finalTargets) .replace("%target%", finalTargets)
.replace("%conflicts%", finalConflicts) .replace("%conflicts%", finalConflicts)
.replace("%maxlevel%", finalMaxLevel); .replace("%maxlevel%", finalMaxLevel);

View File

@ -13,6 +13,7 @@ messages:
not-found: "&cCannot find an enchantment matching name: &f%name%." not-found: "&cCannot find an enchantment matching name: &f%name%."
enchantinfo: | enchantinfo: |
%name%: &r%description% %name%: &r%description%
&9Rarity: &r%rarity%
&9Max Level: &r%maxlevel% &9Max Level: &r%maxlevel%
&9Can be applied to: &r%target% &9Can be applied to: &r%target%
&9Conflicts with: &r%conflicts% &9Conflicts with: &r%conflicts%

View File

@ -26,7 +26,7 @@ general-config:
list: [] list: []
not-met-lore: [] not-met-lore: []
conflicts: conflicts:
- altitide - altitude
- aquamarine - aquamarine
- dehydration - dehydration
- rainforest - rainforest