Skip to content

Commit

Permalink
Merge pull request #475 from refinedmods/release/2.0.0-milestone.3.3
Browse files Browse the repository at this point in the history
Release v2.0.0-milestone.3.3
  • Loading branch information
raoulvdberge authored Feb 17, 2024
2 parents 4c0ac38 + 28a5521 commit 61eaab4
Show file tree
Hide file tree
Showing 382 changed files with 7,906 additions and 4,299 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ on:
types: [ opened, synchronize, reopened ]
jobs:
build:
uses: refinedmods/refinedarchitect/.github/workflows/build.yml@v0.9.0
uses: refinedmods/refinedarchitect/.github/workflows/build.yml@v0.11.3
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
type: string
jobs:
draft:
uses: refinedmods/refinedarchitect/.github/workflows/draft-release.yml@v0.9.0
uses: refinedmods/refinedarchitect/.github/workflows/draft-release.yml@v0.11.3
with:
release-type: ${{ inputs.release-type }}
version-number-override: ${{ inputs.version-number-override }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-for-unsupported-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ on:
types: [ labeled, unlabeled, reopened ]
jobs:
unsupported-labeler:
uses: refinedmods/refinedarchitect/.github/workflows/issue-for-unsupported-version.yml@v0.9.0
uses: refinedmods/refinedarchitect/.github/workflows/issue-for-unsupported-version.yml@v0.11.3
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- closed
jobs:
publish-release:
uses: refinedmods/refinedarchitect/.github/workflows/publish-release.yml@v0.9.0
uses: refinedmods/refinedarchitect/.github/workflows/publish-release.yml@v0.11.3
secrets: inherit
with:
project-name: 'Refined Storage'
2 changes: 1 addition & 1 deletion .github/workflows/resolved-issue-locking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ on:
- cron: '0 0 * * *'
jobs:
lock:
uses: refinedmods/refinedarchitect/.github/workflows/resolved-issue-locking.yml@v0.9.0
uses: refinedmods/refinedarchitect/.github/workflows/resolved-issue-locking.yml@v0.11.3
2 changes: 1 addition & 1 deletion .github/workflows/validate-branch-name.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: Validate branch name
on: [ pull_request ]
jobs:
validate-branch-name:
uses: refinedmods/refinedarchitect/.github/workflows/validate-branch-name.yml@v0.9.0
uses: refinedmods/refinedarchitect/.github/workflows/validate-branch-name.yml@v0.11.3
2 changes: 1 addition & 1 deletion .github/workflows/validate-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ on:
types: [ opened, synchronize, reopened, ready_for_review, labeled, unlabeled ]
jobs:
validate-changelog:
uses: refinedmods/refinedarchitect/.github/workflows/validate-changelog.yml@v0.9.0
uses: refinedmods/refinedarchitect/.github/workflows/validate-changelog.yml@v0.11.3
2 changes: 1 addition & 1 deletion .github/workflows/validate-commit-messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: Validate commit messages
on: [ pull_request ]
jobs:
validate-commit-messages:
uses: refinedmods/refinedarchitect/.github/workflows/validate-commit-messages.yml@v0.9.0
uses: refinedmods/refinedarchitect/.github/workflows/validate-commit-messages.yml@v0.11.3
23 changes: 22 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.0.0-milestone.3.3] - 2024-02-17

### Added

