Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public void setPatternId(@Nullable ResourceLocation patternId) {
}

@Nullable
@Override
public ResourceLocation getPatternId() {
return this.patternId;
}
Expand All @@ -125,10 +126,12 @@ public void refreshPattern() {
}

@Nullable
@Override
public AbyssTrialSpawnerPattern getPattern() {
return this.cachedPattern;
}

@Override
public boolean hasValidPattern() {
return this.cachedPattern != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public AbyssTrialSpawnerManager() {
var fixedLoc = ResourceLocation.fromNamespaceAndPath(namespace, parts[0]);
var res = entry.getValue();

try (var stream = res.open()) {
var json = GsonHelper.fromJson(GSON, new InputStreamReader(stream), JsonElement.class);
try (var stream = res.open(); var reader = new InputStreamReader(stream)) {
var json = GsonHelper.fromJson(GSON, reader, JsonElement.class);
result.put(fixedLoc, json);
} catch (IOException | JsonParseException e) {
LOGGER.error("Failed to load trial spawner JSON from {}", fileLoc, e);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/altnoir/mia/util/MiaUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ public static boolean isCreativeOrSpectator(Player player) {
return null;
}

// Ensure there is at least one character after basePath before substring
if (filePath.length() <= basePath.length()) {
return null;
}

var trimmedPath = filePath.substring(basePath.length() + 1);
if (trimmedPath.endsWith(".json")) {
trimmedPath = trimmedPath.substring(0, trimmedPath.length() - 5);
Expand Down