Skip to content

Commit

Permalink
validate mod is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
LLytho authored and rlnt committed Aug 22, 2024
1 parent 1a3cd06 commit 15e9c0e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Common/src/main/java/com/almostreliable/unified/AlmostUnified.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.almostreliable.unified;

import com.almostreliable.unified.api.Placeholders;
import com.almostreliable.unified.api.TagMap;
import com.almostreliable.unified.api.UnifierRegistry;
import com.almostreliable.unified.api.UnifyHandler;
import com.almostreliable.unified.api.*;
import com.almostreliable.unified.config.*;
import com.almostreliable.unified.impl.AlmostUnifiedRuntimeImpl;
import com.almostreliable.unified.impl.TagMapImpl;
Expand Down Expand Up @@ -79,6 +76,7 @@ public static void onTagLoaderReload(Map<ResourceLocation, Collection<Holder<Ite
TagMap<Item> tagMap = TagMapImpl.compose(unifyHandlers.stream().map(UnifyHandler::getTagMap).toList());
ItemHider.applyHideTags(tags, unifyHandlers);

logMissingPriorityMods(unifyHandlers);
RUNTIME = new AlmostUnifiedRuntimeImpl(tagMap,
unifyHandlers,
dupConfig,
Expand All @@ -87,6 +85,21 @@ public static void onTagLoaderReload(Map<ResourceLocation, Collection<Holder<Ite
tagOwnerships);
}

private static void logMissingPriorityMods(List<UnifyHandler> unifyHandlers) {
Set<String> mods = unifyHandlers
.stream()
.map(UnifySettings::getModPriorities)
.flatMap(ModPriorities::stream)
.collect(Collectors.toSet());

for (String mod : mods) {
if (!AlmostUnifiedPlatform.INSTANCE.isModLoaded(mod)) {
LOG.warn("Mod '{}' is not loaded, but used in unify settings", mod);
}
}
}


/**
* Creates all unify handlers for further unification.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import javax.annotation.Nullable;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public interface ModPriorities extends Iterable<String> {

Expand All @@ -17,4 +19,8 @@ public interface ModPriorities extends Iterable<String> {
ResourceLocation findPreferredItemId(TagKey<Item> tag, List<ResourceLocation> items);

void forEachOverride(BiConsumer<TagKey<Item>, String> callback);

default Stream<String> stream() {
return StreamSupport.stream(spliterator(), false);
}
}

0 comments on commit 15e9c0e

Please sign in to comment.