- Ported to Minecraft 1.20.4.
- Custom disk models. Fluid disks now have a different model.
- Portable Grid
- Chinese translation by [@Jiangsubei](https://github.com/Jiangsubei).

### Changed

- The Portable Grid now shows an energy bar in the UI.
- The energy bar on creative items now shows the infinity symbol instead of the whole amount.

### Fixed

- Fixed bug where Grid contents weren't synced properly when a network merge occurs.
- Fixed incompatibility crash with InvMove on Fabric.

## [2.0.0-milestone.3.2] - 2023-11-03

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The MIT License (MIT)

Copyright © 2020 - 2023 Refined Mods
Copyright © 2020 - 2024 Refined Mods

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
Expand Down
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public GridOperationsImpl(final StorageChannel<T> storageChannel,
}

@Override
public boolean extract(final T resource, final GridExtractMode extractMode,
public boolean extract(final T resource,
final GridExtractMode extractMode,
final InsertableStorage<T> destination) {
final long amount = getExtractableAmount(resource, extractMode);
if (amount == 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.refinedmods.refinedstorage2.api.grid.operations;

import com.refinedmods.refinedstorage2.api.storage.ExtractableStorage;
import com.refinedmods.refinedstorage2.api.storage.InsertableStorage;

public class NoopGridOperations<T> implements GridOperations<T> {
@Override
public boolean extract(final T resource,
final GridExtractMode extractMode,
final InsertableStorage<T> destination) {
return false;
}

@Override
public boolean insert(final T resource,
final GridInsertMode insertMode,
final ExtractableStorage<T> source) {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.refinedmods.refinedstorage2.api.grid.watcher;

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

import java.util.Set;

import org.apiguardian.api.API;

/**
* Provides the {@link GridWatcherManagerImpl} with {@link StorageChannel}s.
*/
@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.3")
public interface GridStorageChannelProvider {
Set<StorageChannelType<?>> getStorageChannelTypes();

<T> StorageChannel<T> getStorageChannel(StorageChannelType<T> type);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.refinedmods.refinedstorage2.api.grid;
package com.refinedmods.refinedstorage2.api.grid.watcher;

import com.refinedmods.refinedstorage2.api.storage.channel.StorageChannelType;
import com.refinedmods.refinedstorage2.api.storage.tracked.TrackedResource;
Expand Down Expand Up @@ -36,7 +36,7 @@ <T> void onChanged(
);

/**
* Called when the grid network has been changed.
* Usually called when the grid network has been changed.
*/
void onNetworkChanged();
void invalidate();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.refinedmods.refinedstorage2.api.grid.watcher;

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

import org.apiguardian.api.API;

/**
* This manager helps with attaching and detaching listeners to
* {@link com.refinedmods.refinedstorage2.api.storage.channel.StorageChannel}s.
*/
@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.3")
public interface GridWatcherManager {
void addWatcher(
GridWatcher watcher,
Class<? extends Actor> actorType,
GridStorageChannelProvider storageChannelProvider
);

void attachAll(GridStorageChannelProvider storageChannelProvider);

void removeWatcher(GridWatcher watcher, GridStorageChannelProvider storageChannelProvider);

void detachAll(GridStorageChannelProvider storageChannelProvider);

void activeChanged(boolean active);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.refinedmods.refinedstorage2.api.grid.watcher;

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

import java.util.HashMap;
import java.util.Map;

import org.apiguardian.api.API;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.3")
public class GridWatcherManagerImpl implements GridWatcherManager {
private static final Logger LOGGER = LoggerFactory.getLogger(GridWatcherManagerImpl.class);

private final Map<GridWatcher, GridWatcherRegistration> watchers = new HashMap<>();

@Override
public void addWatcher(
final GridWatcher watcher,
final Class<? extends Actor> actorType,
final GridStorageChannelProvider storageChannelProvider
) {
if (watchers.containsKey(watcher)) {
throw new IllegalArgumentException("Watcher is already registered");
}
final GridWatcherRegistration registration = new GridWatcherRegistration(watcher, actorType);
attachAll(registration, storageChannelProvider, false);
watchers.put(watcher, registration);
LOGGER.info("Added watcher {}, new count is {}", watcher, watchers.size());
}

@Override
public void attachAll(final GridStorageChannelProvider storageChannelProvider) {
// If we get here we are affected by a network split or network merge.
// At this point, all the storages that are affected by the split or merge have not yet been processed
// as the grid has the highest priority.
watchers.forEach((watcher, registration) -> {
// Invalidate all watcher data, the resources that were synced earlier are no longer valid because we have
// a brand-new network.
watcher.invalidate();
// Re-attach the watcher to the new network, and send all the resources from the new network.
// Resources from the old network are not part of the new network yet, as mentioned above,
// but those will be synced when the storages are re-added.
attachAll(registration, storageChannelProvider, true);
});
}

private void attachAll(final GridWatcherRegistration registration,
final GridStorageChannelProvider storageChannelProvider,
final boolean replay) {
storageChannelProvider.getStorageChannelTypes().forEach(storageChannelType -> attach(
registration,
storageChannelType,
storageChannelProvider,
replay
));
}

private <T> void attach(
final GridWatcherRegistration registration,
final StorageChannelType<T> storageChannelType,
final GridStorageChannelProvider storageChannelProvider,
final boolean replay
) {
LOGGER.info("Attaching {} to {}", registration, storageChannelType);
registration.attach(storageChannelProvider.getStorageChannel(storageChannelType), storageChannelType, replay);
}

@Override
public void removeWatcher(final GridWatcher watcher, final GridStorageChannelProvider storageChannelProvider) {
final GridWatcherRegistration registration = watchers.get(watcher);
if (registration == null) {
throw new IllegalArgumentException("Watcher is not registered");
}
detachAll(registration, storageChannelProvider);
watchers.remove(watcher);
LOGGER.info("Removed watcher {}, remaining {}", watcher, watchers.size());
}

@Override
public void detachAll(final GridStorageChannelProvider storageChannelProvider) {
LOGGER.info("Detaching {} watchers", watchers.size());
watchers.values().forEach(w -> detachAll(w, storageChannelProvider));
}

private void detachAll(final GridWatcherRegistration registration,
final GridStorageChannelProvider storageChannelProvider) {
storageChannelProvider.getStorageChannelTypes().forEach(storageChannelType -> detach(
registration,
storageChannelType,
storageChannelProvider
));
}

private <T> void detach(
final GridWatcherRegistration registration,
final StorageChannelType<T> storageChannelType,
final GridStorageChannelProvider storageChannelProvider
) {
LOGGER.info("Detaching {} from {}", registration, storageChannelType);
registration.detach(storageChannelProvider.getStorageChannel(storageChannelType), storageChannelType);
}

@Override
public void activeChanged(final boolean active) {
watchers.keySet().forEach(watcher -> watcher.onActiveChanged(active));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.refinedmods.refinedstorage2.api.network.impl.node.grid;
package com.refinedmods.refinedstorage2.api.grid.watcher;

import com.refinedmods.refinedstorage2.api.grid.GridWatcher;
import com.refinedmods.refinedstorage2.api.resource.list.listenable.ResourceListListener;
import com.refinedmods.refinedstorage2.api.storage.Actor;
import com.refinedmods.refinedstorage2.api.storage.channel.StorageChannel;
Expand All @@ -9,17 +8,19 @@
import java.util.HashMap;
import java.util.Map;

public class GridWatcherRegistration {
class GridWatcherRegistration {
private final GridWatcher watcher;
private final Class<? extends Actor> actorType;
private final Map<StorageChannelType<?>, ResourceListListener<?>> listeners = new HashMap<>();

public GridWatcherRegistration(final GridWatcher watcher, final Class<? extends Actor> actorType) {
GridWatcherRegistration(final GridWatcher watcher, final Class<? extends Actor> actorType) {
this.watcher = watcher;
this.actorType = actorType;
}

public <T> void attach(final StorageChannel<T> storageChannel, final StorageChannelType<T> storageChannelType) {
<T> void attach(final StorageChannel<T> storageChannel,
final StorageChannelType<T> storageChannelType,
final boolean replay) {
final ResourceListListener<T> listener = change -> watcher.onChanged(
storageChannelType,
change.resourceAmount().getResource(),
Expand All @@ -31,10 +32,21 @@ public <T> void attach(final StorageChannel<T> storageChannel, final StorageChan
);
storageChannel.addListener(listener);
listeners.put(storageChannelType, listener);
if (replay) {
storageChannel.getAll().forEach(resourceAmount -> watcher.onChanged(
storageChannelType,
resourceAmount.getResource(),
resourceAmount.getAmount(),
storageChannel.findTrackedResourceByActorType(
resourceAmount.getResource(),
actorType
).orElse(null)
));
}
}

@SuppressWarnings("unchecked")
public <T> void detach(final StorageChannel<T> storageChannel, final StorageChannelType<T> storageChannelType) {
<T> void detach(final StorageChannel<T> storageChannel, final StorageChannelType<T> storageChannelType) {
final ResourceListListener<T> listener = (ResourceListListener<T>) listeners.get(storageChannelType);
storageChannel.removeListener(listener);
listeners.remove(storageChannelType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@ParametersAreNonnullByDefault
@FieldsAndMethodsAreNonnullByDefault
package com.refinedmods.refinedstorage2.api.grid;
package com.refinedmods.refinedstorage2.api.grid.watcher;

import com.refinedmods.refinedstorage2.api.core.FieldsAndMethodsAreNonnullByDefault;

Expand Down
Loading

0 comments on commit 61eaab4

Please sign in to comment.