-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Data versioning, default extraction, and removing marker files
Marker files have silently been removed - this should not affect anything in a breaking fashion.
- Loading branch information
1 parent
bfd594f
commit 633332e
Showing
10 changed files
with
258 additions
and
75 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
Common/src/main/java/dev/lukebemish/defaultresources/api/OutdatedResourcesListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) 2024 Luke Bemish, and contributors | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
*/ | ||
|
||
package dev.lukebemish.defaultresources.api; | ||
|
||
import dev.lukebemish.defaultresources.impl.DefaultResources; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Allows mods to provide custom logic for when the extracted default resources are outdated, but cannot be updated due | ||
* to having been changed on disk. | ||
*/ | ||
public interface OutdatedResourcesListener { | ||
|
||
/** | ||
* Called when the listener is fired. | ||
* @param oldDataVersion the data version of the outdated resources on disk, or {@code null} if none is present | ||
* @param newDataVersion the data version of the new resources the mod provides, or {@code null} if none is present | ||
*/ | ||
void resourcesOutdated(@Nullable String oldDataVersion, @Nullable String newDataVersion); | ||
|
||
/** | ||
* Registers a listener to be notified when the extracted default resources are outdated, but cannot be updated due | ||
* to having been changed on disk. | ||
* @param modId the mod ID to listen for | ||
* @param listener the listener to call if the resources cannot be updated | ||
*/ | ||
@SuppressWarnings("unused") | ||
static void register(String modId, OutdatedResourcesListener listener) { | ||
DefaultResources.delegate(() -> { | ||
Optional<String> oldVersion = DefaultResources.OUTDATED_TARGETS.get(modId); | ||
Optional<String> newVersion = DefaultResources.MOD_TARGETS.get(modId); | ||
if (oldVersion != null && newVersion != null) { | ||
listener.resourcesOutdated(oldVersion.orElse(null), newVersion.orElse(null)); | ||
} | ||
}, () -> DefaultResources.addListener(modId, listener)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.