Fix critical bugs and Caffeine ClassNotFoundException
- Disabled minimize in shadowJar (was removing Caffeine's dynamic classes) - Fixed Score.fromString() ArrayIndexOutOfBoundsException - Fixed Leaderboard DIFFICULTY sort NumberFormatException - Fixed PAPIHook parsing errors (difficulty, score_until, rank) - Fixed HoloHook parsing errors (rank, difficulty) - Added proper error handling for all Integer/Double.parseX() calls
This commit is contained in:
parent
5526910bef
commit
e5dd567ca9
5 changed files with 78 additions and 27 deletions
|
|
@ -113,11 +113,12 @@ tasks.shadowJar {
|
||||||
relocate("com.google.gson", "dev.loki.loparkour.lib.gson")
|
relocate("com.google.gson", "dev.loki.loparkour.lib.gson")
|
||||||
relocate("org.bstats", "dev.loki.loparkour.lib.bstats")
|
relocate("org.bstats", "dev.loki.loparkour.lib.bstats")
|
||||||
|
|
||||||
// Minimize jar size (keep JDBC pool + driver intact)
|
// Don't minimize - causes issues with Caffeine's dynamically generated classes
|
||||||
minimize {
|
// minimize {
|
||||||
exclude(dependency("com.zaxxer:HikariCP:.*"))
|
// exclude(dependency("com.zaxxer:HikariCP:.*"))
|
||||||
exclude(dependency("com.mysql:mysql-connector-j:.*"))
|
// exclude(dependency("com.mysql:mysql-connector-j:.*"))
|
||||||
}
|
// exclude(dependency(files("libs/lolib-3.0.0.jar")))
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named("build") {
|
tasks.named("build") {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,12 @@ public class HoloHook {
|
||||||
String type = split[1].toLowerCase();
|
String type = split[1].toLowerCase();
|
||||||
String rank = split[2].replace("#", "");
|
String rank = split[2].replace("#", "");
|
||||||
|
|
||||||
Score score = leaderboard.getScoreAtRank(Integer.parseInt(rank));
|
Score score;
|
||||||
|
try {
|
||||||
|
score = leaderboard.getScoreAtRank(Integer.parseInt(rank));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
|
|
||||||
if (score == null) {
|
if (score == null) {
|
||||||
return "?";
|
return "?";
|
||||||
|
|
@ -69,7 +74,15 @@ public class HoloHook {
|
||||||
return "?";
|
return "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
double difficulty = Double.parseDouble(string);
|
try {
|
||||||
|
double difficulty = Double.parseDouble(string);
|
||||||
|
return parseDifficultyValue(difficulty);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String parseDifficultyValue(double difficulty) {
|
||||||
if (difficulty <= 0.25) {
|
if (difficulty <= 0.25) {
|
||||||
return "easy";
|
return "easy";
|
||||||
} else if (difficulty <= 0.5) {
|
} else if (difficulty <= 0.5) {
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,17 @@ public class PAPIHook extends PlaceholderExpansion {
|
||||||
return getInfiniteScore(params.replace("difficulty_rank_", ""), Score::difficulty);
|
return getInfiniteScore(params.replace("difficulty_rank_", ""), Score::difficulty);
|
||||||
} else if (params.contains("difficulty_string_rank_")) {
|
} else if (params.contains("difficulty_string_rank_")) {
|
||||||
return getInfiniteScore(params.replace("difficulty_string_rank_", ""),
|
return getInfiniteScore(params.replace("difficulty_string_rank_", ""),
|
||||||
score -> parseDifficulty(Double.parseDouble(score.difficulty().contains("?") ? "2" : score.difficulty())));
|
score -> {
|
||||||
|
String diff = score.difficulty();
|
||||||
|
if ("?".equals(diff)) {
|
||||||
|
return parseDifficulty(2.0);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return parseDifficulty(Double.parseDouble(diff));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return parseDifficulty(2.0);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// placeholders that require player
|
// placeholders that require player
|
||||||
|
|
@ -132,10 +142,14 @@ public class PAPIHook extends PlaceholderExpansion {
|
||||||
default -> {
|
default -> {
|
||||||
if (params.contains("score_until_")) {
|
if (params.contains("score_until_")) {
|
||||||
String replaced = params.replace("score_until_", "");
|
String replaced = params.replace("score_until_", "");
|
||||||
int interval = Integer.parseInt(replaced);
|
try {
|
||||||
if (interval > 0) {
|
int interval = Integer.parseInt(replaced);
|
||||||
return Integer.toString(interval - (generator.state.score % interval));
|
if (interval > 0) {
|
||||||
} else {
|
return Integer.toString(interval - (generator.state.score % interval));
|
||||||
|
} else {
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -164,20 +178,24 @@ public class PAPIHook extends PlaceholderExpansion {
|
||||||
Leaderboard leaderboard = null;
|
Leaderboard leaderboard = null;
|
||||||
Matcher matcher = INFINITE_REGEX.matcher(rankData);
|
Matcher matcher = INFINITE_REGEX.matcher(rankData);
|
||||||
|
|
||||||
// use mode-specific format
|
try {
|
||||||
// x_mode_rank
|
// use mode-specific format
|
||||||
if (matcher.matches()) {
|
// x_mode_rank
|
||||||
String name = matcher.group(1);
|
if (matcher.matches()) {
|
||||||
rank = Integer.parseInt(matcher.group(2));
|
String name = matcher.group(1);
|
||||||
|
rank = Integer.parseInt(matcher.group(2));
|
||||||
|
|
||||||
Mode mode = Registry.getMode(name);
|
Mode mode = Registry.getMode(name);
|
||||||
if (mode != null) {
|
if (mode != null) {
|
||||||
leaderboard = mode.getLeaderboard();
|
leaderboard = mode.getLeaderboard();
|
||||||
|
}
|
||||||
|
// use generic format
|
||||||
|
// x_rank
|
||||||
|
} else {
|
||||||
|
rank = Integer.parseInt(rankData);
|
||||||
}
|
}
|
||||||
// use generic format
|
} catch (NumberFormatException e) {
|
||||||
// x_rank
|
return "?";
|
||||||
} else {
|
|
||||||
rank = Integer.parseInt(rankData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leaderboard == null) {
|
if (leaderboard == null) {
|
||||||
|
|
|
||||||
|
|
@ -114,8 +114,19 @@ public class Leaderboard {
|
||||||
return Integer.compare(one.getValue().getTimeMillis(), two.getValue().getTimeMillis());
|
return Integer.compare(one.getValue().getTimeMillis(), two.getValue().getTimeMillis());
|
||||||
}
|
}
|
||||||
case DIFFICULTY -> {
|
case DIFFICULTY -> {
|
||||||
return (int) Math.signum(Double.parseDouble(two.getValue().difficulty()) -
|
String diff1 = one.getValue().difficulty();
|
||||||
Double.parseDouble(one.getValue().difficulty()));
|
String diff2 = two.getValue().difficulty();
|
||||||
|
|
||||||
|
// Handle "?" as lowest difficulty
|
||||||
|
if ("?".equals(diff1) && "?".equals(diff2)) return 0;
|
||||||
|
if ("?".equals(diff1)) return 1;
|
||||||
|
if ("?".equals(diff2)) return -1;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return (int) Math.signum(Double.parseDouble(diff2) - Double.parseDouble(diff1));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
default -> throw new IllegalArgumentException("Invalid sort method");
|
default -> throw new IllegalArgumentException("Invalid sort method");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,15 @@ public record Score(String name, String time, String difficulty, int score) {
|
||||||
public static Score fromString(String string) {
|
public static Score fromString(String string) {
|
||||||
String[] parts = string.split(",");
|
String[] parts = string.split(",");
|
||||||
|
|
||||||
return new Score(parts[0], parts[1], parts[2], Integer.parseInt(parts[3]));
|
if (parts.length != 4) {
|
||||||
|
return new Score("?", "?", "?", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return new Score(parts[0], parts[1], parts[2], Integer.parseInt(parts[3]));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return new Score(parts[0], parts[1], parts[2], 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue