Skip to content

Commit

Permalink
update for core improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Feb 15, 2020
1 parent 4b227f0 commit 61f9ab4
Show file tree
Hide file tree
Showing 45 changed files with 77 additions and 78 deletions.
Expand Up @@ -74,7 +74,7 @@ public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
return true;
}
if (Argument.valueOf(determination)
.matchesPrimitive(ArgumentHelper.PrimitiveType.Boolean)) {
.matchesBoolean()) {
fire = determination.equalsIgnoreCase("true");
return true;
}
Expand Down
Expand Up @@ -63,7 +63,7 @@ else if (!scriptEntry.hasObject("agetype")
scriptEntry.addObject("agetype", AgeType.valueOf(arg.getValue().toUpperCase()));
}
else if (!scriptEntry.hasObject("age")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Integer)) {
&& arg.matchesInteger()) {
scriptEntry.addObject("age", arg.asElement());
}
else if (!scriptEntry.hasObject("lock")
Expand Down
Expand Up @@ -77,7 +77,7 @@ else if (!scriptEntry.hasObject("duration")
}
else if (!scriptEntry.hasObject("amplifier")
&& arg.matchesPrefix("power", "p", "amplifier", "a")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)) {
&& arg.matchesFloat()) {
scriptEntry.addObject("amplifier", arg.asElement());
}
else if (!scriptEntry.hasObject("effect")
Expand Down
Expand Up @@ -57,12 +57,12 @@ public class FeedCommand extends AbstractCommand {
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

for (Argument arg : scriptEntry.getProcessedArgs()) {
if (arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Integer)
if (arg.matchesInteger()
&& arg.matchesPrefix("amount", "amt", "quantity", "qty", "a", "q")
&& !scriptEntry.hasObject("amount")) {
scriptEntry.addObject("amount", arg.asElement());
}
else if (arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Integer)
else if (arg.matchesInteger()
&& arg.matchesPrefix("saturation", "sat", "s")
&& !scriptEntry.hasObject("saturation")) {
scriptEntry.addObject("saturation", arg.asElement());
Expand Down
Expand Up @@ -92,12 +92,12 @@ else if (!scriptEntry.hasObject("entities")
}
else if (!scriptEntry.hasObject("rotation_threshold")
&& arg.matchesPrefix("rotationthreshold", "rotation", "r")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Float)) {
&& arg.matchesFloat()) {

scriptEntry.addObject("rotation_threshold", arg.asElement());
}
else if (!scriptEntry.hasObject("speed")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)) {
&& arg.matchesFloat()) {

scriptEntry.addObject("speed", arg.asElement());
}
Expand Down
Expand Up @@ -62,12 +62,12 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
scriptEntry.addObject("stop", new ElementTag(true));
}
else if (!scriptEntry.hasObject("lead") &&
arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double) &&
arg.matchesFloat() &&
arg.matchesPrefix("l", "lead")) {
scriptEntry.addObject("lead", arg.asElement());
}
else if (!scriptEntry.hasObject("max") &&
arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double) &&
arg.matchesFloat() &&
arg.matchesPrefix("max")) {
scriptEntry.addObject("max", arg.asElement());
}
Expand All @@ -76,7 +76,7 @@ else if (!scriptEntry.hasObject("allow_wander") &&
scriptEntry.addObject("allow_wander", new ElementTag(true));
}
else if (!scriptEntry.hasObject("speed") &&
arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Percentage) &&
arg.matchesFloat() &&
arg.matchesPrefix("s", "speed")) {
scriptEntry.addObject("speed", arg.asElement());
}
Expand Down
Expand Up @@ -52,7 +52,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
for (Argument arg : scriptEntry.getProcessedArgs()) {

if (!scriptEntry.hasObject("amount")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)) {
&& arg.matchesFloat()) {
scriptEntry.addObject("amount", arg.asElement());
}
else if (!scriptEntry.hasObject("entities")
Expand Down
Expand Up @@ -68,7 +68,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
scriptEntry.addObject("target", Arrays.asList(Utilities.getEntryPlayer(scriptEntry).getDenizenEntity()));
}
else if (!scriptEntry.hasObject("qty")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)) {
&& arg.matchesFloat()) {
scriptEntry.addObject("qty", arg.asElement());
}
else if (!scriptEntry.hasObject("target")
Expand Down
Expand Up @@ -67,8 +67,8 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
for (Argument arg : scriptEntry.getProcessedArgs()) {

if (!scriptEntry.hasObject("amount")
&& (arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)
|| arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Integer))) {
&& (arg.matchesFloat()
|| arg.matchesInteger())) {
scriptEntry.addObject("amount", arg.asElement());
}
else if (!scriptEntry.hasObject("source")
Expand Down
Expand Up @@ -103,7 +103,7 @@ else if (!scriptEntry.hasObject("duration")
scriptEntry.addObject("duration", arg.asType(DurationTag.class));
}
else if (!scriptEntry.hasObject("speed")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)
&& arg.matchesFloat()
&& arg.matchesPrefix("speed", "s")) {

scriptEntry.addObject("speed", arg.asElement());
Expand Down
Expand Up @@ -87,13 +87,13 @@ else if (!scriptEntry.hasObject("frequency")
}
else if (!scriptEntry.hasObject("yaw")
&& arg.matchesPrefix("yaw", "y", "rotation", "r")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Float)) {
&& arg.matchesFloat()) {

scriptEntry.addObject("yaw", arg.asElement());
}
else if (!scriptEntry.hasObject("pitch")
&& arg.matchesPrefix("pitch", "p", "tilt", "t")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Float)) {
&& arg.matchesFloat()) {

scriptEntry.addObject("pitch", arg.asElement());
}
Expand Down
Expand Up @@ -118,13 +118,13 @@ else if (!scriptEntry.hasObject("lead")
scriptEntry.addObject("lead", arg.asType(LocationTag.class));
}
else if (!scriptEntry.hasObject("height")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)
&& arg.matchesFloat()
&& arg.matchesPrefix("height", "h")) {

scriptEntry.addObject("height", arg.asElement());
}
else if (!scriptEntry.hasObject("speed")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)
&& arg.matchesFloat()
&& arg.matchesPrefix("speed")) {

scriptEntry.addObject("speed", arg.asElement());
Expand All @@ -147,13 +147,13 @@ else if (!scriptEntry.hasObject("entities")

// Don't document this argument; it is for debug purposes only
else if (!scriptEntry.hasObject("gravity")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)
&& arg.matchesFloat()
&& arg.matchesPrefix("gravity", "g")) {

scriptEntry.addObject("gravity", arg.asElement());
}
else if (!scriptEntry.hasObject("spread")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)
&& arg.matchesFloat()
&& arg.matchesPrefix("spread")) {
scriptEntry.addObject("spread", arg.asElement());
}
Expand Down
Expand Up @@ -73,7 +73,7 @@ else if (!scriptEntry.hasObject("target")
scriptEntry.addObject("target", arg.asType(EntityTag.class));
}
else if (!scriptEntry.hasObject("spread")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Integer)) {
&& arg.matchesInteger()) {
scriptEntry.addObject("spread", arg.asElement());
}
else if (!scriptEntry.hasObject("persistent")
Expand Down
Expand Up @@ -95,7 +95,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
scriptEntry.addObject("lookat", arg.asType(LocationTag.class));
}
else if (!scriptEntry.hasObject("speed")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Percentage)
&& arg.matchesFloat()
&& arg.matchesPrefix("s", "speed")) {
scriptEntry.addObject("speed", arg.asElement());
}
Expand All @@ -104,7 +104,7 @@ else if (!scriptEntry.hasObject("auto_range")
scriptEntry.addObject("auto_range", new ElementTag(true));
}
else if (!scriptEntry.hasObject("radius")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)
&& arg.matchesFloat()
&& arg.matchesPrefix("radius")) {
scriptEntry.addObject("radius", arg.asElement());
}
Expand Down
Expand Up @@ -66,7 +66,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException

