mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +02:00
Sort new enchantment in gui on add.
This commit is contained in:
parent
b70887c5ca
commit
a6c2d5f148
2 changed files with 42 additions and 2 deletions
|
|
@ -53,6 +53,46 @@ public abstract class AbstractEnchantConfigGui<T extends SettingGui.SettingGuiFa
|
|||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateValueForGeneric(CAEnchantment generic, boolean shouldUpdate) {
|
||||
updateValueForGeneric(generic, shouldUpdate, true);
|
||||
}
|
||||
|
||||
public void updateValueForGeneric(CAEnchantment generic, boolean shouldUpdate, boolean prepareSorting) {
|
||||
if(!prepareSorting) {
|
||||
super.updateValueForGeneric(generic, shouldUpdate);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!this.factoryMap.containsKey(generic)){
|
||||
// We need to sort elements again
|
||||
super.updateValueForGeneric(generic, false);
|
||||
|
||||
// Clear page then refill all of them
|
||||
this.firstPage.clear();
|
||||
this.pages.clear();
|
||||
this.pages.add(this.firstPage);
|
||||
|
||||
for (CAEnchantment enchantment : getEveryDisplayableInstanceOfGeneric()) {
|
||||
GuiItem item = this.guiItemMap.get(enchantment);
|
||||
|
||||
if(item == null) {
|
||||
updateValueForGeneric(enchantment, false, false);
|
||||
}else {
|
||||
addToPage(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(shouldUpdate) update();
|
||||
|
||||
}else{
|
||||
super.updateValueForGeneric(generic, shouldUpdate);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Unused methods
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -118,8 +118,8 @@ public abstract class ElementListConfigGui< T > extends ChestGui implements Valu
|
|||
this.pages.clear();
|
||||
this.pages.add(this.firstPage);
|
||||
|
||||
for (T conflict : getEveryDisplayableInstanceOfGeneric()) {
|
||||
updateValueForGeneric(conflict, false);
|
||||
for (T generic : getEveryDisplayableInstanceOfGeneric()) {
|
||||
updateValueForGeneric(generic, false);
|
||||
}
|
||||
|
||||
update();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue