From 69993536e5f63a9b4654145df94cb3f18d865075 Mon Sep 17 00:00:00 2001
From: Flowsqy <47575244+Flowsqy@users.noreply.github.com>
Date: Wed, 23 Feb 2022 15:42:53 +0100
Subject: [PATCH] Add logic check
---
.../config/hologram/parser/FormatParser.java | 63 ++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)
diff --git a/plugin/src/main/java/de/epiceric/shopchest/config/hologram/parser/FormatParser.java b/plugin/src/main/java/de/epiceric/shopchest/config/hologram/parser/FormatParser.java
index d84151f..7745a9d 100644
--- a/plugin/src/main/java/de/epiceric/shopchest/config/hologram/parser/FormatParser.java
+++ b/plugin/src/main/java/de/epiceric/shopchest/config/hologram/parser/FormatParser.java
@@ -215,6 +215,9 @@ public class FormatParser {
public
Token> createFunctions(Iterable> tokens, Function providerFunction, Map> providerTypes) {
Chain> tokensChain = Chain.getChain(tokens);
+ if (tokensChain == null) {
+ return null;
+ }
// Node
Chain> nodeChain = tokensChain;
@@ -496,7 +499,65 @@ public class FormatParser {
equalityChain = equalityChain.getAfter();
}
- return tokensChain == null ? null : tokensChain.getValue();
+ // Logic operator
+ Chain> logicChain = tokensChain;
+ while (logicChain != null) {
+ final Token> token = logicChain.getValue();
+ // Operator check
+ if (token.getType() == Token.LOGIC_OPERATOR) {
+ final Chain> previousChain = logicChain.getBefore();
+ final Chain> nextChain = logicChain.getAfter();
+ // First member does not exist
+ if (previousChain == null) {
+ throw new RuntimeException("Try to apply a logic operator without first member");
+ }
+ // Second member does not exist
+ if (nextChain == null) {
+ throw new RuntimeException("Try to apply a logic operator without second member");
+ }
+ // Get First member
+ final Condition