Skip to content

Commit

Permalink
Merge pull request #310 from refinedmods/release/2.0.0-milestone.2.7
Browse files Browse the repository at this point in the history
Release v2.0.0-milestone.2.7
  • Loading branch information
raoulvdberge authored Jan 31, 2023
2 parents b3b0c0f + fe840b4 commit 4ac2616
Show file tree
Hide file tree
Showing 376 changed files with 5,289 additions and 7,771 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ body:
description: |
If your Minecraft version isn't listed here, it means that it's no longer supported. In that case, don't create an issue.
options:
- Minecraft 1.19.2
- Minecraft 1.19.3
validations:
required: true
- type: input
Expand Down
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.0.0-milestone.2.7] - 2023-01-31

### Added

- Added a "Storage channel" filter in the Grid that determines which resource type is shown. Defaults to "All".

### Changed

- Ported to Minecraft 1.19.3.
- The regular Grid now shows fluids as well.
- You can insert fluids in the Grid by right-clicking a fluid container in the Grid slots.
- You no longer have to explicitly select a resource type for the filter configuration slots. You can set a fluid
by right-clicking a fluid container in the filter slots.
- You can no longer insert fluids into the Grid or filter slots straight from the player inventory slots, you have to
insert the fluid while holding the fluid container.

### Removed

- Removed the Fluid Grid, which has been combined into the regular Grid.

## [2.0.0-milestone.2.6] - 2023-01-13

### Fixed
Expand Down Expand Up @@ -274,7 +294,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- The Grid can now use smooth scrolling.
- The Grid now has syntax highlighting for the search query.

[Unreleased]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.2.6...HEAD
[Unreleased]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.2.7...HEAD

[2.0.0-milestone.2.7]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.2.6...v2.0.0-milestone.2.7