if (!scriptEntry.hasObject("qty")
&& arg.matchesPrefix("q", "qty", "quantity")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)) {
&& arg.matchesFloat()) {
scriptEntry.addObject("qty", arg.asElement());
scriptEntry.addObject("set_quantity", new ElementTag(true));
}
Expand Down
Expand Up @@ -95,12 +95,12 @@ else if (!scriptEntry.hasObject("resize")
}
else if (!scriptEntry.hasObject("width")
&& arg.matchesPrefix("width")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Integer)) {
&& arg.matchesInteger()) {
scriptEntry.addObject("width", arg.asElement());
}
else if (!scriptEntry.hasObject("height")
&& arg.matchesPrefix("height")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Integer)) {
&& arg.matchesInteger()) {
scriptEntry.addObject("height", arg.asElement());
}
else if (!scriptEntry.hasObject("script")
Expand All @@ -110,16 +110,16 @@ else if (!scriptEntry.hasObject("script")
}
else if (!scriptEntry.hasObject("x-value")
&& arg.matchesPrefix("x")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)) {
&& arg.matchesFloat()) {
scriptEntry.addObject("x-value", arg.asElement());
}
else if (!scriptEntry.hasObject("y-value")
&& arg.matchesPrefix("y")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)) {
&& arg.matchesFloat()) {
scriptEntry.addObject("y-value", arg.asElement());
}
else if (!scriptEntry.hasObject("map-id")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Integer)) {
&& arg.matchesInteger()) {
scriptEntry.addObject("map-id", arg.asElement());
}

