Skip to content

Commit

Permalink
Merge pull request #49 from Ender-Cube/no-non-polar
Browse files Browse the repository at this point in the history
Ignore non-polar worlds
  • Loading branch information
zax71 authored Mar 12, 2024
2 parents 8524562 + ee01e86 commit 80338f6
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class SpleefMinigame extends EndercubeMinigame {

Expand Down Expand Up @@ -98,6 +101,12 @@ protected ArrayList<InstanceContainer> initInstances() throws IOException {
continue;
}

// We only want to deal with polar files. Ignore everything else
if (!isPolar(worldFile.getName())) {
logger.trace("Skipped " + worldFile.getName() + " because it is not a polar world");
continue;
}

CommentedConfigurationNode configNode = config.node("maps", mapName);

// Load instance
Expand Down Expand Up @@ -154,4 +163,15 @@ private void checkMaxMin() {
MinecraftServer.stopCleanly();
}
}

private boolean isPolar(String file) {
Pattern pattern = Pattern.compile("\\.[0-9a-z]+$", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(file);

if (matcher.find()) {
return Objects.equals(matcher.group(), ".polar");
}

return false;
}
}

0 comments on commit 80338f6

Please sign in to comment.