use of com.almuradev.almura.feature.store.SideType in project Almura by AlmuraDev.
the class StoreScreen method drawScreen.
@Override
public void drawScreen(final int mouseX, final int mouseY, final float partialTick) {
// Update colors
this.updateTabs(this.buyTabContainer, this.buyTabLabel);
this.updateTabs(this.sellTabContainer, this.sellTabLabel);
// Hover logic
this.getTabContainer(mouseX, mouseY).ifPresent(tab -> {
final SideType tabType = (SideType) tab.getData();
if (tabType == SideType.BUY && this.store.getBuyingItems().size() == 0) {
return;
}
if (tabType == SideType.SELL && this.store.getSellingItems().size() == 0) {
return;
}
if (this.currentSide != tabType) {
tab.setColor(hoveredTabColor);
}
});
super.drawScreen(mouseX, mouseY, partialTick);
}
use of com.almuradev.almura.feature.store.SideType in project Almura by AlmuraDev.
the class ClientStoreManager method filterLocalItems.
@SuppressWarnings("unchecked")
public <T extends StoreItem> List<T> filterLocalItems(final String id, @Nullable final String filter, @Nullable final String sort, final SideType targetSide) {
checkNotNull(id);
checkNotNull(targetSide);
final Store axs = this.getStore(id);
checkNotNull(axs);
Stream<T> stream = targetSide == SideType.BUY ? (Stream<T>) axs.getBuyingItems().stream() : (Stream<T>) axs.getSellingItems().stream();
if (filter != null) {
final List<FilterRegistry.FilterElement<StoreItem>> elements = FilterRegistry.instance.getFilterElements(filter);
stream = stream.filter(storeItem -> elements.stream().allMatch(element -> element.getFilter().test(storeItem, element.getValue())));
}
if (sort != null) {
final List<FilterRegistry.SorterElement<StoreItem>> elements = FilterRegistry.instance.getSortingElements(sort);
final Comparator<StoreItem> comparator = FilterRegistry.instance.buildSortingComparator(elements).orElse(null);
if (comparator != null) {
stream = stream.sorted(comparator);
}
}
return stream.collect(Collectors.toList());
}
use of com.almuradev.almura.feature.store.SideType in project Almura by AlmuraDev.
the class StoreScreen method mouseClicked.
@Override
protected void mouseClicked(final int x, final int y, final int button) {
this.getTabContainer(x, y).ifPresent(tab -> {
final SideType targetSide = (SideType) tab.getData();
;
if (targetSide == SideType.BUY && this.store.getBuyingItems().size() == 0) {
return;
}
if (targetSide == SideType.SELL && this.store.getSellingItems().size() == 0) {
return;
}
this.currentSide = targetSide;
this.refresh(false);
});
super.mouseClicked(x, y, button);
}
Aggregations