Expand Down
Expand Up @@ -86,7 +86,7 @@ else if (!scriptEntry.hasObject("type")
}
else if (!scriptEntry.hasObject("qty")
&& arg.matchesPrefix("q", "qty", "quantity")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)) {
&& arg.matchesFloat()) {
scriptEntry.addObject("qty", arg.asElement());
}
else if (!scriptEntry.hasObject("items")
Expand Down
Expand Up @@ -64,7 +64,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
scriptEntry.addObject("action", Action.valueOf(arg.getValue().toUpperCase()));
}
else if (!scriptEntry.hasObject("range")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)
&& arg.matchesFloat()
&& arg.matchesPrefix("range", "r")) {
scriptEntry.addObject("range", arg.asElement());
}
Expand Down
Expand Up @@ -69,7 +69,7 @@ else if (!scriptEntry.hasObject("npc")
scriptEntry.addObject("npc", arg.asType(NPCTag.class));
}
else if (!scriptEntry.hasObject("radius")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)) {
&& arg.matchesFloat()) {
scriptEntry.addObject("radius", arg.asElement());
}
else {
Expand Down
Expand Up @@ -64,7 +64,7 @@ else if (!scriptEntry.hasObject("stop")
}
else if (!scriptEntry.hasObject("percent")
&& arg.matchesPrefix("catchpercent", "percent", "chance", "c")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Integer)) {
&& arg.matchesInteger()) {
scriptEntry.addObject("percent", arg.asElement());
}

Expand Down
Expand Up @@ -55,10 +55,10 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
if (arg.matches("realistic", "realistically")) {
scriptEntry.addObject("realistic", new ElementTag(true));
}
else if (arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Integer)) {
else if (arg.matchesInteger()) {
scriptEntry.addObject("range", arg.asElement());
}
else if (arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Boolean)) {
else if (arg.matchesBoolean()) {
scriptEntry.addObject("toggle", arg.asElement());
}
else if (arg.matchesArgumentType(NPCTag.class)) // TODO: better way of handling this?
Expand Down
Expand Up @@ -55,7 +55,7 @@ else if (!scriptEntry.hasObject("delay")
}
else if (!scriptEntry.hasObject("return")
&& arg.matchesPrefix("return", "r")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Boolean)) {
&& arg.matchesBoolean()) {
scriptEntry.addObject("return", arg.asElement());
}

