Skip to content
Merged

Dev #58

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [26.1.2.3-beta]

### Fixed
* Updated FTB Ranks wiki URL in generated README file
* Reworked `RankCommandPredicate` to avoid stack overflow errors with certain modded command trees

## [26.1.2.2-beta]

### Fixed
Expand All @@ -15,7 +21,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Configs are no longer `SNBT` and are now `JSON5` instead.
* Anything previously using our `SNBT` format has now been moved to either `json` or in most cases `json5`.


## [26.1.2.1-beta]

### ⚠️ Breaking ⚠️
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import net.minecraft.server.level.ServerPlayer;
import org.jspecify.annotations.Nullable;

import java.util.HashSet;
import java.util.Set;
import java.util.function.Predicate;
import java.util.function.Supplier;

Expand All @@ -23,7 +25,19 @@ public RankCommandPredicate(CommandNode<CommandSourceStack> commandNode, String
}

public String getNodeName() {
return redirect == null ? nodeName : redirect.get().getNodeName();
Set<RankCommandPredicate> visited = new HashSet<>();
RankCommandPredicate currentNode = this;
while (visited.add(currentNode)) {
if (currentNode.redirect == null) {
return currentNode.nodeName;
}
RankCommandPredicate nextNode = currentNode.redirect.get();
if (nextNode == null) {
return currentNode.nodeName;
}
currentNode = nextNode;
}
return currentNode.nodeName;
}

public void setRedirect(Supplier<RankCommandPredicate> redirect) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public void reload() throws IOException {
}

Map<UUID, PlayerRankData> tempPlayerData = new LinkedHashMap<>();
var playerFileTag = Json5Util.tryRead(playerFile);
var playerFileTag = Json5Util.load(playerFile);
for (String key : playerFileTag.keySet()) {
var el = playerFileTag.get(key);
if (el.isJson5Object()) {
Expand All @@ -236,7 +236,7 @@ public void reload() throws IOException {

private void readRankFile(RankFileSource source, Map<String, RankImpl> rankMap) throws IOException {
Path inputFile = source.getPath(server);
Json5Object rankFileTag = Json5Util.tryRead(inputFile);
Json5Object rankFileTag = Json5Util.load(inputFile);
int size = rankMap.size();
for (String rankId : rankFileTag.keySet()) {
try {
Expand Down Expand Up @@ -326,12 +326,12 @@ void saveRanksNow() {
if (shouldSaveRanks) {
Map<RankFileSource, Json5Object> map = new EnumMap<>(RankFileSource.class);
for (RankImpl rank : ranks.values()) {
map.computeIfAbsent(rank.getSource(), k -> new Json5Object())
map.computeIfAbsent(rank.getSource(), _ -> new Json5Object())
.add(rank.getId(), rank.toJson());
}
map.forEach((source, json) -> {
try {
Json5Util.tryWrite(source.getPath(server), (Json5Element) json);
Json5Util.save(source.getPath(server), (Json5Element) json);
} catch (IOException e) {
FTBRanks.LOGGER.warn("Failed to save {}}! {} / {}", source.getPath(server), e.getClass().getName(), e.getMessage());
}
Expand All @@ -348,7 +348,7 @@ void savePlayersNow() {
}

try {
Json5Util.tryWrite(playerFile, (Json5Element) playerTag);
Json5Util.save(playerFile, (Json5Element) playerTag);
} catch (IOException e) {
FTBRanks.LOGGER.warn("Failed to save players.json5! {} / {}", e.getClass().getName(), e.getMessage());
}
Expand All @@ -373,17 +373,12 @@ static PermissionValue readPermissions(Json5Object json, String key) {

static Json5Object writePermissions(Map<String, PermissionValue> map, Json5Object res) {
map.forEach((key, value) -> {
/*if (value.isEmpty()) {
res.putNull(key);
} else*/ if (value instanceof BooleanPermissionValue b) {
res.addProperty(key, b.value);
} else if (value instanceof StringPermissionValue s) {
res.addProperty(key, s.value);
} else if (value instanceof NumberPermissionValue n) {
res.addProperty(key, n.value);
} else {
res.addProperty(key, value.asString().orElse(""));
}
switch (value) {
case BooleanPermissionValue b -> res.addProperty(key, b.value);
case StringPermissionValue s -> res.addProperty(key, s.value);
case NumberPermissionValue n -> res.addProperty(key, n.value);
default -> res.addProperty(key, value.asString().orElse(""));
}
});
return res;
}
Expand Down
18 changes: 9 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ supported_minecraft_versions=26.1,26.1.1,26.1.2
minecraft_version_range_maven=[26.1,27)
minecraft_version_range_semver=>=26.1.0

mod_version=2
mod_version=3
mod_author=FTB Team

# Deps
neoforge_version=26.1.2.7-beta
neoforge_version_range=[26.1.0.19-beta,27)
neoforge_version=26.1.2.71
neoforge_version_range=[26.1.0.71,27)
neoforge_loader_version=4

fabric_loader_version=0.18.4
fabric_api_version=0.144.0+26.1
fabric_api_version_range=>=0.144.0+26.1
fabric_loader_version=0.18.6
fabric_api_version=0.149.1+26.1.2
fabric_api_version_range=>=0.149.1+26.1.2

ftb_library_version=26.1.1.1
ftb_library_version_range_semver=>=26.1.1.1
ftb_library_version_range_maven=[26.1.1.1,27)
ftb_library_version=26.1.2.6
ftb_library_version_range_semver=>=26.1.2.1
ftb_library_version_range_maven=[26.1.2.1,27)

curseforge_id_forge=314905
curseforge_id_fabric=472659
2 changes: 1 addition & 1 deletion neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repositories {
}

dependencies {
api("dev.ftb.mods:ftb-library-neoforge:${rootProject.ftb_library_version}")
implementation("dev.ftb.mods:ftb-library-neoforge:${rootProject.ftb_library_version}")
}

jar {
Expand Down
Loading