Added require-target option to display

This commit is contained in:
Auxilor 2021-03-09 19:12:49 +00:00
parent cba6784eea
commit 25f9f4e030
2 changed files with 16 additions and 4 deletions

View File

@ -78,8 +78,10 @@ public class EnchantDisplay extends DisplayModule {
@Override
protected void display(@NotNull final ItemStack itemStack,
@NotNull final Object... args) {
if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) {
return;
if (options.isRequireTarget()) {
if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) {
return;
}
}
ItemMeta meta = itemStack.getItemMeta();
@ -198,8 +200,10 @@ public class EnchantDisplay extends DisplayModule {
@Override
protected void revert(@NotNull final ItemStack itemStack) {
if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) {
return;
if (options.isRequireTarget()) {
if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) {
return;
}
}
ItemMeta meta = itemStack.getItemMeta();

View File

@ -85,6 +85,12 @@ public class DisplayOptions extends PluginDependent {
@Getter
private boolean usingForceHideFixer = false;
/**
* If item must be a target.
*/
@Getter
private boolean requireTarget = true;
/**
* Instantiate new display options.
*
@ -124,6 +130,8 @@ public class DisplayOptions extends PluginDependent {
usingAggressiveExperimentalHideFixer = this.getPlugin().getConfigYml().getBool("advanced.hide-fixer.aggressive");
usingForceHideFixer = this.getPlugin().getConfigYml().getBool("advanced.hide-fixer.force");
requireTarget = this.getPlugin().getConfigYml().getBool("lore.require-target");
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");