Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Efnilite committed Nov 27, 2024
1 parent 5a0c42c commit 081c8c8
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 125 deletions.
8 changes: 5 additions & 3 deletions src/main/java/ch/njol/skript/SkriptConfig.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package ch.njol.skript;

import ch.njol.skript.config.*;
import ch.njol.skript.config.Config;
import ch.njol.skript.config.EnumParser;
import ch.njol.skript.config.Option;
import ch.njol.skript.config.OptionSection;
import ch.njol.skript.hooks.Hook;
import ch.njol.skript.hooks.VaultHook;
import ch.njol.skript.hooks.regions.GriefPreventionHook;
Expand Down Expand Up @@ -328,8 +331,7 @@ private static void userDisableHooks(Class<? extends Hook<?>> hookClass, boolean
/**
* This should only be used in special cases
*/
@Nullable
public static Config getConfig() {
public static @Nullable Config getConfig() {
return mainConfig;
}

Expand Down
42 changes: 20 additions & 22 deletions src/main/java/ch/njol/skript/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,33 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

/**
* Represents a config file.
*/
public class Config implements Comparable<Config> {

boolean simple;

/**
* One level of the indentation, e.g. a tab or 4 spaces.
*/
private String indentation = "\t";

/**
* The indentation's name, i.e. 'tab' or 'space'.
*/
private String indentationName = "tab";

private final SectionNode main;

final String defaultSeparator;
String separator;

boolean simple;
int level = 0;

private final SectionNode main;

int errors = 0;

final boolean allowEmptySections;

String fileName;
Expand Down Expand Up @@ -329,14 +329,14 @@ public boolean isEmpty() {
* @return The file this config was loaded from, or null if it was loaded from an InputStream.
*/
public @Nullable File getFile() {
if (file != null) {
try {
return file.toFile();
} catch (Exception e) {
return null; // ZipPath, for example, throws undocumented exception
}
if (file == null)
return null;

try {
return file.toFile();
} catch (Exception e) {
return null; // ZipPath, for example, throws undocumented exception
}
return null;
}

/**
Expand All @@ -354,29 +354,27 @@ public String getSeparator() {
}

/**
* @return A separator string useful for saving, e.g. ": " or " = ".
* @return A separator string useful for saving, e.g. ": ".
*/
public String getSaveSeparator() {
if (separator.equals(":"))
return ": ";
if (separator.equals("="))
return " = ";
return " " + separator + " ";
}

String getIndentation() {
@NotNull String getIndentation() {
return indentation;
}

String getIndentationName() {
@NotNull String getIndentationName() {
return indentationName;
}

public SectionNode getMainNode() {
public @NotNull SectionNode getMainNode() {
return main;
}

public String getFileName() {
public @NotNull String getFileName() {
return fileName;
}

Expand Down
Loading

0 comments on commit 081c8c8

Please sign in to comment.