[2.0.0-milestone.2.6]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.2.5...v2.0.0-milestone.2.6

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ subprojects {
])) {
apply plugin: 'info.solidsoft.pitest'
pitest {
junit5PluginVersion = '1.0.0'
pitestVersion = '1.9.0'
junit5PluginVersion = libs.versions.pitestJUnit5Plugin
pitestVersion = libs.versions.pitest
outputFormats.set(['HTML'])
mutationThreshold.set(90)
coverageThreshold.set(80)
Expand Down
2 changes: 2 additions & 0 deletions config/checkstyle/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
<suppress checks="JavadocPackage" files="test[\\/].*.java"/>
<!-- Mod initializer can be longer due to initialization logic -->
<suppress checks="FileLength" files="ModInitializer.*.java"/>
<!-- Shadow target contains underscore -->
<suppress checks="MemberName" files="ModelBakerImplMixin.java"/>
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;

import org.apiguardian.api.API;

Expand Down Expand Up @@ -61,8 +62,19 @@ default T getOrElseDefault(I id) {
* Returns the next value in the ordered list.
* If the value is not found, it will return the default value.
*
* @param value the value
* @param value the given value
* @return the next value after the given value
*/
T next(T value);

/**
* Returns the next value in the ordered list.
* If the value is not found, it will the default value.
* If the value is the last value in the ordered list, it will return null.
*
* @param value the given value
* @return the next value after the given value, or null if it's the last value
*/
@Nullable
T nextOrNullIfLast(T value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;

import org.apiguardian.api.API;

Expand Down Expand Up @@ -66,11 +67,21 @@ public List<T> getAll() {

@Override
public T next(final T value) {
final T nextValue = nextOrNullIfLast(value);
if (nextValue == null) {
return order.get(0);
}
return nextValue;
}

@Nullable
@Override
public T nextOrNullIfLast(final T value) {
CoreValidations.validateNotNull(value, VALUE_NOT_PRESENT_ERROR);
final int index = order.indexOf(value);
final int nextIndex = index + 1;
if (nextIndex >= order.size()) {
return order.get(0);
return null;
}
return order.get(nextIndex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ void testDefaults() {
assertThat(sut.getId(10)).get().isEqualTo("A");
assertThat(sut.getId(20)).isEmpty();
assertThat(sut.next(10)).isEqualTo(10);
assertThat(sut.nextOrNullIfLast(10)).isNull();
assertThat(sut.next(20)).isEqualTo(10);
assertThat(sut.nextOrNullIfLast(20)).isEqualTo(10);
assertThat(sut.isEmpty()).isTrue();
}

Expand All @@ -53,7 +55,9 @@ void shouldRegisterAndRetrieve() {
assertThat(sut.getId(10)).get().isEqualTo("A");
assertThat(sut.getId(20)).get().isEqualTo("B");
assertThat(sut.next(10)).isEqualTo(20);
assertThat(sut.nextOrNullIfLast(10)).isEqualTo(20);
assertThat(sut.next(20)).isEqualTo(10);
assertThat(sut.nextOrNullIfLast(20)).isNull();
assertThat(sut.isEmpty()).isFalse();
}

Expand Down Expand Up @@ -99,6 +103,7 @@ void testInvalidDefaults() {
@SuppressWarnings("ConstantConditions")
void testInvalidNextValues() {
assertThrows(NullPointerException.class, () -> sut.next(null));
assertThrows(NullPointerException.class, () -> sut.nextOrNullIfLast(null));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.refinedmods.refinedstorage2.api.grid;

import com.refinedmods.refinedstorage2.api.resource.list.ResourceListOperationResult;
import com.refinedmods.refinedstorage2.api.storage.channel.StorageChannelType;
import com.refinedmods.refinedstorage2.api.storage.tracked.TrackedResource;

import javax.annotation.Nullable;
Expand All @@ -11,7 +12,7 @@
* A grid listener.
*/
@API(status = API.Status.STABLE, since = "2.0.0-milestone.1.0")
public interface GridWatcher<T> {
public interface GridWatcher {
/**
* Called when the activeness state of the grid has changed.
*
Expand All @@ -22,8 +23,12 @@ public interface GridWatcher<T> {
/**
* Called when a resource is changed.
*
* @param change the change
* @param trackedResource the tracked resource, if present
* @param <T> the resource type
* @param storageChannelType the relevant storage channel type
* @param change the change
* @param trackedResource the tracked resource, if present
*/
void onChanged(ResourceListOperationResult<T> change, @Nullable TrackedResource trackedResource);
<T> void onChanged(StorageChannelType<T> storageChannelType,
ResourceListOperationResult<T> change,
@Nullable TrackedResource trackedResource);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.refinedmods.refinedstorage2.api.grid.query;

import com.refinedmods.refinedstorage2.api.grid.view.AbstractGridResource;
import com.refinedmods.refinedstorage2.api.grid.view.GridResource;

import java.util.function.Predicate;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.1.0")
public interface GridQueryParser<T> {
Predicate<AbstractGridResource<T>> parse(String query) throws GridQueryParserException;
public interface GridQueryParser {
Predicate<GridResource> parse(String query) throws GridQueryParserException;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.refinedmods.refinedstorage2.api.grid.query;

import com.refinedmods.refinedstorage2.api.grid.view.AbstractGridResource;
import com.refinedmods.refinedstorage2.api.grid.view.GridResource;
import com.refinedmods.refinedstorage2.api.grid.view.GridResourceAttributeKey;
import com.refinedmods.refinedstorage2.query.lexer.Lexer;
import com.refinedmods.refinedstorage2.query.lexer.LexerException;
Expand Down Expand Up @@ -30,7 +30,7 @@
import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.1.0")
public class GridQueryParserImpl<T> implements GridQueryParser<T> {
public class GridQueryParserImpl implements GridQueryParser {
private final LexerTokenMappings tokenMappings;
private final ParserOperatorMappings operatorMappings;
private final Map<String, Set<GridResourceAttributeKey>> unaryOperatorToAttributeKeyMapping;
Expand All @@ -44,7 +44,7 @@ public GridQueryParserImpl(final LexerTokenMappings tokenMappings,
}

@Override
public Predicate<AbstractGridResource<T>> parse(final String query) throws GridQueryParserException {
public Predicate<GridResource> parse(final String query) throws GridQueryParserException {
if ("".equals(query.trim())) {
return resource -> true;
}
Expand Down Expand Up @@ -73,15 +73,15 @@ private List<Node> getNodes(final List<Token> tokens) throws GridQueryParserExce
}
}

private Predicate<AbstractGridResource<T>> implicitAnd(final List<Node> nodes) throws GridQueryParserException {
final List<Predicate<AbstractGridResource<T>>> conditions = new ArrayList<>();
private Predicate<GridResource> implicitAnd(final List<Node> nodes) throws GridQueryParserException {
final List<Predicate<GridResource>> conditions = new ArrayList<>();
for (final Node node : nodes) {
conditions.add(parseNode(node));
}
return and(conditions);
}

private Predicate<AbstractGridResource<T>> parseNode(final Node node) throws GridQueryParserException {
private Predicate<GridResource> parseNode(final Node node) throws GridQueryParserException {
if (node instanceof LiteralNode literalNode) {
return parseLiteral(literalNode);
} else if (node instanceof UnaryOpNode unaryOpNode) {
Expand All @@ -94,7 +94,7 @@ private Predicate<AbstractGridResource<T>> parseNode(final Node node) throws Gri
throw new GridQueryParserException("Unsupported node", null);
}

private Predicate<AbstractGridResource<T>> parseBinOp(final BinOpNode node) throws GridQueryParserException {
private Predicate<GridResource> parseBinOp(final BinOpNode node) throws GridQueryParserException {
final String operator = node.binOp().content();
if ("&&".equals(operator)) {
return parseAndBinOpNode(node);
Expand All @@ -105,24 +105,24 @@ private Predicate<AbstractGridResource<T>> parseBinOp(final BinOpNode node) thro
}
}

private Predicate<AbstractGridResource<T>> parseAndBinOpNode(final BinOpNode node) throws GridQueryParserException {
private Predicate<GridResource> parseAndBinOpNode(final BinOpNode node) throws GridQueryParserException {
return and(Arrays.asList(
parseNode(node.left()),
parseNode(node.right())
));
}

private Predicate<AbstractGridResource<T>> parseOrBinOpNode(final BinOpNode node) throws GridQueryParserException {
private Predicate<GridResource> parseOrBinOpNode(final BinOpNode node) throws GridQueryParserException {
return or(Arrays.asList(
parseNode(node.left()),
parseNode(node.right())
));
}

private Predicate<AbstractGridResource<T>> parseUnaryOp(final UnaryOpNode node) throws GridQueryParserException {
private Predicate<GridResource> parseUnaryOp(final UnaryOpNode node) throws GridQueryParserException {
final String operator = node.operator().content();
final Node content = node.node();
final Predicate<AbstractGridResource<T>> predicate;
final Predicate<GridResource> predicate;

if ("!".equals(operator)) {
predicate = not(parseNode(content));
Expand All @@ -149,8 +149,8 @@ private Predicate<AbstractGridResource<T>> parseUnaryOp(final UnaryOpNode node)
return predicate;
}

private static <T> Predicate<AbstractGridResource<T>> count(final Node node,
final BiPredicate<Long, Long> predicate)
private static Predicate<GridResource> count(final Node node,
final BiPredicate<Long, Long> predicate)
throws GridQueryParserException {
if (!(node instanceof LiteralNode)) {
throw new GridQueryParserException("Count filtering expects a literal", null);
Expand All @@ -162,11 +162,11 @@ private static <T> Predicate<AbstractGridResource<T>> count(final Node node,

final long wantedCount = Long.parseLong(((LiteralNode) node).token().content());

return resource -> predicate.test(resource.getResourceAmount().getAmount(), wantedCount);
return resource -> predicate.test(resource.getAmount(), wantedCount);
}

private static <T> Predicate<AbstractGridResource<T>> attributeMatch(final Set<GridResourceAttributeKey> keys,
final String query) {
private static Predicate<GridResource> attributeMatch(final Set<GridResourceAttributeKey> keys,
final String query) {
return resource -> keys
.stream()
.map(resource::getAttribute)
Expand All @@ -178,13 +178,13 @@ private static String normalize(final String value) {
return value.trim().toLowerCase(Locale.ROOT);
}

private static <T> Predicate<AbstractGridResource<T>> parseLiteral(final LiteralNode node) {
private static Predicate<GridResource> parseLiteral(final LiteralNode node) {
return resource -> normalize(resource.getName()).contains(normalize(node.token().content()));
}

private static <T> Predicate<AbstractGridResource<T>> and(final List<Predicate<AbstractGridResource<T>>> chain) {
private static Predicate<GridResource> and(final List<Predicate<GridResource>> chain) {
return resource -> {
for (final Predicate<AbstractGridResource<T>> predicate : chain) {
for (final Predicate<GridResource> predicate : chain) {
if (!predicate.test(resource)) {
return false;
}
Expand All @@ -193,9 +193,9 @@ private static <T> Predicate<AbstractGridResource<T>> and(final List<Predicate<A
};
}

private static <T> Predicate<AbstractGridResource<T>> or(final List<Predicate<AbstractGridResource<T>>> chain) {
private static Predicate<GridResource> or(final List<Predicate<GridResource>> chain) {
return resource -> {
for (final Predicate<AbstractGridResource<T>> predicate : chain) {
for (final Predicate<GridResource> predicate : chain) {
if (predicate.test(resource)) {
return true;
}
Expand All @@ -204,7 +204,7 @@ private static <T> Predicate<AbstractGridResource<T>> or(final List<Predicate<Ab
};
}

private static <T> Predicate<AbstractGridResource<T>> not(final Predicate<AbstractGridResource<T>> predicate) {
private static Predicate<GridResource> not(final Predicate<GridResource> predicate) {
return resource -> !predicate.test(resource);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.refinedmods.refinedstorage2.api.grid.service;

import com.refinedmods.refinedstorage2.api.storage.Actor;
import com.refinedmods.refinedstorage2.api.storage.channel.StorageChannelType;

import java.util.function.ToLongFunction;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.2.6")
public interface GridServiceFactory {
<T> GridService<T> create(
StorageChannelType<T> storageChannelType,
Actor actor,
ToLongFunction<T> maxAmountProvider,
long singleAmount
);
}
Loading

0 comments on commit 4ac2616

Please sign in to comment.