Skip to content

Commit

Permalink
filler is null was not supposed to be an issue due to filler not bein…
Browse files Browse the repository at this point in the history
…g meant to be required.
  • Loading branch information
anjoismysign committed Dec 9, 2022
1 parent 909eabd commit 31687d9
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/main/java/us/mytheria/bloblib/entities/BlobEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,19 @@ public void loadPage(int page, boolean refill) {
}

public void loadCustomPage(int page, boolean refill, Function<T, ItemStack> function) {
super.loadCustomPage(page, refill, list, function);
if (page < 1) {
return;
}
if (getTotalPages() < page) {
return;
}
if (refill)
refillButton("White-Background");
clearValues();
List<VariableValue<T>> values = this.customPage(page, getItemsPerPage(), function);
for (int i = 0; i < values.size(); i++) {
setValue(i, values.get(i));
}
}

@Override
Expand All @@ -88,6 +100,22 @@ public List<VariableValue<T>> page(int page, int itemsPerPage) {
return values;
}

public List<VariableValue<T>> customPage(int page, int itemsPerPage, Function<T, ItemStack> function) {
int start = (page - 1) * itemsPerPage;
int end = start + (itemsPerPage);
ArrayList<VariableValue<T>> values = new ArrayList<>();
for (int i = start; i < end; i++) {
T get;
try {
get = getList().get(i);
values.add(new VariableValue<>(function.apply(get), get));
} catch (IndexOutOfBoundsException e) {
break;
}
}
return values;
}

public void remove(T t) {
list.remove(t);
}
Expand Down

0 comments on commit 31687d9

Please sign in to comment.