Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v2.0.0-milestone.3.6 #524

Merged
merged 33 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b0a4409
Merge pull request #515 from refinedmods/main
raoulvdberge Apr 4, 2024
38aab20
chore: update translation Chinese Simplified from crowdin
raoulvdberge Apr 4, 2024
e9b9081
chore: update translation French from crowdin
raoulvdberge Apr 4, 2024
9bb8886
chore: update translation Spanish from crowdin
raoulvdberge Apr 4, 2024
bf7d99a
chore: update translation Polish from crowdin
raoulvdberge Apr 4, 2024
68372ba
chore: update translation Russian from crowdin
raoulvdberge Apr 4, 2024
241b7ab
chore: update translation Portuguese, Brazilian from crowdin
raoulvdberge Apr 4, 2024
4194141
chore: update translation Indonesian from crowdin
raoulvdberge Apr 4, 2024
3e587c2
chore: update translation German from crowdin
raoulvdberge Apr 4, 2024
dbde139
chore: update translation Hungarian from crowdin
raoulvdberge Apr 4, 2024
263894f
chore: update translation Italian from crowdin
raoulvdberge Apr 4, 2024
cd0f25a
chore: update translation Japanese from crowdin
raoulvdberge Apr 4, 2024
a77dc76
chore: update translation Korean from crowdin
raoulvdberge Apr 4, 2024
086d111
chore: update translation Chinese Traditional from crowdin
raoulvdberge Apr 4, 2024
22b47e4
Merge pull request #516 from refinedmods/crowdin-translations
raoulvdberge Apr 4, 2024
4422522
refactor: allow multiple containers within a single container block e…
raoulvdberge Apr 5, 2024
1a36d64
Merge pull request #517 from refinedmods/feat/GH-80/multiple-containers
raoulvdberge Apr 5, 2024
36606ec
fix: double slot highlighting in the grid
raoulvdberge Apr 4, 2024
d388270
fix: detector, receiver, transmitter and security manager always conn…
raoulvdberge Apr 4, 2024
ac66269
fix: relax logging, new storages will not have an id yet
raoulvdberge Apr 5, 2024
a752533
fix: introduce safe saved data for data corruption protection
raoulvdberge Apr 5, 2024
9d07262
Merge pull request #520 from refinedmods/feat/GH-518/bugfixes
raoulvdberge Apr 5, 2024
5140d30
refactor: improve contract needed for energy network component
raoulvdberge Apr 5, 2024
3faf3ae
Merge pull request #521 from refinedmods/feat/GH-80/energy-contract
raoulvdberge Apr 5, 2024
c052e23
chore: update translation German from crowdin
raoulvdberge Apr 5, 2024
09b1212
chore: update translation French from crowdin
raoulvdberge Apr 8, 2024
da0c99d
chore: update translation French from crowdin
raoulvdberge Apr 9, 2024
55f4f60
chore: update translation Spanish from crowdin
raoulvdberge Apr 20, 2024
0e0fe83
chore: update translation Chinese Simplified from crowdin
raoulvdberge Apr 22, 2024
0e4eaf4
Merge pull request #519 from refinedmods/crowdin-translations
raoulvdberge Apr 22, 2024
b7c3d94
feat: relay and subnetworking
raoulvdberge Apr 5, 2024
feb1c13
Merge pull request #523 from refinedmods/feat/GH-80/relay
raoulvdberge May 18, 2024
b212d5a
chore: prepare release v2.0.0-milestone.3.6
raoulvdberge May 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.0.0-milestone.3.6] - 2024-05-18

### Added

- Relay

### Changed

- The Detector, Network Receiver, Network Transmitter and Security Manager will now always connect regardless of color.
- The Relay now has a "pass-through" mode. By default, pass-through is on, which means that when the Relay is active, the network signal from the input network will be passed through as-is to the output side.
- When the "pass-through" mode on the Relay is off, the network signal from the input network will no longer be passed through as-is to the output side, but you can choose to pass the energy buffer, security settings or (specific) storage resources of the input network to the output network.
- When using the Relay when "pass-through" mode is off, and when passing all storage resources or specific storage resources, you can choose the filter mode, whether fuzzy mode is enabled, the access mode and the priority of the storage exposed to the output network.

### Fixed

- Double slot highlighting in the Grid.
- Improved data corruption protection for storages.

