Change MultiPageManager to use BiConsumer/BiPredicate
This commit is contained in:
parent
5e5762d6e7
commit
ed37174e94
@ -1,8 +1,8 @@
|
||||
package mineplex.core.shop.page;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.bukkit.Material;
|
||||
@ -16,21 +16,21 @@ public class MultiPageManager<ItemType>
|
||||
private int ELEMENTS_PER_PAGE = 28;
|
||||
private int _page;
|
||||
|
||||
private Predicate<Pair<ItemType, Integer>> _addItem;
|
||||
private BiPredicate<ItemType, Integer> _addItem;
|
||||
private Supplier<List<ItemType>> _getItems;
|
||||
private ShopPageBase _shopPage;
|
||||
|
||||
public MultiPageManager(ShopPageBase shopPage, Supplier<List<ItemType>> getItems, Predicate<Pair<ItemType, Integer>> addItem)
|
||||
public MultiPageManager(ShopPageBase shopPage, Supplier<List<ItemType>> getItems, BiPredicate<ItemType, Integer> addItem)
|
||||
{
|
||||
_shopPage = shopPage;
|
||||
_getItems = getItems;
|
||||
_addItem = addItem;
|
||||
}
|
||||
|
||||
public MultiPageManager(ShopPageBase shopPage, Supplier<List<ItemType>> getItems, Consumer<Pair<ItemType, Integer>> addItem)
|
||||
public MultiPageManager(ShopPageBase shopPage, Supplier<List<ItemType>> getItems, BiConsumer<ItemType, Integer> addItem)
|
||||
{
|
||||
this(shopPage, getItems, (Pair<ItemType, Integer> pair)-> {
|
||||
addItem.accept(pair);
|
||||
this(shopPage, getItems, (item, slot)-> {
|
||||
addItem.accept(item, slot);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@ -54,7 +54,7 @@ public class MultiPageManager<ItemType>
|
||||
|
||||
for (ItemType item : _getItems.get())
|
||||
{
|
||||
if (!_addItem.test(Pair.create(item, slot)))
|
||||
if (!_addItem.test(item, slot))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user