Skip to content

Commit

Permalink
LoaderOptions doesn't exist in 1.8.8
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Oct 4, 2022
1 parent 9c8e459 commit 13422a7
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/main/java/net/citizensnpcs/api/util/YamlStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.yaml.snakeyaml.LoaderOptions;

import com.google.common.io.Files;

Expand Down Expand Up @@ -119,11 +118,10 @@ public String toString() {
}

private void tryIncreaseMaxCodepoints(FileConfiguration config) {
if (LOADER_OPTIONS == null || SET_CODEPOINT_LIMIT == null)
if (SET_CODEPOINT_LIMIT == null || LOADER_OPTIONS == null)
return;
try {
LoaderOptions options = (LoaderOptions) LOADER_OPTIONS.get(config);
SET_CODEPOINT_LIMIT.invoke(options, 67108864 /* ~64MB, Paper's limit */);
SET_CODEPOINT_LIMIT.invoke(LOADER_OPTIONS.get(config), 67108864 /* ~64MB, Paper's limit */);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -344,12 +342,10 @@ public String toString() {
try {
LOADER_OPTIONS = YamlConfiguration.class.getDeclaredField("yamlLoaderOptions");
LOADER_OPTIONS.setAccessible(true);
} catch (Exception ex) {
}
try {
SET_CODEPOINT_LIMIT = LoaderOptions.class.getMethod("setCodepointLimit", int.class);
SET_CODEPOINT_LIMIT = Class.forName("org.yaml.snakeyaml.LoaderOptions").getMethod("setCodepointLimit",
int.class);
SET_CODEPOINT_LIMIT.setAccessible(true);
} catch (Exception ex) {
} catch (Exception e) {
}
}
}

0 comments on commit 13422a7

Please sign in to comment.