Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev/1.21' into dev/1.21
Browse files Browse the repository at this point in the history
# Conflicts:
#	settings.gradle
  • Loading branch information
Oganesson897 committed Aug 3, 2024
2 parents b11dac1 + eca9a8d commit 5e428ce
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import band.kessoku.lib.platform.impl.KessokuPlatformServices;

import java.nio.file.Path;
import java.util.Collection;

public interface ModLoader {
static ModLoader getInstance() {
Expand All @@ -17,4 +18,6 @@ static ModLoader getInstance() {
Path getConfigFolder();
Path getModsFolder();
boolean isModLoaded(String id);
Collection<String> getModIds();
Collection<? extends ModData> getMods();
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public ModDataImpl(String modid) {
this.modContainer = FabricLoader.getInstance().getModContainer(modid).orElseThrow();
this.modMetadata = modContainer.getMetadata();
}
public ModDataImpl(ModContainer container) {
this.modContainer = container;
this.modMetadata = modContainer.getMetadata();
}

@Override
public String getModId() {
Expand All @@ -34,7 +38,7 @@ public String getVersion() {

@Override
public Collection<? extends ModDependencyInfo> getDependencies() {
return modMetadata.getDependencies().stream().map(ModDependencyInfoImpl::new).collect(Collectors.toSet());
return modMetadata.getDependencies().stream().map(ModDependencyInfoImpl::new).toList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class ModDependencyInfoImpl implements ModDependencyInfo {
private final ModDependency value;
public ModDependencyInfoImpl(ModDependency dependency) {
value = dependency;
this.value = dependency;
}
@Override
public DependencyKind getKind() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
import com.google.auto.service.AutoService;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.fabricmc.loader.api.metadata.ModMetadata;

import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

Expand Down Expand Up @@ -54,4 +58,14 @@ public Path getModsFolder() {
public boolean isModLoaded(String id) {
return FabricLoader.getInstance().isModLoaded(id);
}

@Override
public Collection<String> getModIds() {
return FabricLoader.getInstance().getAllMods().stream().map(ModContainer::getMetadata).map(ModMetadata::getId).toList();
}

@Override
public Collection<? extends ModData> getMods() {
return FabricLoader.getInstance().getAllMods().stream().map(ModDataImpl::new).toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public ModDataImpl(String modid) {
this.modInfo = modContainer.getModInfo();
}

public ModDataImpl(IModInfo info) {
this.modContainer = ModList.get().getModContainerById(info.getModId()).orElseThrow();
this.modInfo = info;
}

@Override
public String getModId() {
return modInfo.getModId();
Expand All @@ -34,7 +39,7 @@ public String getVersion() {

@Override
public Collection<? extends ModDependencyInfo> getDependencies() {
return modInfo.getDependencies().stream().map(ModDependencyInfoImpl::new).collect(Collectors.toSet());
return modInfo.getDependencies().stream().map(ModDependencyInfoImpl::new).toList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class ModDependencyInfoImpl implements ModDependencyInfo {
private final IModInfo.ModVersion value;
public ModDependencyInfoImpl(IModInfo.ModVersion modVersion) {
value = modVersion;
this.value = modVersion;
}
@Override
public DependencyKind getKind() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
import net.neoforged.fml.ModList;
import net.neoforged.fml.loading.FMLLoader;
import net.neoforged.fml.loading.FMLPaths;
import net.neoforged.neoforgespi.language.IModInfo;

import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

Expand Down Expand Up @@ -56,4 +59,14 @@ public Path getModsFolder() {
public boolean isModLoaded(String id) {
return ModList.get().isLoaded(id);
}

@Override
public Collection<String> getModIds() {
return ModList.get().getMods().stream().map(IModInfo::getModId).toList();
}

@Override
public Collection<? extends ModData> getMods() {
return ModList.get().getMods().stream().map(ModDataImpl::new).toList();
}
}
10 changes: 5 additions & 5 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pluginManagement {

rootProject.name = 'kessoku-lib'

include("fabric", "neo") // Loader: v1
include("base-common", "base-fabric", "base-neo") // Base: v1
include("event-base-common", "event-base-fabric", "event-base-neo") // Eventbase: v0
include("platform-common", "platform-fabric", "platform-neo") // Platform: v1
include("command-api-common", "command-api-fabric", "command-api-neo") // Command API: v0
include("fabric", "neo") // Bundle modules
include("base-common", "base-fabric", "base-neo") // Base
include("event-base-common", "event-base-fabric", "event-base-neo") // Event Base
include("platform-common", "platform-fabric", "platform-neo") // Platform
include("command-api-common", "command-api-fabric", "command-api-neo") // Command API

0 comments on commit 5e428ce

Please sign in to comment.