mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +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
|
// Unused methods
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -118,8 +118,8 @@ public abstract class ElementListConfigGui< T > extends ChestGui implements Valu
|
||||||
this.pages.clear();
|
this.pages.clear();
|
||||||
this.pages.add(this.firstPage);
|
this.pages.add(this.firstPage);
|
||||||
|
|
||||||
for (T conflict : getEveryDisplayableInstanceOfGeneric()) {
|
for (T generic : getEveryDisplayableInstanceOfGeneric()) {
|
||||||
updateValueForGeneric(conflict, false);
|
updateValueForGeneric(generic, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue