Skip to content

Commit

Permalink
Clean up post-merge files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Moderocky committed Dec 31, 2024
1 parent 2edaf61 commit ea4f67c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
12 changes: 6 additions & 6 deletions src/main/java/ch/njol/skript/SkriptConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static EventRegistry<Event> eventRegistry() {
Skript.error("No language file found for '" + s + "'!");
}
});

public static final Option<Boolean> checkForNewVersion = new Option<>("check for new version", false)
.setter(t -> {
SkriptUpdater updater = Skript.getInstance().getUpdater();
Expand Down Expand Up @@ -170,7 +170,7 @@ public static String formatDate(final long timestamp) {
return "" + f.format(timestamp);
}
}

public static final Option<Verbosity> verbosity = new Option<>("verbosity", Verbosity.NORMAL, new EnumParser<>(Verbosity.class, "verbosity"))
.setter(SkriptLogger::setVerbosity);

Expand All @@ -189,7 +189,7 @@ public static String formatDate(final long timestamp) {
public static final Option<Boolean> listenCancelledByDefault = new Option<>("listen to cancelled events by default", false)
.optional(true);


/**
* Maximum number of digits to display after the period for floats and doubles
*/
Expand All @@ -206,7 +206,7 @@ public static String formatDate(final long timestamp) {
public static final Option<Boolean> disableVariableStartingWithExpressionWarnings =
new Option<>("disable starting a variable's name with an expression warnings", false);
public static final Option<Boolean> disableUnreachableCodeWarnings = new Option<>("disable unreachable code warnings", false);

@Deprecated
public static final Option<Boolean> enableScriptCaching = new Option<>("enable script caching", false)
.optional(true);
Expand Down Expand Up @@ -368,7 +368,7 @@ private static void userDisableHooks(Class<? extends Hook<?>> hookClass, boolean
}

// also used for reloading
static boolean load() {
static void load() {
if (mainConfig != null)
mainConfig.invalidate(); // todo
try {
Expand All @@ -392,7 +392,7 @@ static boolean load() {
}
SkriptConfig.mainConfig = mainConfig;

String configVersion = mainConfig.get(version.key);
String configVersion = mainConfig.getValue(version.key);
if (configVersion == null || Skript.getVersion().compareTo(new Version(configVersion)) != 0) {
if (!mainConfig.getMainNode().isValid()) {
Skript.error("Your config is outdated, but cannot be updated because it contains errors.");
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/ch/njol/skript/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
/**
* Represents a config file.
*/
public class Config implements Comparable<Config>, Validated {
public class Config implements Comparable<Config>, AnyNamed {
public class Config implements Comparable<Config>, Validated, NodeNavigator {
public class Config implements Comparable<Config>, Validated, NodeNavigator, AnyNamed {

/**
* One level of the indentation, e.g. a tab or 4 spaces.
Expand Down Expand Up @@ -234,7 +232,7 @@ public boolean updateNodes(@NotNull Config newer) {
SectionNode newParent = node.getParent();
Preconditions.checkNotNull(newParent);

SectionNode parent = getNode(newParent.getPath());
SectionNode parent = getNode(newParent.getPathSteps());
Preconditions.checkNotNull(parent);

int index = node.getIndex();
Expand Down
26 changes: 10 additions & 16 deletions src/main/java/ch/njol/skript/config/Node.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
package ch.njol.skript.config;

import java.io.PrintWriter;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import ch.njol.skript.SkriptConfig;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;

import ch.njol.skript.Skript;
import ch.njol.skript.lang.util.common.AnyNamed;
import ch.njol.skript.log.SkriptLogger;
import ch.njol.util.NonNullPair;
import ch.njol.util.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.skriptlang.skript.util.Validated;

import java.io.PrintWriter;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Pattern;

/**
* @author Peter Güttinger
*/
public abstract class Node implements AnyNamed {
public abstract class Node implements Validated, NodeNavigator {
public abstract class Node implements AnyNamed, Validated, NodeNavigator {

@Nullable
protected String key;
Expand Down Expand Up @@ -468,7 +461,8 @@ int getIndex() {
}

/**
* Returns the path to this node in the config file from the root.
* Returns the node names in the path to this node from the config root.
* If this is not a section node, returns the path to its parent node.
*
* <p>
* Getting the path of node {@code z} in the following example would
Expand All @@ -481,7 +475,7 @@ int getIndex() {
*
* @return The path to this node in the config file.
*/
public @NotNull String[] getPath() {
public @NotNull String[] getPathSteps() {
List<String> path = new ArrayList<>();
Node node = this;

Expand All @@ -503,7 +497,7 @@ int getIndex() {
}

@Override
public @UnknownNullability String name() {
public @Nullable String name() {
return this.getKey();
}

Expand All @@ -512,13 +506,13 @@ public boolean equals(Object object) {
if (!(object instanceof Node other))
return false;

return Arrays.equals(getPath(), other.getPath()) // for entry/section nodes
return Arrays.equals(this.getPathSteps(), other.getPathSteps()) // for entry/section nodes
&& Objects.equals(comment, other.comment); // for void nodes
}

@Override
public int hashCode() {
return Objects.hash(Arrays.hashCode(getPath()), comment);
return Objects.hash(Arrays.hashCode(this.getPathSteps()), comment);
}

}
8 changes: 6 additions & 2 deletions src/main/java/ch/njol/skript/expressions/ExprNodeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.lang.reflect.Array;

@Name("Value (Experimental)")
@Description({
"Returns the value of a node in a loaded config.",
Expand Down Expand Up @@ -112,7 +114,9 @@ protected Object[] get(Event event, Node[] source) {
if (pathExpression != null) {
String path = pathExpression.getSingle(event);
Node node = source[0].getNodeAt(path);
return CollectionUtils.array(this.convert(node));
Object[] array = (Object[]) Array.newInstance(this.getReturnType(), 1);
array[0] = this.convert(node);
return array;
}
return super.get(source, this);
}
Expand All @@ -124,7 +128,7 @@ protected Object[] get(Event event, Node[] source) {

@Override
public Class<?> getReturnType() {
return Object.class;
return classInfo.getC();
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/test/skript/tests/syntaxes/expressions/ExprName.sk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ test "config name (new)":
test "node name (new)":
set {_node} to the current script
set {_node} to the first element of nodes of {_node}
assert name of {_node} is "using script reflection" with "first node name was wrong"
assert name of {_node} is "test ""name of world""" with "first node name was wrong"

set {_node} to the current script
set {_node} to the 4th element of nodes of {_node} # Obviously, this changes if this file changes
assert name of {_node} is "using script reflection" with "4th node name was wrong"

# root node
set {_node} to the skript config
Expand Down

0 comments on commit ea4f67c

Please sign in to comment.