Change MultiPageManager to use BiConsumer/BiPredicate

This commit is contained in:
Spencer 2018-01-05 20:39:39 -05:00 committed by Alexander Meech
parent 5e5762d6e7
commit ed37174e94

View File

@ -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;
}