Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
Updating Konstruct
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkKronicle committed Jan 23, 2022
1 parent ccd46a7 commit cfcc43b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ archives_base_name=AdvancedChatCore

kommandlib_version=1.0.0-build1
malilib_version = 0.10.0-dev.26
konstruct_version=1.2.0-build1
konstruct_version=2.0.0-build1
mxparser_version=4.4.2
owo_version=2.0.0
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package io.github.darkkronicle.advancedchatcore.util;

import io.github.darkkronicle.Konstruct.*;
import io.github.darkkronicle.Konstruct.builder.NodeBuilder;
import io.github.darkkronicle.Konstruct.functions.Function;
import io.github.darkkronicle.Konstruct.functions.NamedFunction;
import io.github.darkkronicle.Konstruct.functions.Variable;
import io.github.darkkronicle.Konstruct.nodes.Node;
import io.github.darkkronicle.Konstruct.parser.*;
import io.github.darkkronicle.Konstruct.reader.builder.NodeBuilder;
import io.github.darkkronicle.Konstruct.type.IntegerObject;
import io.github.darkkronicle.Konstruct.type.StringObject;
import io.github.darkkronicle.addons.*;
import io.github.darkkronicle.addons.conditions.BooleanFunction;
import io.github.darkkronicle.advancedchatcore.AdvancedChatCore;
import lombok.Getter;
import net.minecraft.util.Util;

import java.util.List;
import java.util.Optional;

public class AdvancedChatKonstruct {

Expand All @@ -36,9 +36,8 @@ private AdvancedChatKonstruct() {
addFunction(new OwOFunction());
addFunction(new RomanNumeralFunction());
addFunction(new IsMatchFunction());
BooleanFunction.addAllConditionalFunctions(processor);
addFunction(new TimeFunction());
addVariable("server", AdvancedChatCore::getServer);
addVariable("server", () -> new StringObject(AdvancedChatCore.getServer()));
addFunction("randomString", new Function() {
@Override
public Result parse(ParseContext context, List<Node> input) {
Expand All @@ -55,7 +54,7 @@ public IntRange getArgumentCount() {
public Result parse(ParseContext context, List<Node> input) {
Result res = Function.parseArgument(context, input, 0);
if (Function.shouldReturn(res)) return res;
Color color = Colors.getInstance().getColorOrWhite(res.getContent());
Color color = Colors.getInstance().getColorOrWhite(res.getContent().getString());
return Result.success(color.getString());
}

Expand All @@ -71,7 +70,7 @@ public Result parse(ParseContext context, List<Node> input) {
try {
Result res = Function.parseArgument(context, input, 0);
if (Function.shouldReturn(res)) return res;
number = Integer.parseInt(res.getContent().strip());
number = Integer.parseInt(res.getContent().getString().strip());
} catch (NumberFormatException e) {
return Result.success("NaN");
}
Expand All @@ -83,7 +82,7 @@ public IntRange getArgumentCount() {
return IntRange.of(1);
}
});
addVariable("ms", () -> String.valueOf(Util.getMeasuringTimeMs()));
addVariable("ms", () -> new IntegerObject((int) Util.getMeasuringTimeMs()));
}

public ParseResult parse(Node node) {
Expand Down

0 comments on commit cfcc43b

Please sign in to comment.