## [2.0.0-milestone.3.5] - 2024-04-04

### Added
Expand Down Expand Up @@ -554,7 +572,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.3.5...HEAD
[Unreleased]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.3.6...HEAD

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ public ComponentMapFactory<C, X> copy() {
return new ComponentMapFactory<>(new LinkedHashMap<>(factories));
}

@SuppressWarnings("unchecked")
public ComponentMap<C> buildComponentMap(final X context) {
final Map<Class<? extends C>, C> components = new LinkedHashMap<>();
factories.forEach((componentType, factory) -> components.put(componentType, factory.apply(context)));
factories.forEach((componentType, factory) -> {
final C component = factory.apply(context);
components.put(componentType, component);
});
return new ComponentMap<>(components);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,5 @@
import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.1.1")
public interface EnergyNetworkComponent extends NetworkComponent {
long getStored();

long getCapacity();

long extract(long amount);
public interface EnergyNetworkComponent extends NetworkComponent, EnergyProvider {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.refinedmods.refinedstorage2.api.network.energy;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.6")
public interface EnergyProvider {
long getStored();

long getCapacity();

long extract(long amount);

default boolean contains(EnergyProvider energyProvider) {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.refinedmods.refinedstorage2.api.network.node.container;

import com.refinedmods.refinedstorage2.api.network.node.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.node.NetworkNode;

import javax.annotation.Nullable;
Expand All @@ -18,7 +17,8 @@ public interface NetworkNodeContainer {
* The key must be kept stable, and must stay the same for the lifetime of the container.
* If it changes after adding it into the graph, the container would not be removed from the key index when the
* container is removed!
* The container can be queried by {@link GraphNetworkComponent#getContainer(Object)}.
* The container can be queried by
* {@link com.refinedmods.refinedstorage2.api.network.node.GraphNetworkComponent#getContainer(Object)}.
*
* @return the key, or null if indexing is not required
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ default SecurityDecision isAllowed(Permission permission) {
return SecurityDecision.PASS;
}

default boolean isActive() {
default boolean isProviderActive() {
return true;
}

default boolean contains(SecurityNetworkComponent component) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.5")
@FunctionalInterface
public interface SecurityNetworkComponent extends NetworkComponent {
boolean isAllowed(Permission permission, SecurityActor actor);

boolean contains(SecurityNetworkComponent component);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
public record SecurityPolicy(Set<Permission> allowedPermissions) {
public static final SecurityPolicy EMPTY = new SecurityPolicy(Collections.emptySet());

public static SecurityPolicy of(final Permission... permissions) {
return new SecurityPolicy(Set.of(permissions));
}

public boolean isAllowed(final Permission permission) {
return allowedPermissions.contains(permission);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.refinedmods.refinedstorage2.api.network.NetworkComponent;
import com.refinedmods.refinedstorage2.api.storage.Actor;
import com.refinedmods.refinedstorage2.api.storage.Storage;
import com.refinedmods.refinedstorage2.api.storage.TrackedResourceAmount;
import com.refinedmods.refinedstorage2.api.storage.channel.StorageChannel;

Expand All @@ -12,4 +13,6 @@
@API(status = API.Status.STABLE, since = "2.0.0-milestone.1.1")
public interface StorageNetworkComponent extends NetworkComponent, StorageChannel {
List<TrackedResourceAmount> getResources(Class<? extends Actor> actorType);

boolean contains(Storage storage);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.refinedmods.refinedstorage2.network.test;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
public @interface InjectNetworkSecurityComponent {
String networkId() default "default";
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
public @interface InjectNetworkStorageChannel {
public @interface InjectNetworkStorageComponent {
String networkId() default "default";
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.refinedmods.refinedstorage2.api.network.impl.node.iface.InterfaceNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.importer.ImporterNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.multistorage.MultiStorageNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.relay.RelayInputNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.relay.RelayOutputNetworkNode;
import com.refinedmods.refinedstorage2.api.network.impl.node.storage.StorageNetworkNode;
import com.refinedmods.refinedstorage2.network.test.nodefactory.ControllerNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.DetectorNetworkNodeFactory;
Expand All @@ -18,6 +20,8 @@
import com.refinedmods.refinedstorage2.network.test.nodefactory.ImporterNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.InterfaceNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.MultiStorageNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.RelayInputNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.RelayOutputNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.SimpleNetworkNodeFactory;
import com.refinedmods.refinedstorage2.network.test.nodefactory.StorageNetworkNodeFactory;

Expand All @@ -41,5 +45,7 @@
@RegisterNetworkNode(value = InterfaceNetworkNodeFactory.class, clazz = InterfaceNetworkNode.class)
@RegisterNetworkNode(value = ExternalStorageNetworkNodeFactory.class, clazz = ExternalStorageNetworkNode.class)
@RegisterNetworkNode(value = DetectorNetworkNodeFactory.class, clazz = DetectorNetworkNode.class)
@RegisterNetworkNode(value = RelayInputNetworkNodeFactory.class, clazz = RelayInputNetworkNode.class)
@RegisterNetworkNode(value = RelayOutputNetworkNodeFactory.class, clazz = RelayOutputNetworkNode.class)
public @interface NetworkTest {
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import com.refinedmods.refinedstorage2.api.network.impl.energy.EnergyStorageImpl;
import com.refinedmods.refinedstorage2.api.network.impl.node.controller.ControllerNetworkNode;
import com.refinedmods.refinedstorage2.api.network.node.NetworkNode;
import com.refinedmods.refinedstorage2.api.network.security.SecurityNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.storage.StorageNetworkComponent;
import com.refinedmods.refinedstorage2.api.storage.channel.StorageChannel;
import com.refinedmods.refinedstorage2.network.test.nodefactory.NetworkNodeFactory;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -33,9 +34,10 @@ public class NetworkTestExtension implements BeforeEachCallback, ParameterResolv

@Override
public void beforeEach(final ExtensionContext extensionContext) {
extensionContext
.getTestInstances()
.ifPresent(testInstances -> testInstances.getAllInstances().forEach(this::processTestInstance));
extensionContext.getTestInstances().ifPresent(
testInstances -> testInstances.getAllInstances().forEach(this::processTestInstance)
);
extensionContext.getTestMethod().ifPresent(this::processTestMethod);
}

private void processTestInstance(final Object testInstance) {
Expand All @@ -45,6 +47,10 @@ private void processTestInstance(final Object testInstance) {
addNetworkNodes(testInstance);
}

private void processTestMethod(final Method method) {
setupNetworks(method);
}

private void registerNetworkNodes(final Object testInstance) {
for (final RegisterNetworkNode annotation : getAnnotations(testInstance, RegisterNetworkNode.class)) {
try {
Expand All @@ -61,10 +67,22 @@ private void registerNetworkNodes(final Object testInstance) {

private void setupNetworks(final Object testInstance) {
for (final SetupNetwork annotation : getAnnotations(testInstance, SetupNetwork.class)) {
final Network network = new NetworkImpl(NetworkTestFixtures.NETWORK_COMPONENT_MAP_FACTORY);
setupNetwork(annotation);
}
}

private void setupNetworks(final Method method) {
for (final SetupNetwork annotation : method.getAnnotationsByType(SetupNetwork.class)) {
setupNetwork(annotation);
}
}

private void setupNetwork(final SetupNetwork annotation) {
final Network network = new NetworkImpl(NetworkTestFixtures.NETWORK_COMPONENT_MAP_FACTORY);
if (annotation.setupEnergy()) {
setupNetworkEnergy(annotation.energyCapacity(), annotation.energyStored(), network);
networkMap.put(annotation.id(), network);
}
networkMap.put(annotation.id(), network);
}

private <A extends Annotation> List<A> getAnnotations(final Object testInstance, final Class<A> annotationType) {
Expand Down Expand Up @@ -173,35 +191,39 @@ private void setField(final Object instance, final Field field, final Object val
@Override
public boolean supportsParameter(final ParameterContext parameterContext,
final ExtensionContext extensionContext) throws ParameterResolutionException {
return parameterContext.isAnnotated(InjectNetworkStorageChannel.class)
return parameterContext.isAnnotated(InjectNetworkStorageComponent.class)
|| parameterContext.isAnnotated(InjectNetworkEnergyComponent.class)
|| parameterContext.isAnnotated(InjectNetworkSecurityComponent.class)
|| parameterContext.isAnnotated(InjectNetwork.class);
}

@Override
public Object resolveParameter(final ParameterContext parameterContext,
final ExtensionContext extensionContext) throws ParameterResolutionException {
return parameterContext
.findAnnotation(InjectNetworkStorageChannel.class)
.map(annotation -> (Object) getNetworkStorageChannel(annotation.networkId()))
.findAnnotation(InjectNetworkStorageComponent.class)
.map(annotation -> (Object) getNetworkStorage(annotation.networkId()))
.or(() -> parameterContext
.findAnnotation(InjectNetworkEnergyComponent.class)
.map(annotation -> (Object) getNetworkEnergy(annotation.networkId())))
.or(() -> parameterContext
.findAnnotation(InjectNetworkSecurityComponent.class)
.map(annotation -> (Object) getNetworkSecurity(annotation.networkId())))
.or(() -> parameterContext
.findAnnotation(InjectNetwork.class)
.map(annotation -> networkMap.get(annotation.value())))
.orElseThrow();
}

private StorageChannel getNetworkStorageChannel(final String networkId) {
return networkMap
.get(networkId)
.getComponent(StorageNetworkComponent.class);
private StorageNetworkComponent getNetworkStorage(final String networkId) {
return networkMap.get(networkId).getComponent(StorageNetworkComponent.class);
}

private EnergyNetworkComponent getNetworkEnergy(final String networkId) {
return networkMap
.get(networkId)
.getComponent(EnergyNetworkComponent.class);
return networkMap.get(networkId).getComponent(EnergyNetworkComponent.class);
}

private SecurityNetworkComponent getNetworkSecurity(final String networkId) {
return networkMap.get(networkId).getComponent(SecurityNetworkComponent.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
import com.refinedmods.refinedstorage2.api.network.energy.EnergyNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.impl.energy.EnergyNetworkComponentImpl;
import com.refinedmods.refinedstorage2.api.network.impl.node.GraphNetworkComponentImpl;
import com.refinedmods.refinedstorage2.api.network.impl.security.SecurityNetworkComponentImpl;
import com.refinedmods.refinedstorage2.api.network.impl.storage.StorageNetworkComponentImpl;
import com.refinedmods.refinedstorage2.api.network.node.GraphNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.security.SecurityNetworkComponent;
import com.refinedmods.refinedstorage2.api.network.security.SecurityPolicy;
import com.refinedmods.refinedstorage2.api.network.storage.StorageNetworkComponent;
import com.refinedmods.refinedstorage2.api.resource.list.ResourceListImpl;
import com.refinedmods.refinedstorage2.network.test.fake.FakePermissions;

public final class NetworkTestFixtures {
public static final ComponentMapFactory<NetworkComponent, Network> NETWORK_COMPONENT_MAP_FACTORY =
Expand All @@ -28,6 +32,10 @@ public final class NetworkTestFixtures {
StorageNetworkComponent.class,
network -> new StorageNetworkComponentImpl(new ResourceListImpl())
);
NETWORK_COMPONENT_MAP_FACTORY.addFactory(
SecurityNetworkComponent.class,
network -> new SecurityNetworkComponentImpl(SecurityPolicy.of(FakePermissions.ALLOW_BY_DEFAULT))
);
}

private NetworkTestFixtures() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Target({ElementType.TYPE, ElementType.METHOD})
@Repeatable(SetupNetworks.class)
public @interface SetupNetwork {
long energyStored() default Long.MAX_VALUE;

long energyCapacity() default Long.MAX_VALUE;

boolean setupEnergy() default true;

String id() default "default";
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface SetupNetworks {
SetupNetwork[] value();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.refinedmods.refinedstorage2.network.test.util;
package com.refinedmods.refinedstorage2.network.test.fake;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.refinedmods.refinedstorage2.network.test.fake;

import com.refinedmods.refinedstorage2.api.network.security.Permission;

public enum FakePermissions implements Permission {
ALLOW_BY_DEFAULT, OTHER, OTHER2
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.refinedmods.refinedstorage2.network.test;
package com.refinedmods.refinedstorage2.network.test.fake;

import com.refinedmods.refinedstorage2.api.resource.ResourceKey;

public enum TestResource implements ResourceKey {
public enum FakeResources implements ResourceKey {
A,
A_ALTERNATIVE,
A_ALTERNATIVE2,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.refinedmods.refinedstorage2.network.test.fake;

import com.refinedmods.refinedstorage2.api.network.security.SecurityActor;

public enum FakeSecurityActors implements SecurityActor {
A, B, C
}
Loading
Loading