From 969d2066dedde5027ea8fe73f24681fd32fdcc90 Mon Sep 17 00:00:00 2001 From: lbenav8095 Date: Mon, 28 Nov 2022 18:59:20 -0600 Subject: [PATCH] 1.5.70 BlobEditor#loadPage overriden --- .../mytheria/bloblib/entities/BlobEditor.java | 28 ++++++++++++++++--- .../entities/inventory/VariableSelector.java | 8 ++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/main/java/us/mytheria/bloblib/entities/BlobEditor.java b/src/main/java/us/mytheria/bloblib/entities/BlobEditor.java index e68695f5..1f7fcc07 100644 --- a/src/main/java/us/mytheria/bloblib/entities/BlobEditor.java +++ b/src/main/java/us/mytheria/bloblib/entities/BlobEditor.java @@ -23,18 +23,38 @@ public class BlobEditor extends VariableSelector implements VariableEditor private final SelectorListenerManager selectorManager; public static BlobEditor build(BlobInventory blobInventory, UUID builderId, - String dataType, VariableFiller filler) { + String dataType) { return new BlobEditor<>(blobInventory, builderId, - dataType, null); + dataType); } private BlobEditor(BlobInventory blobInventory, UUID builderId, - String dataType, VariableFiller filler) { - super(blobInventory, builderId, dataType, filler); + String dataType) { + super(blobInventory, builderId, dataType, null); list = new ArrayList<>(); selectorManager = BlobLib.getInstance().getSelectorManager(); } + @Override + public void loadInConstructor() { + } + + @Override + public void loadPage(int page, boolean refill) { + if (page < 1) + return; + if (getTotalPages() < page) { + return; + } + if (refill) + refillButton("White-Background"); + clearValues(); + List> values = page(page, getItemsPerPage()); + for (int i = 0; i < values.size(); i++) { + setValue(i, values.get(i)); + } + } + @Override public List> page(int page, int itemsPerPage) { int start = (page - 1) * itemsPerPage; diff --git a/src/main/java/us/mytheria/bloblib/entities/inventory/VariableSelector.java b/src/main/java/us/mytheria/bloblib/entities/inventory/VariableSelector.java index 94bd32e8..caeb9ec0 100644 --- a/src/main/java/us/mytheria/bloblib/entities/inventory/VariableSelector.java +++ b/src/main/java/us/mytheria/bloblib/entities/inventory/VariableSelector.java @@ -79,6 +79,10 @@ public void setValue(int slot, VariableValue value) { setButton(slot, value.itemStack()); } + public void clearValues() { + values.clear(); + } + public T getValue(int slot) { return values.get(slot); } @@ -124,6 +128,10 @@ public int valuesSize() { return getValues().size(); } + public int getItemsPerPage() { + return itemsPerPage; + } + public void setPage(int page) { if (page < 1) return;