Expand Down
Expand Up @@ -74,7 +74,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
}
else if (!scriptEntry.hasObject("radius")
&& arg.matchesPrefix("radius", "r")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Integer)) {
&& arg.matchesInteger()) {
scriptEntry.addObject("radius", arg.asElement());
}
else if (!scriptEntry.hasObject("toggle")
Expand Down
Expand Up @@ -125,27 +125,27 @@ else if (!scriptEntry.hasObject("frame")
}
else if (!scriptEntry.hasObject("toast")
&& arg.matchesPrefix("toast", "show")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Boolean)) {
&& arg.matchesBoolean()) {
scriptEntry.addObject("toast", arg.asElement());
}
else if (!scriptEntry.hasObject("announce")
&& arg.matchesPrefix("announce", "chat")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Boolean)) {
&& arg.matchesBoolean()) {
scriptEntry.addObject("announce", arg.asElement());
}
else if (!scriptEntry.hasObject("hidden")
&& arg.matchesPrefix("hidden", "hide", "h")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Boolean)) {
&& arg.matchesBoolean()) {
scriptEntry.addObject("hidden", arg.asElement());
}
else if (!scriptEntry.hasObject("x")
&& arg.matchesPrefix("x")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Float)) {
&& arg.matchesFloat()) {
scriptEntry.addObject("x", arg.asElement());
}
else if (!scriptEntry.hasObject("y")
&& arg.matchesPrefix("y")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Float)) {
&& arg.matchesFloat()) {
scriptEntry.addObject("y", arg.asElement());
}
else {
Expand Down
Expand Up @@ -63,7 +63,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
scriptEntry.addObject("players", arg.asType(ListTag.class).filter(PlayerTag.class, scriptEntry));
}
else if (arg.matchesPrefix("progress")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Integer)) {
&& arg.matchesInteger()) {
scriptEntry.addObject("progress", arg.asElement());
}
else if (arg.matchesArgumentType(LocationTag.class)) {
Expand Down
Expand Up @@ -86,7 +86,7 @@ else if (arg.matchesPrefix("talker", "talkers")) {

}
else if (arg.matchesPrefix("range", "r")) {
if (arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)) {
if (arg.matchesFloat()) {
scriptEntry.addObject("range", arg.asElement());
}
}
Expand Down
Expand Up @@ -86,7 +86,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException

for (Argument arg : scriptEntry.getProcessedArgs()) {

if (arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Integer)) {
if (arg.matchesInteger()) {
amount = arg.asElement().asInt();
}
else if (arg.matches("set", "give", "take")) {
Expand Down
Expand Up @@ -69,7 +69,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
scriptEntry.addObject("entities", arg.asType(ListTag.class).filter(EntityTag.class, scriptEntry));
}
else if (!scriptEntry.hasObject("glowing")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Boolean)) {
&& arg.matchesBoolean()) {
scriptEntry.addObject("glowing", arg.asElement());
}
else {
Expand Down
Expand Up @@ -70,7 +70,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
scriptEntry.addObject("action", arg.asElement());
}
else if (!scriptEntry.hasObject("quantity") && arg.matchesPrefix("quantity", "qty", "q")
&& arg.matchesPrimitive(ArgumentHelper.PrimitiveType.Double)) {
&& arg.matchesFloat()) {
scriptEntry.addObject("quantity", arg.asElement());
}
else if (!scriptEntry.hasObject("players") && arg.matchesPrefix("to", "from", "players", "player") &&
Expand Down

0 comments on commit 61f9ab4

Please sign in to comment.