Merge branch 'master' into master

This commit is contained in:
PiggyPiglet
2026-02-12 20:33:19 +08:00
committed by GitHub
8 changed files with 93 additions and 10 deletions
@@ -22,7 +22,6 @@ package me.clip.placeholderapi.replacer;
import java.util.Locale;
import java.util.function.Function;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
@@ -26,8 +26,8 @@ import java.net.URL;
import java.util.Arrays;
import javax.net.ssl.HttpsURLConnection;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.scheduler.scheduling.schedulers.TaskScheduler;
import me.clip.placeholderapi.util.Msg;
@@ -66,7 +66,7 @@ public class UpdateChecker implements Listener {
try {
HttpsURLConnection con = (HttpsURLConnection) new URL(MODRINTH_URL).openConnection();
con.setRequestMethod("GET");
final JsonElement json = JsonParser.parseReader(new BufferedReader(new InputStreamReader(con.getInputStream())));
final JsonElement json = new Gson().fromJson(new BufferedReader(new InputStreamReader(con.getInputStream())), JsonElement.class);
modrinthVersion = json.getAsJsonArray().get(0).getAsJsonObject().get("version_number").getAsString();
} catch (Exception ex) {
plugin.getLogger().info("Failed to check for updates on modrinth.");
@@ -55,9 +55,18 @@ public final class ExpansionSafetyCheck {
}
final Set<String> maliciousPaths = new HashSet<>();
final File[] files = expansionsFolder.listFiles();
for (File file : expansionsFolder.listFiles()) {
if (files == null) {
return false;
}
for (File file : files) {
try {
if (!file.isFile()) {
continue;
}
final String hash = Hashing.sha256().hashBytes(Files.asByteSource(file).read()).toString();
if (knownMaliciousExpansions.contains(hash)) {