diff --git a/.idea/dictionaries/moritz.xml b/.idea/dictionaries/moritz.xml
index ab347f524..43531182f 100644
--- a/.idea/dictionaries/moritz.xml
+++ b/.idea/dictionaries/moritz.xml
@@ -159,6 +159,7 @@
strad
straymeow
stutterturn
+ summonable
suspiciousstew
sweepattack
takepotion
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/CommandArgumentNode.java b/src/main/java/de/bixilon/minosoft/data/commands/CommandArgumentNode.java
index df539a06f..9087c06aa 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/CommandArgumentNode.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/CommandArgumentNode.java
@@ -14,6 +14,7 @@
package de.bixilon.minosoft.data.commands;
import de.bixilon.minosoft.data.commands.parser.CommandParser;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.util.BitByte;
@@ -59,11 +60,9 @@ public class CommandArgumentNode extends CommandLiteralNode {
}
@Override
- public boolean isSyntaxCorrect(ImprovedStringReader stringReader) {
- if (parser.isParsable(properties, stringReader)) {
- return super.isSyntaxCorrect(stringReader);
- }
- return false;
+ public void isSyntaxCorrect(ImprovedStringReader stringReader) throws CommandParseException {
+ parser.isParsable(properties, stringReader);
+ super.isSyntaxCorrect(stringReader);
}
public enum SuggestionTypes {
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/CommandNode.java b/src/main/java/de/bixilon/minosoft/data/commands/CommandNode.java
index 1a0b93d06..cd6a4eda6 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/CommandNode.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/CommandNode.java
@@ -14,6 +14,9 @@
package de.bixilon.minosoft.data.commands;
import com.google.errorprone.annotations.DoNotCall;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.data.commands.parser.exception.RequiresMoreArgumentsCommandParseException;
+import de.bixilon.minosoft.data.commands.parser.exception.WrongArgumentCommandParseException;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition;
import de.bixilon.minosoft.util.BitByte;
@@ -74,30 +77,42 @@ public abstract class CommandNode {
return childrenIds;
}
- public boolean isSyntaxCorrect(ImprovedStringReader stringReader) {
+ public void isSyntaxCorrect(ImprovedStringReader stringReader) throws CommandParseException {
String nextArgument = stringReader.getUntilNextCommandArgument();
if (nextArgument.length() == 0) {
- return isExecutable;
+ if (isExecutable) {
+ return;
+ }
+ throw new RequiresMoreArgumentsCommandParseException(stringReader);
}
if (literalChildren.containsKey(nextArgument)) {
stringReader.skip(nextArgument.length() + ProtocolDefinition.COMMAND_SEPARATOR.length());
- return literalChildren.get(nextArgument).isSyntaxCorrect(stringReader);
+ literalChildren.get(nextArgument).isSyntaxCorrect(stringReader);
+ return;
}
+ CommandParseException lastException = null;
for (CommandArgumentNode argumentNode : argumentsChildren) {
int currentPosition = stringReader.getPosition();
- if (argumentNode.isSyntaxCorrect(stringReader)) {
- return true;
+ try {
+ argumentNode.isSyntaxCorrect(stringReader);
+ return;
+ } catch (CommandParseException e) {
+ lastException = e;
}
stringReader.setPosition(currentPosition);
}
- return false;
+ if (lastException != null) {
+ throw lastException;
+ }
+ stringReader.skip(nextArgument.length());
+ throw new WrongArgumentCommandParseException(stringReader, nextArgument);
}
- public boolean isSyntaxCorrect(String string) {
+ public void isSyntaxCorrect(String string) throws CommandParseException {
// replace multiple spaces with nothing
string = string.replaceAll("\\s{2,}", " ");
ImprovedStringReader stringReader = new ImprovedStringReader(string);
- return isSyntaxCorrect(stringReader);
+ isSyntaxCorrect(stringReader);
}
public enum NodeTypes {
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/CommandRootNode.java b/src/main/java/de/bixilon/minosoft/data/commands/CommandRootNode.java
index 70d7ab123..618c11046 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/CommandRootNode.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/CommandRootNode.java
@@ -13,10 +13,27 @@
package de.bixilon.minosoft.data.commands;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.data.commands.parser.exception.UnknownCommandParseException;
+import de.bixilon.minosoft.data.commands.parser.exception.WrongArgumentCommandParseException;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
public class CommandRootNode extends CommandNode {
public CommandRootNode(byte flags, InByteBuffer buffer) {
super(flags, buffer);
}
+
+ @Override
+ public void isSyntaxCorrect(ImprovedStringReader stringReader) throws CommandParseException {
+ try {
+ super.isSyntaxCorrect(stringReader);
+ } catch (WrongArgumentCommandParseException e) {
+ if (e.getStartIndex() == 0) {
+ // beginn of string
+ throw new UnknownCommandParseException(stringReader, stringReader.getString().substring(0, e.getEndIndex()));
+ }
+ throw e;
+ }
+ }
}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/BooleanParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/BooleanParser.java
index da45bae6b..80117af5d 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/parser/BooleanParser.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/BooleanParser.java
@@ -13,6 +13,8 @@
package de.bixilon.minosoft.data.commands.parser;
+import de.bixilon.minosoft.data.commands.parser.exception.BooleanCommandParseException;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties;
import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
@@ -22,8 +24,10 @@ public class BooleanParser extends CommandParser {
public static final BooleanParser BOOLEAN_PARSER = new BooleanParser();
@Override
- public boolean isParsable(@Nullable ParserProperties properties, ImprovedStringReader stringReader) {
+ public void isParsable(@Nullable ParserProperties properties, ImprovedStringReader stringReader) throws CommandParseException {
String argument = stringReader.readUntilNextCommandArgument();
- return argument.equals("true") || argument.equals("false");
+ if (!argument.equals("true") && !argument.equals("false")) {
+ throw new BooleanCommandParseException(stringReader, argument);
+ }
}
}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/CommandParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/CommandParser.java
index 1705fe451..e8f29cea1 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/parser/CommandParser.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/CommandParser.java
@@ -14,6 +14,7 @@
package de.bixilon.minosoft.data.commands.parser;
import com.google.common.collect.HashBiMap;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties;
import de.bixilon.minosoft.data.mappings.ModIdentifier;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
@@ -45,6 +46,6 @@ public abstract class CommandParser {
return null;
}
- public abstract boolean isParsable(@Nullable ParserProperties properties, ImprovedStringReader stringReader);
+ public abstract void isParsable(@Nullable ParserProperties properties, ImprovedStringReader stringReader) throws CommandParseException;
}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/DoubleParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/DoubleParser.java
index a539ce44a..dcdd71274 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/parser/DoubleParser.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/DoubleParser.java
@@ -13,6 +13,9 @@
package de.bixilon.minosoft.data.commands.parser;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.data.commands.parser.exception.number.DoubleCommandParseException;
+import de.bixilon.minosoft.data.commands.parser.exception.number.ValueOutOfRangeCommandParseException;
import de.bixilon.minosoft.data.commands.parser.properties.DoubleParserProperties;
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
@@ -31,12 +34,16 @@ public class DoubleParser extends CommandParser {
}
@Override
- public boolean isParsable(ParserProperties properties, ImprovedStringReader stringReader) {
+ public void isParsable(ParserProperties properties, ImprovedStringReader stringReader) throws CommandParseException {
String argument = stringReader.readUntilNextCommandArgument();
try {
- return isValidValue((DoubleParserProperties) properties, Double.parseDouble(argument));
- } catch (Exception ignored) {
- return false;
+ double value = Double.parseDouble(argument);
+ DoubleParserProperties doubleParserProperties = (DoubleParserProperties) properties;
+ if (value < doubleParserProperties.getMinValue() && value > doubleParserProperties.getMaxValue()) {
+ throw new ValueOutOfRangeCommandParseException(stringReader, doubleParserProperties.getMinValue(), doubleParserProperties.getMaxValue(), value);
+ }
+ } catch (NumberFormatException exception) {
+ throw new DoubleCommandParseException(stringReader, argument, exception);
}
}
}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/DummyParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/DummyParser.java
index 492ae57be..349b20202 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/parser/DummyParser.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/DummyParser.java
@@ -13,6 +13,7 @@
package de.bixilon.minosoft.data.commands.parser;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties;
import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
@@ -23,7 +24,6 @@ public class DummyParser extends CommandParser {
public static final DummyParser DUMMY_PARSER = new DummyParser();
@Override
- public boolean isParsable(@Nullable ParserProperties properties, ImprovedStringReader stringReader) {
- return true;
+ public void isParsable(@Nullable ParserProperties properties, ImprovedStringReader stringReader) throws CommandParseException {
}
}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/EntityParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/EntityParser.java
index 2b35cd053..9701659d0 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/parser/EntityParser.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/EntityParser.java
@@ -14,7 +14,10 @@
package de.bixilon.minosoft.data.commands.parser;
import de.bixilon.minosoft.data.commands.parser.entity.EntitySelectorArgumentParser;
-import de.bixilon.minosoft.data.commands.parser.entity.NameEntitySelectorArgumentParser;
+import de.bixilon.minosoft.data.commands.parser.entity.IntegerSelectorArgumentParser;
+import de.bixilon.minosoft.data.commands.parser.entity.StringSelectorArgumentParser;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.data.commands.parser.exception.entity.*;
import de.bixilon.minosoft.data.commands.parser.properties.EntityParserProperties;
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
@@ -39,17 +42,17 @@ public class EntityParser extends CommandParser {
ENTITY_FILTER_PARAMETER_LIST.put("dz", null);
ENTITY_FILTER_PARAMETER_LIST.put("gamemode", null);
ENTITY_FILTER_PARAMETER_LIST.put("level", null);
- ENTITY_FILTER_PARAMETER_LIST.put("limit", null);
*/
- ENTITY_FILTER_PARAMETER_LIST.put("name", NameEntitySelectorArgumentParser.NAME_ENTITY_SELECTOR_ARGUMENT_PARSER);
+ ENTITY_FILTER_PARAMETER_LIST.put("name", StringSelectorArgumentParser.STRING_SELECTOR_ARGUMENT_PARSER);
+ ENTITY_FILTER_PARAMETER_LIST.put("team", StringSelectorArgumentParser.STRING_SELECTOR_ARGUMENT_PARSER);
+ ENTITY_FILTER_PARAMETER_LIST.put("limit", IntegerSelectorArgumentParser.INTEGER_SELECTOR_ARGUMENT_PARSER);
/*
ENTITY_FILTER_PARAMETER_LIST.put("nbt", null);
ENTITY_FILTER_PARAMETER_LIST.put("predicate", null);
ENTITY_FILTER_PARAMETER_LIST.put("scores", null);
ENTITY_FILTER_PARAMETER_LIST.put("sort", null);
ENTITY_FILTER_PARAMETER_LIST.put("tag", null);
- ENTITY_FILTER_PARAMETER_LIST.put("team", null);
ENTITY_FILTER_PARAMETER_LIST.put("x", null);
ENTITY_FILTER_PARAMETER_LIST.put("x_rotation", null);
ENTITY_FILTER_PARAMETER_LIST.put("y", null);
@@ -65,17 +68,18 @@ public class EntityParser extends CommandParser {
}
@Override
- public boolean isParsable(ParserProperties properties, ImprovedStringReader stringReader) {
+ public void isParsable(ParserProperties properties, ImprovedStringReader stringReader) throws CommandParseException {
+ EntityParserProperties entityParserProperties = (EntityParserProperties) properties;
if (stringReader.getChar().equals("@")) {
// selector
- if (((EntityParserProperties) properties).isOnlySingleEntity()) {
- return false;
+ if (entityParserProperties.isOnlySingleEntity()) {
+ throw new SingleEntityOnlyEntityCommandParseException(stringReader, stringReader.getChar());
}
stringReader.skip(1); // skip @
String selectorChar = stringReader.readChar();
if (!selectorChar.equals("a") && !selectorChar.equals("e") && !selectorChar.equals("p") && !selectorChar.equals("r") && !selectorChar.equals("s")) {
// only @a, @e, @p, @r and @s possible
- return false;
+ throw new UnknownMassSelectorEntityCommandParseException(stringReader, stringReader.getChar());
}
// parse entity selector
@@ -83,7 +87,7 @@ public class EntityParser extends CommandParser {
// example: /msg @a[ name = "Bixilon" ] asd
if (!stringReader.getChar().equals("[")) {
// no meta data given, valid
- return true;
+ return;
}
stringReader.skip(1);
@@ -91,20 +95,19 @@ public class EntityParser extends CommandParser {
HashSet parameters = new HashSet<>();
while (true) {
stringReader.skipSpaces();
- String parameterName = stringReader.readUntil("=").key.replaceAll("\\s", "");
+ String parameterName = stringReader.readUntil("=").key.replaceAll("\\s", ""); // ToDo: only remove prefix and suffix spaces!
if (parameters.contains(parameterName)) {
- return false;
+ throw new DuplicatedParameterEntityCommandParseException(stringReader, parameterName);
}
if (!ENTITY_FILTER_PARAMETER_LIST.containsKey(parameterName)) {
- return false;
+ throw new UnknownParameterEntityCommandParseException(stringReader, parameterName);
}
stringReader.skipSpaces();
EntitySelectorArgumentParser parser = ENTITY_FILTER_PARAMETER_LIST.get(parameterName);
- if (!parser.isParsable(stringReader)) {
- return false;
- }
+ parser.isParsable(stringReader);
+
stringReader.skipSpaces();
parameters.add(parameterName);
String nextChar = stringReader.getChar();
@@ -117,20 +120,20 @@ public class EntityParser extends CommandParser {
}
}
stringReader.skipSpaces();
- return true;
+ return;
}
String value = stringReader.readUntilNextCommandArgument();
if (ProtocolDefinition.MINECRAFT_NAME_VALIDATOR.matcher(value).matches()) {
- return true;
+ return;
}
- if (((EntityParserProperties) properties).isOnlyPlayers()) {
- return false;
+ if (entityParserProperties.isOnlyPlayers()) {
+ throw new PlayerOnlyEntityCommandParseException(stringReader, value);
}
try {
Util.getUUIDFromString(value);
- return true;
+ return;
} catch (Exception ignored) {
}
- return false;
+ throw new UnknownEntitySelectorCommandParseException(stringReader, value);
}
}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/FloatParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/FloatParser.java
index 91ff32a07..92a79990a 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/parser/FloatParser.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/FloatParser.java
@@ -13,6 +13,9 @@
package de.bixilon.minosoft.data.commands.parser;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.data.commands.parser.exception.number.FloatCommandParseException;
+import de.bixilon.minosoft.data.commands.parser.exception.number.ValueOutOfRangeCommandParseException;
import de.bixilon.minosoft.data.commands.parser.properties.FloatParserProperties;
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
@@ -21,9 +24,6 @@ import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
public class FloatParser extends CommandParser {
public static final FloatParser FLOAT_PARSER = new FloatParser();
- public boolean isValidValue(FloatParserProperties properties, float value) {
- return value >= properties.getMinValue() && value <= properties.getMaxValue();
- }
@Override
public ParserProperties readParserProperties(InByteBuffer buffer) {
@@ -31,12 +31,16 @@ public class FloatParser extends CommandParser {
}
@Override
- public boolean isParsable(ParserProperties properties, ImprovedStringReader stringReader) {
+ public void isParsable(ParserProperties properties, ImprovedStringReader stringReader) throws CommandParseException {
String argument = stringReader.readUntilNextCommandArgument();
try {
- return isValidValue((FloatParserProperties) properties, Float.parseFloat(argument));
- } catch (Exception ignored) {
- return false;
+ float value = Float.parseFloat(argument);
+ FloatParserProperties floatParserProperties = (FloatParserProperties) properties;
+ if (value < floatParserProperties.getMinValue() && value > floatParserProperties.getMaxValue()) {
+ throw new ValueOutOfRangeCommandParseException(stringReader, floatParserProperties.getMinValue(), floatParserProperties.getMaxValue(), value);
+ }
+ } catch (NumberFormatException exception) {
+ throw new FloatCommandParseException(stringReader, argument, exception);
}
}
}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/IntegerParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/IntegerParser.java
index b158480f7..79153d065 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/parser/IntegerParser.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/IntegerParser.java
@@ -13,6 +13,9 @@
package de.bixilon.minosoft.data.commands.parser;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.data.commands.parser.exception.number.IntegerCommandParseException;
+import de.bixilon.minosoft.data.commands.parser.exception.number.ValueOutOfRangeCommandParseException;
import de.bixilon.minosoft.data.commands.parser.properties.IntegerParserProperties;
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
@@ -31,12 +34,16 @@ public class IntegerParser extends CommandParser {
}
@Override
- public boolean isParsable(ParserProperties properties, ImprovedStringReader stringReader) {
+ public void isParsable(ParserProperties properties, ImprovedStringReader stringReader) throws CommandParseException {
String argument = stringReader.readUntilNextCommandArgument();
try {
- return isValidValue((IntegerParserProperties) properties, Integer.parseInt(argument));
- } catch (Exception ignored) {
- return false;
+ int value = Integer.parseInt(argument);
+ IntegerParserProperties integerParserProperties = (IntegerParserProperties) properties;
+ if (value < integerParserProperties.getMinValue() && value > integerParserProperties.getMaxValue()) {
+ throw new ValueOutOfRangeCommandParseException(stringReader, integerParserProperties.getMinValue(), integerParserProperties.getMaxValue(), value);
+ }
+ } catch (NumberFormatException exception) {
+ throw new IntegerCommandParseException(stringReader, argument, exception);
}
}
}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/MessageParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/MessageParser.java
index 3791fab33..b08e55f2d 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/parser/MessageParser.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/MessageParser.java
@@ -13,6 +13,7 @@
package de.bixilon.minosoft.data.commands.parser;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties;
import de.bixilon.minosoft.data.commands.parser.properties.StringParserProperties;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
@@ -31,7 +32,7 @@ public class MessageParser extends StringParser {
}
@Override
- public boolean isParsable(@Nullable ParserProperties properties, ImprovedStringReader stringReader) {
- return super.isParsable(STRING_PARSER_PROPERTIES, stringReader);
+ public void isParsable(@Nullable ParserProperties properties, ImprovedStringReader stringReader) throws CommandParseException {
+ super.isParsable(STRING_PARSER_PROPERTIES, stringReader);
}
}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/RangeParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/RangeParser.java
index d60a98a24..edf2d2b72 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/parser/RangeParser.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/RangeParser.java
@@ -13,6 +13,7 @@
package de.bixilon.minosoft.data.commands.parser;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties;
import de.bixilon.minosoft.data.commands.parser.properties.RangeParserProperties;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
@@ -29,7 +30,7 @@ public class RangeParser extends CommandParser {
}
@Override
- public boolean isParsable(@Nullable ParserProperties properties, ImprovedStringReader stringReader) {
- return false; // ToDo
+ public void isParsable(@Nullable ParserProperties properties, ImprovedStringReader stringReader) throws CommandParseException {
+ // ToDo
}
}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/ScoreHolderParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/ScoreHolderParser.java
index ae9375c09..6b2d483a5 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/parser/ScoreHolderParser.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/ScoreHolderParser.java
@@ -13,6 +13,7 @@
package de.bixilon.minosoft.data.commands.parser;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties;
import de.bixilon.minosoft.data.commands.parser.properties.ScoreHolderParserProperties;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
@@ -29,7 +30,7 @@ public class ScoreHolderParser extends CommandParser {
}
@Override
- public boolean isParsable(@Nullable ParserProperties properties, ImprovedStringReader stringReader) {
- return false; // ToDo
+ public void isParsable(@Nullable ParserProperties properties, ImprovedStringReader stringReader) throws CommandParseException {
+ // ToDo
}
}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/StringParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/StringParser.java
index a4ccd0da1..86ffd555a 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/parser/StringParser.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/StringParser.java
@@ -13,6 +13,8 @@
package de.bixilon.minosoft.data.commands.parser;
+import de.bixilon.minosoft.data.commands.parser.exception.BlankStringCommandParseException;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
import de.bixilon.minosoft.data.commands.parser.properties.ParserProperties;
import de.bixilon.minosoft.data.commands.parser.properties.StringParserProperties;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
@@ -27,17 +29,10 @@ public class StringParser extends CommandParser {
}
@Override
- public boolean isParsable(ParserProperties properties, ImprovedStringReader stringReader) {
- // Why the hell can't I use yield here :?
+ public void isParsable(ParserProperties properties, ImprovedStringReader stringReader) throws CommandParseException {
StringParserProperties stringParserProperties = ((StringParserProperties) properties);
- switch (stringParserProperties.getSetting()) {
- case SINGLE_WORD -> {
- String rest = stringReader.readUntilNextCommandArgument();
- if (stringParserProperties.isAllowEmptyString()) {
- return true;
- }
- return !rest.isBlank();
- }
+ String string = switch (stringParserProperties.getSetting()) {
+ case SINGLE_WORD -> stringReader.readUntilNextCommandArgument();
case QUOTABLE_PHRASE -> {
if (stringReader.get(1).equals("\"")) {
stringReader.skip(1);
@@ -50,24 +45,18 @@ public class StringParser extends CommandParser {
builder.append(stringReader.readUntil("\""));
currentString = builder.toString();
}
- if (stringParserProperties.isAllowEmptyString()) {
- return true;
- }
- return currentString.isBlank();
+ yield currentString;
}
- if (stringParserProperties.isAllowEmptyString()) {
- return true;
- }
- return !stringReader.readUntilNextCommandArgument().isBlank();
- }
- case GREEDY_PHRASE -> {
- String rest = stringReader.readRest();
- if (stringParserProperties.isAllowEmptyString()) {
- return true;
- }
- return !rest.isBlank();
+ yield stringReader.readUntilNextCommandArgument();
}
+ case GREEDY_PHRASE -> stringReader.readRest();
+ };
+
+ if (stringParserProperties.isAllowEmptyString()) {
+ return;
+ }
+ if (string.isBlank()) {
+ throw new BlankStringCommandParseException(stringReader, string);
}
- return false;
}
}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/entity/EntitySelectorArgumentParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/entity/EntitySelectorArgumentParser.java
index d5d3bd71c..abcba8a84 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/parser/entity/EntitySelectorArgumentParser.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/entity/EntitySelectorArgumentParser.java
@@ -13,9 +13,10 @@
package de.bixilon.minosoft.data.commands.parser.entity;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
public interface EntitySelectorArgumentParser {
- boolean isParsable(ImprovedStringReader stringReader);
+ void isParsable(ImprovedStringReader stringReader) throws CommandParseException;
}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/entity/IntegerSelectorArgumentParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/entity/IntegerSelectorArgumentParser.java
new file mode 100644
index 000000000..23928ce76
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/entity/IntegerSelectorArgumentParser.java
@@ -0,0 +1,38 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.entity;
+
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.data.commands.parser.exception.number.IntegerCommandParseException;
+import de.bixilon.minosoft.util.Pair;
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class IntegerSelectorArgumentParser implements EntitySelectorArgumentParser {
+ public static final IntegerSelectorArgumentParser INTEGER_SELECTOR_ARGUMENT_PARSER = new IntegerSelectorArgumentParser();
+
+ @Override
+ public void isParsable(ImprovedStringReader stringReader) throws CommandParseException {
+ // read until next space or comma
+ Pair match = stringReader.readUntil(",", " ", "]");
+ if (!match.value.equals(" ")) {
+ // set pointer to --
+ stringReader.skip(-1);
+ }
+ try {
+ Integer.parseInt(match.key);
+ } catch (Exception e) {
+ throw new IntegerCommandParseException(stringReader, match.key, e);
+ }
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/entity/NameEntitySelectorArgumentParser.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/entity/StringSelectorArgumentParser.java
similarity index 76%
rename from src/main/java/de/bixilon/minosoft/data/commands/parser/entity/NameEntitySelectorArgumentParser.java
rename to src/main/java/de/bixilon/minosoft/data/commands/parser/entity/StringSelectorArgumentParser.java
index 46ee2995a..323f4a098 100644
--- a/src/main/java/de/bixilon/minosoft/data/commands/parser/entity/NameEntitySelectorArgumentParser.java
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/entity/StringSelectorArgumentParser.java
@@ -14,19 +14,21 @@
package de.bixilon.minosoft.data.commands.parser.entity;
import de.bixilon.minosoft.data.commands.parser.StringParser;
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
import de.bixilon.minosoft.data.commands.parser.properties.StringParserProperties;
import de.bixilon.minosoft.util.Pair;
import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
-public class NameEntitySelectorArgumentParser implements EntitySelectorArgumentParser {
- public static final NameEntitySelectorArgumentParser NAME_ENTITY_SELECTOR_ARGUMENT_PARSER = new NameEntitySelectorArgumentParser();
+public class StringSelectorArgumentParser implements EntitySelectorArgumentParser {
+ public static final StringSelectorArgumentParser STRING_SELECTOR_ARGUMENT_PARSER = new StringSelectorArgumentParser();
private static final StringParserProperties STRING_PARSER_PROPERTIES = new StringParserProperties(StringParserProperties.StringSettings.QUOTABLE_PHRASE, true);
@Override
- public boolean isParsable(ImprovedStringReader stringReader) {
+ public void isParsable(ImprovedStringReader stringReader) throws CommandParseException {
// if it starts with a quote, it will end with a quote
if (stringReader.get(1).equals("\"")) {
- return StringParser.STRING_PARSER.isParsable(STRING_PARSER_PROPERTIES, stringReader);
+ StringParser.STRING_PARSER.isParsable(STRING_PARSER_PROPERTIES, stringReader);
+ return;
}
// read until next space or comma
Pair match = stringReader.readUntil(",", " ", "]");
@@ -34,6 +36,5 @@ public class NameEntitySelectorArgumentParser implements EntitySelectorArgumentP
// set pointer to --
stringReader.skip(-1);
}
- return true;
}
}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/BlankStringCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/BlankStringCommandParseException.java
new file mode 100644
index 000000000..4e727cdf7
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/BlankStringCommandParseException.java
@@ -0,0 +1,29 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception;
+
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class BlankStringCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "String is blank!";
+
+ public BlankStringCommandParseException(ImprovedStringReader command, String currentArgument) {
+ super(ERROR_MESSAGE, command, currentArgument);
+ }
+
+ public BlankStringCommandParseException(ImprovedStringReader command, String currentArgument, Throwable cause) {
+ super(ERROR_MESSAGE, command, currentArgument, cause);
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/BooleanCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/BooleanCommandParseException.java
new file mode 100644
index 000000000..e65bbe566
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/BooleanCommandParseException.java
@@ -0,0 +1,29 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception;
+
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class BooleanCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "Unknown boolean value!";
+
+ public BooleanCommandParseException(ImprovedStringReader command, String currentArgument) {
+ super(ERROR_MESSAGE, command, currentArgument);
+ }
+
+ public BooleanCommandParseException(ImprovedStringReader command, String currentArgument, Throwable cause) {
+ super(ERROR_MESSAGE, command, currentArgument, cause);
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/CommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/CommandParseException.java
new file mode 100644
index 000000000..e780261b5
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/CommandParseException.java
@@ -0,0 +1,64 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception;
+
+
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class CommandParseException extends Exception {
+ private final String errorMessage;
+ private final ImprovedStringReader command;
+ private final int startIndex;
+ private final int endIndex;
+
+ public CommandParseException(String errorMessage, ImprovedStringReader command, int startIndex) {
+ this(errorMessage, command, startIndex, null);
+ }
+
+ public CommandParseException(String errorMessage, ImprovedStringReader command, int startIndex, Throwable cause) {
+ super(String.format("%s <-- [%s] (%d): %s", command.getString(), command.getString().substring(startIndex), startIndex, errorMessage), cause);
+ this.errorMessage = errorMessage;
+ this.command = command;
+ this.startIndex = startIndex;
+ this.endIndex = command.getPosition();
+ }
+
+ public CommandParseException(String errorMessage, ImprovedStringReader command, String currentArgument) {
+ this(errorMessage, command, currentArgument, null);
+ }
+
+ public CommandParseException(String errorMessage, ImprovedStringReader command, String currentArgument, Throwable cause) {
+ super(String.format("%s <-- [%s] (%d): %s", command.getString(), currentArgument, (command.getPosition() - currentArgument.length()), errorMessage), cause);
+ this.errorMessage = errorMessage;
+ this.command = command;
+ this.startIndex = command.getPosition() - currentArgument.length();
+ this.endIndex = command.getPosition();
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public ImprovedStringReader getCommand() {
+ return command;
+ }
+
+ public int getStartIndex() {
+ return startIndex;
+ }
+
+ public int getEndIndex() {
+ return endIndex;
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/RequiresMoreArgumentsCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/RequiresMoreArgumentsCommandParseException.java
new file mode 100644
index 000000000..d6a875fc7
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/RequiresMoreArgumentsCommandParseException.java
@@ -0,0 +1,29 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception;
+
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class RequiresMoreArgumentsCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "Command requires more arguments!";
+
+ public RequiresMoreArgumentsCommandParseException(ImprovedStringReader command) {
+ super(ERROR_MESSAGE, command, command.getPosition());
+ }
+
+ public RequiresMoreArgumentsCommandParseException(ImprovedStringReader command, Throwable cause) {
+ super(ERROR_MESSAGE, command, command.getPosition(), cause);
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/UnknownCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/UnknownCommandParseException.java
new file mode 100644
index 000000000..1ccd7c1bf
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/UnknownCommandParseException.java
@@ -0,0 +1,29 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception;
+
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class UnknownCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "Unknown command!";
+
+ public UnknownCommandParseException(ImprovedStringReader command, String currentArgument) {
+ super(ERROR_MESSAGE, command, currentArgument);
+ }
+
+ public UnknownCommandParseException(ImprovedStringReader command, String currentArgument, Throwable cause) {
+ super(ERROR_MESSAGE, command, currentArgument, cause);
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/WrongArgumentCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/WrongArgumentCommandParseException.java
new file mode 100644
index 000000000..e45f6d349
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/WrongArgumentCommandParseException.java
@@ -0,0 +1,29 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception;
+
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class WrongArgumentCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "Wrong argument given!";
+
+ public WrongArgumentCommandParseException(ImprovedStringReader command, String currentArgument) {
+ super(ERROR_MESSAGE, command, currentArgument);
+ }
+
+ public WrongArgumentCommandParseException(ImprovedStringReader command, String currentArgument, Throwable cause) {
+ super(ERROR_MESSAGE, command, currentArgument, cause);
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/DuplicatedParameterEntityCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/DuplicatedParameterEntityCommandParseException.java
new file mode 100644
index 000000000..9b7aaa417
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/DuplicatedParameterEntityCommandParseException.java
@@ -0,0 +1,30 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception.entity;
+
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class DuplicatedParameterEntityCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "Entity parameter is duplicated!";
+
+ public DuplicatedParameterEntityCommandParseException(ImprovedStringReader command, String currentArgument) {
+ super(ERROR_MESSAGE, command, currentArgument);
+ }
+
+ public DuplicatedParameterEntityCommandParseException(ImprovedStringReader command, String currentArgument, Throwable cause) {
+ super(ERROR_MESSAGE, command, currentArgument, cause);
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/PlayerOnlyEntityCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/PlayerOnlyEntityCommandParseException.java
new file mode 100644
index 000000000..ce86af9d9
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/PlayerOnlyEntityCommandParseException.java
@@ -0,0 +1,30 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception.entity;
+
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class PlayerOnlyEntityCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "Only players allowed!";
+
+ public PlayerOnlyEntityCommandParseException(ImprovedStringReader command, String currentArgument) {
+ super(ERROR_MESSAGE, command, currentArgument);
+ }
+
+ public PlayerOnlyEntityCommandParseException(ImprovedStringReader command, String currentArgument, Throwable cause) {
+ super(ERROR_MESSAGE, command, currentArgument, cause);
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/SingleEntityOnlyEntityCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/SingleEntityOnlyEntityCommandParseException.java
new file mode 100644
index 000000000..49b8cd116
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/SingleEntityOnlyEntityCommandParseException.java
@@ -0,0 +1,30 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception.entity;
+
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class SingleEntityOnlyEntityCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "Only 1 entity allowed!";
+
+ public SingleEntityOnlyEntityCommandParseException(ImprovedStringReader command, String currentArgument) {
+ super(ERROR_MESSAGE, command, currentArgument);
+ }
+
+ public SingleEntityOnlyEntityCommandParseException(ImprovedStringReader command, String currentArgument, Throwable cause) {
+ super(ERROR_MESSAGE, command, currentArgument, cause);
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/UnknownEntitySelectorCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/UnknownEntitySelectorCommandParseException.java
new file mode 100644
index 000000000..54f8b6020
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/UnknownEntitySelectorCommandParseException.java
@@ -0,0 +1,30 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception.entity;
+
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class UnknownEntitySelectorCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "Unknown entity selector!";
+
+ public UnknownEntitySelectorCommandParseException(ImprovedStringReader command, String currentArgument) {
+ super(ERROR_MESSAGE, command, currentArgument);
+ }
+
+ public UnknownEntitySelectorCommandParseException(ImprovedStringReader command, String currentArgument, Throwable cause) {
+ super(ERROR_MESSAGE, command, currentArgument, cause);
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/UnknownMassSelectorEntityCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/UnknownMassSelectorEntityCommandParseException.java
new file mode 100644
index 000000000..bd3e50d1e
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/UnknownMassSelectorEntityCommandParseException.java
@@ -0,0 +1,30 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception.entity;
+
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class UnknownMassSelectorEntityCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "Unknown mass selector!";
+
+ public UnknownMassSelectorEntityCommandParseException(ImprovedStringReader command, String currentArgument) {
+ super(ERROR_MESSAGE, command, currentArgument);
+ }
+
+ public UnknownMassSelectorEntityCommandParseException(ImprovedStringReader command, String currentArgument, Throwable cause) {
+ super(ERROR_MESSAGE, command, currentArgument, cause);
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/UnknownParameterEntityCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/UnknownParameterEntityCommandParseException.java
new file mode 100644
index 000000000..495070e34
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/entity/UnknownParameterEntityCommandParseException.java
@@ -0,0 +1,30 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception.entity;
+
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class UnknownParameterEntityCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "Unknown entity parameter!";
+
+ public UnknownParameterEntityCommandParseException(ImprovedStringReader command, String currentArgument) {
+ super(ERROR_MESSAGE, command, currentArgument);
+ }
+
+ public UnknownParameterEntityCommandParseException(ImprovedStringReader command, String currentArgument, Throwable cause) {
+ super(ERROR_MESSAGE, command, currentArgument, cause);
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/number/DoubleCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/number/DoubleCommandParseException.java
new file mode 100644
index 000000000..929209a8b
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/number/DoubleCommandParseException.java
@@ -0,0 +1,30 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception.number;
+
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class DoubleCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "Unknown double value!";
+
+ public DoubleCommandParseException(ImprovedStringReader command, String currentArgument) {
+ super(ERROR_MESSAGE, command, currentArgument);
+ }
+
+ public DoubleCommandParseException(ImprovedStringReader command, String currentArgument, Throwable cause) {
+ super(ERROR_MESSAGE, command, currentArgument, cause);
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/number/FloatCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/number/FloatCommandParseException.java
new file mode 100644
index 000000000..c99e48639
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/number/FloatCommandParseException.java
@@ -0,0 +1,30 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception.number;
+
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class FloatCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "Unknown float value!";
+
+ public FloatCommandParseException(ImprovedStringReader command, String currentArgument) {
+ super(ERROR_MESSAGE, command, currentArgument);
+ }
+
+ public FloatCommandParseException(ImprovedStringReader command, String currentArgument, Throwable cause) {
+ super(ERROR_MESSAGE, command, currentArgument, cause);
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/number/IntegerCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/number/IntegerCommandParseException.java
new file mode 100644
index 000000000..6a13d0ef2
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/number/IntegerCommandParseException.java
@@ -0,0 +1,30 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception.number;
+
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class IntegerCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "Unknown int value!";
+
+ public IntegerCommandParseException(ImprovedStringReader command, String currentArgument) {
+ super(ERROR_MESSAGE, command, currentArgument);
+ }
+
+ public IntegerCommandParseException(ImprovedStringReader command, String currentArgument, Throwable cause) {
+ super(ERROR_MESSAGE, command, currentArgument, cause);
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/number/ValueOutOfRangeCommandParseException.java b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/number/ValueOutOfRangeCommandParseException.java
new file mode 100644
index 000000000..c348d8b38
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/commands/parser/exception/number/ValueOutOfRangeCommandParseException.java
@@ -0,0 +1,26 @@
+/*
+ * Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.commands.parser.exception.number;
+
+import de.bixilon.minosoft.data.commands.parser.exception.CommandParseException;
+import de.bixilon.minosoft.util.buffers.ImprovedStringReader;
+
+public class ValueOutOfRangeCommandParseException extends CommandParseException {
+
+ private static final String ERROR_MESSAGE = "Value out of range (min=%s, max=%s!";
+
+ public ValueOutOfRangeCommandParseException(ImprovedStringReader command, Object minValue, Object maxValue, Object value) {
+ super(String.format(ERROR_MESSAGE, minValue, maxValue), command, value.toString());
+ }
+}