mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Add "See only selected" for enchant select setting gui.
Please note that the unselected enchantment not being removed on see only selected mode is a feature as it allow to undo missclick.
This commit is contained in:
parent
0ed0e01f3b
commit
eef8ab9e09
9 changed files with 53 additions and 15 deletions
|
|
@ -9,6 +9,7 @@ import xyz.alexcrea.cuanvil.gui.config.list.SettingGuiListConfigGui;
|
|||
import xyz.alexcrea.cuanvil.gui.config.settings.SettingGui;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
|
@ -35,7 +36,7 @@ public abstract class AbstractEnchantConfigGui<T extends SettingGui.SettingGuiFa
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<WrappedEnchantment> getEveryDisplayableInstanceOfGeneric() {
|
||||
protected Collection<WrappedEnchantment> getEveryDisplayableInstanceOfGeneric() {
|
||||
return GuiSharedConstant.SORTED_ENCHANTMENT_LIST;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe;
|
|||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class CustomRecipeConfigGui extends MappedGuiListConfigGui<AnvilCustomRecipe, CustomRecipeSubSettingGui> {
|
||||
|
|
@ -90,7 +91,7 @@ public class CustomRecipeConfigGui extends MappedGuiListConfigGui<AnvilCustomRec
|
|||
|
||||
|
||||
@Override
|
||||
protected List<AnvilCustomRecipe> getEveryDisplayableInstanceOfGeneric() {
|
||||
protected Collection<AnvilCustomRecipe> getEveryDisplayableInstanceOfGeneric() {
|
||||
return ConfigHolder.CUSTOM_RECIPE_HOLDER.getRecipeManager().getRecipeList();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
|||
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class EnchantConflictGui extends MappedGuiListConfigGui<EnchantConflictGroup, EnchantConflictSubSettingGui> {
|
||||
|
|
@ -83,7 +84,7 @@ public class EnchantConflictGui extends MappedGuiListConfigGui<EnchantConflictGr
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<EnchantConflictGroup> getEveryDisplayableInstanceOfGeneric() {
|
||||
protected Collection<EnchantConflictGroup> getEveryDisplayableInstanceOfGeneric() {
|
||||
return ConfigHolder.CONFLICT_HOLDER.getConflictManager().getConflictList();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class GroupConfigGui extends MappedGuiListConfigGui<IncludeGroup, GroupConfigSubSettingGui> {
|
||||
|
|
@ -49,7 +50,7 @@ public class GroupConfigGui extends MappedGuiListConfigGui<IncludeGroup, GroupCo
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<IncludeGroup> getEveryDisplayableInstanceOfGeneric() {
|
||||
protected Collection<IncludeGroup> getEveryDisplayableInstanceOfGeneric() {
|
||||
ArrayList<IncludeGroup> includeGroups = new ArrayList<>();
|
||||
|
||||
for (AbstractMaterialGroup group : ConfigHolder.ITEM_GROUP_HOLDER.getItemGroupsManager().getGroupMap().values()) {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class UnitRepairConfigGui extends MappedGuiListConfigGui<Material, UnitRepairElementListGui> {
|
||||
|
|
@ -62,7 +63,7 @@ public class UnitRepairConfigGui extends MappedGuiListConfigGui<Material, UnitRe
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Material> getEveryDisplayableInstanceOfGeneric() {
|
||||
protected Collection<Material> getEveryDisplayableInstanceOfGeneric() {
|
||||
ArrayList<Material> materials = new ArrayList<>();
|
||||
|
||||
for (String matName : ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().getKeys(false)) {
|
||||
|
|
|
|||
|
|
@ -20,10 +20,7 @@ import xyz.alexcrea.cuanvil.gui.config.MainConfigGui;
|
|||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class ElementListConfigGui< T > extends ChestGui implements ValueUpdatableGui {
|
||||
|
||||
|
|
@ -296,7 +293,7 @@ public abstract class ElementListConfigGui< T > extends ChestGui implements Valu
|
|||
|
||||
protected abstract void updateGeneric(T generic, ItemStack usedItem);
|
||||
|
||||
protected abstract List<T> getEveryDisplayableInstanceOfGeneric();
|
||||
protected abstract Collection<T> getEveryDisplayableInstanceOfGeneric();
|
||||
|
||||
@Override
|
||||
public void updateGuiValues() {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
|
@ -136,7 +137,7 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getEveryDisplayableInstanceOfGeneric() {
|
||||
protected Collection<String> getEveryDisplayableInstanceOfGeneric() {
|
||||
ArrayList<String> keys = new ArrayList<>();
|
||||
if(!this.shouldWork){
|
||||
return keys;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import xyz.alexcrea.cuanvil.util.CasedStringUtil;
|
|||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class EnchantSelectSettingGui extends SettingGuiListConfigGui<WrappedEnchantment, EnchantSelectSettingGui.DummyFactory> implements SettingGui {
|
||||
|
||||
|
|
@ -31,6 +32,8 @@ public class EnchantSelectSettingGui extends SettingGuiListConfigGui<WrappedEnch
|
|||
private final Set<WrappedEnchantment> selectedEnchant;
|
||||
private final GuiItem saveItem;
|
||||
|
||||
private boolean displayUnselected;
|
||||
|
||||
public EnchantSelectSettingGui(@NotNull String title, ValueUpdatableGui parent, SelectEnchantmentContainer enchantContainer) {
|
||||
super(title);
|
||||
this.enchantContainer = enchantContainer;
|
||||
|
|
@ -40,6 +43,9 @@ public class EnchantSelectSettingGui extends SettingGuiListConfigGui<WrappedEnch
|
|||
this.saveItem = GuiGlobalItems.saveItem(this, parent);
|
||||
this.backgroundPane.bindItem('S', GuiGlobalItems.noChangeItem());
|
||||
|
||||
this.displayUnselected = true;
|
||||
this.backgroundPane.bindItem('b', createDisplayUnusedItem());
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
|
@ -51,15 +57,22 @@ public class EnchantSelectSettingGui extends SettingGuiListConfigGui<WrappedEnch
|
|||
GuiSharedConstant.EMPTY_GUI_FULL_LINE,
|
||||
GuiSharedConstant.EMPTY_GUI_FULL_LINE,
|
||||
GuiSharedConstant.EMPTY_GUI_FULL_LINE,
|
||||
"B11L1R11S"
|
||||
"B11LbR11S"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<WrappedEnchantment> getEveryDisplayableInstanceOfGeneric() {
|
||||
protected Collection<WrappedEnchantment> getEveryDisplayableInstanceOfGeneric() {
|
||||
Stream<WrappedEnchantment> toDisplayStream;
|
||||
if(this.displayUnselected){
|
||||
toDisplayStream = Arrays.stream(WrappedEnchantment.values());
|
||||
}else{
|
||||
toDisplayStream = this.selectedEnchant.stream();
|
||||
}
|
||||
Set<WrappedEnchantment> illegalEnchantments = this.enchantContainer.illegalEnchantments();
|
||||
|
||||
return Arrays.stream(WrappedEnchantment.values())
|
||||
|
||||
return toDisplayStream
|
||||
.filter(enchantment -> !illegalEnchantments.contains(enchantment))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
|
@ -89,6 +102,28 @@ public class EnchantSelectSettingGui extends SettingGuiListConfigGui<WrappedEnch
|
|||
return guiItem;
|
||||
}
|
||||
|
||||
private GuiItem createDisplayUnusedItem() {
|
||||
ItemStack item = new ItemStack(this.displayUnselected ? Material.BOOK : Material.ENCHANTED_BOOK);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
assert meta != null;
|
||||
|
||||
meta.setDisplayName((this.displayUnselected ? "\u00A7aEverything displayed" : "\u00A7eOnly selected displayed"));
|
||||
meta.setLore(Collections.singletonList(
|
||||
"\u00A77Click here to see " +
|
||||
(this.displayUnselected ? "only selected" : "every") +
|
||||
" enchantments"));
|
||||
|
||||
item.setItemMeta(meta);
|
||||
|
||||
return new GuiItem(item, clickEvent -> {
|
||||
clickEvent.setCancelled(true);
|
||||
this.displayUnselected = !this.displayUnselected;
|
||||
|
||||
this.backgroundPane.bindItem('b', createDisplayUnusedItem());
|
||||
reloadValues();
|
||||
}, CustomAnvil.instance);
|
||||
}
|
||||
|
||||
private static final List<String> TRUE_LORE = Collections.singletonList("\u00A77Value: \u00A7aSelected");
|
||||
private static final List<String> FALSE_LORE = Collections.singletonList("\u00A77Value: \u00A7cNot Selected");
|
||||
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui<Materia
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Material> getEveryDisplayableInstanceOfGeneric() {
|
||||
protected Collection<Material> getEveryDisplayableInstanceOfGeneric() {
|
||||
return this.defaultMaterials;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue