Skip to content

Commit

Permalink
Set displayTest property for SpongeForge and for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeregorix committed Nov 3, 2023
1 parent 50d9324 commit 9320a50
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,14 @@ public <T> Optional<T> getConfigElement(final String... key) {
return Optional.empty();
}

final String query = key[0];
if ("modId".equals(query)) {
return (Optional<T>) Optional.of(this.dependency.id());
}
if ("mandatory".equals(query)) {
return (Optional<T>) Optional.of(!this.dependency.optional());
}
if ("versionRange".equals(query)) {
return (Optional<T>) Optional.of(this.dependency.version().toString());
}
if ("ordering".equals(query)) {
return (Optional<T>) Optional.of(this.loadToOrdering(this.dependency.loadOrder()).toString());
}
if ("side".equals(query)) {
return (Optional<T>) Optional.of(IModInfo.DependencySide.BOTH.toString());
}
return Optional.empty();
return switch (key[0]) {
case "modId" -> (Optional<T>) Optional.of(this.dependency.id());
case "mandatory" -> (Optional<T>) Optional.of(!this.dependency.optional());
case "versionRange" -> (Optional<T>) Optional.of(this.dependency.version().toString());
case "ordering" -> (Optional<T>) Optional.of(this.loadToOrdering(this.dependency.loadOrder()).toString());
case "side" -> (Optional<T>) Optional.of(IModInfo.DependencySide.BOTH.toString());
default -> Optional.empty();
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,15 @@ public <T> Optional<T> getConfigElement(final String... key) {
if (key.length != 1) {
return Optional.empty();
}
final String query = key[0];
if ("modId".equals(query)) {
return Optional.of((T) this.metadata.id());
}
if ("version".equals(query)) {
return Optional.of((T) this.metadata.version().toString());
}
if ("displayName".equals(query)) {
return (Optional<T>) this.metadata.name();
}
if ("description".equals(query)) {
return (Optional<T>) this.metadata.description();
}
return Optional.empty();

return switch (key[0]) {
case "modId" -> Optional.of((T) this.metadata.id());
case "version" -> Optional.of((T) this.metadata.version().toString());
case "displayName" -> (Optional<T>) this.metadata.name();
case "description" -> (Optional<T>) this.metadata.description();
case "displayTest" -> Optional.of((T) "IGNORE_SERVER_VERSION");
default -> Optional.empty();
};
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions forge/src/main/resourceTemplates/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ issueTrackerURL="https://github.com/SpongePowered/Sponge/issues"
modId="spongeforge"
version="${version}"
displayName="SpongeForge"
displayTest="IGNORE_SERVER_VERSION"
credits="SpongePowered and Contributors"
authors="SpongePowered"
description = "${description}"
Expand All @@ -32,6 +33,7 @@ side="BOTH"
modId="sponge"
version="${version}"
displayName="Sponge"
displayTest="IGNORE_SERVER_VERSION"
credits="SpongePowered and Contributors"
authors="SpongePowered"
description="The SpongeAPI implementation targeting vanilla Minecraft and 3rd party platforms"
Expand All @@ -48,6 +50,7 @@ side="BOTH"
modId="spongeapi"
version="10.0.0"
displayName="SpongeAPI"
displayTest="IGNORE_SERVER_VERSION"
credits="SpongePowered and Contributors"
authors="SpongePowered"
description="A Minecraft plugin API"

0 comments on commit 9320a50

Please sign in to comment.