mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-01-15 23:31:20 +01:00
Added option to show target groups in /enchantinfo
This commit is contained in:
parent
ec61350b94
commit
b8ad3d2193
@ -84,6 +84,15 @@ public final class CommandEnchantinfo extends AbstractCommand {
|
|||||||
|
|
||||||
Set<String> applicableItemsSet = new HashSet<>();
|
Set<String> applicableItemsSet = new HashSet<>();
|
||||||
|
|
||||||
|
if(ConfigManager.getConfig().getBool("commands.enchantinfo.show-target-group")) {
|
||||||
|
enchantment.getRawTarget().forEach(target -> {
|
||||||
|
String targetName = target.getName();
|
||||||
|
targetName = targetName.toLowerCase();
|
||||||
|
targetName = targetName.replaceAll("_", " ");
|
||||||
|
targetName = WordUtils.capitalize(targetName);
|
||||||
|
applicableItemsSet.add(targetName);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
targets.forEach(material -> {
|
targets.forEach(material -> {
|
||||||
String matName = material.toString();
|
String matName = material.toString();
|
||||||
matName = matName.toLowerCase();
|
matName = matName.toLowerCase();
|
||||||
@ -91,6 +100,7 @@ public final class CommandEnchantinfo extends AbstractCommand {
|
|||||||
matName = WordUtils.capitalize(matName);
|
matName = WordUtils.capitalize(matName);
|
||||||
applicableItemsSet.add(matName);
|
applicableItemsSet.add(matName);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder targetNamesBuilder = new StringBuilder();
|
StringBuilder targetNamesBuilder = new StringBuilder();
|
||||||
applicableItemsSet.forEach((name1) -> {
|
applicableItemsSet.forEach((name1) -> {
|
||||||
|
@ -17,12 +17,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -41,7 +36,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
|
|||||||
private int maxLvl;
|
private int maxLvl;
|
||||||
private Set<Enchantment> conflicts;
|
private Set<Enchantment> conflicts;
|
||||||
private EnchantmentRarity rarity;
|
private EnchantmentRarity rarity;
|
||||||
private final Set<Material> target = new HashSet<>();
|
private Set<com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget> target = new HashSet<>();
|
||||||
|
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
@ -89,7 +84,7 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
|
|||||||
name = ChatColor.translateAlternateColorCodes('&', config.getString("name"));
|
name = ChatColor.translateAlternateColorCodes('&', config.getString("name"));
|
||||||
description = ChatColor.translateAlternateColorCodes('&', config.getString("description"));
|
description = ChatColor.translateAlternateColorCodes('&', config.getString("description"));
|
||||||
target.clear();
|
target.clear();
|
||||||
config.getTargets().forEach(enchantmentTarget -> target.addAll(enchantmentTarget.getMaterials()));
|
target.addAll(config.getTargets());
|
||||||
enabled = config.getBool("enabled", true);
|
enabled = config.getBool("enabled", true);
|
||||||
|
|
||||||
this.register();
|
this.register();
|
||||||
@ -235,6 +230,18 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
|
|||||||
* @return Set of enchantable items
|
* @return Set of enchantable items
|
||||||
*/
|
*/
|
||||||
public Set<Material> getTarget() {
|
public Set<Material> getTarget() {
|
||||||
|
Set<Material> materials = new HashSet<>();
|
||||||
|
target.forEach(target -> {
|
||||||
|
materials.addAll(target.getMaterials());
|
||||||
|
});
|
||||||
|
return materials;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get raw target of enchantment
|
||||||
|
* @return {@link com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget}
|
||||||
|
*/
|
||||||
|
public Set<com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget> getRawTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
# by Auxilor
|
# by Auxilor
|
||||||
#
|
#
|
||||||
|
|
||||||
|
commands:
|
||||||
|
enchantinfo:
|
||||||
|
show-target-group: true # Show name of target group rather than individual items
|
||||||
|
|
||||||
anvil:
|
anvil:
|
||||||
allow-unsafe-levels: false # Allow unsafe enchantments like Sharpness 6 by combining 2 Sharp 5.
|
allow-unsafe-levels: false # Allow unsafe enchantments like Sharpness 6 by combining 2 Sharp 5.
|
||||||
allow-combining-unsafe: true # Allow further combining unsafe levels, eg Sharp 6 + Sharp 6 = Sharp 7.
|
allow-combining-unsafe: true # Allow further combining unsafe levels, eg Sharp 6 + Sharp 6 = Sharp 7.
|
||||||
|
Loading…
Reference in New Issue
Block a user