Skip to content

Commit b8e805b

Browse files
Literal Number Max+Min Values (SkriptLang#8008)
* Initial Commit * Update Tests * literals package * Add "[the] "
1 parent 4b1a30c commit b8e805b

23 files changed

Lines changed: 338 additions & 19 deletions

src/main/java/ch/njol/skript/Skript.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ public void onEnable() {
575575

576576
try {
577577
getAddonInstance().loadClasses("ch.njol.skript",
578-
"conditions", "effects", "events", "expressions", "entity", "sections", "structures");
578+
"conditions", "effects", "events", "expressions", "entity", "literals", "sections", "structures");
579579
getAddonInstance().loadClasses("org.skriptlang.skript.bukkit", "misc");
580580
// todo: become proper module once registry api is merged
581581
FishingModule.load();

src/main/java/ch/njol/skript/expressions/LitAt.java renamed to src/main/java/ch/njol/skript/literals/LitAt.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ch.njol.skript.expressions;
1+
package ch.njol.skript.literals;
22

33
import org.bukkit.event.Event;
44
import org.jetbrains.annotations.Nullable;

src/main/java/ch/njol/skript/expressions/LitConsole.java renamed to src/main/java/ch/njol/skript/literals/LitConsole.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ch.njol.skript.expressions;
1+
package ch.njol.skript.literals;
22

33
import org.bukkit.Bukkit;
44
import org.bukkit.command.ConsoleCommandSender;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package ch.njol.skript.literals;
2+
3+
import ch.njol.skript.Skript;
4+
import ch.njol.skript.doc.Description;
5+
import ch.njol.skript.doc.Example;
6+
import ch.njol.skript.doc.Name;
7+
import ch.njol.skript.doc.Since;
8+
import ch.njol.skript.lang.Expression;
9+
import ch.njol.skript.lang.ExpressionType;
10+
import ch.njol.skript.lang.SkriptParser.ParseResult;
11+
import ch.njol.skript.lang.util.SimpleLiteral;
12+
import ch.njol.util.Kleenean;
13+
import org.bukkit.event.Event;
14+
import org.jetbrains.annotations.Nullable;
15+
16+
@Name("Maximum Double Value")
17+
@Description("A number representing the maximum value of a double number type.")
18+
@Example("if {_number} >= maximum double value:")
19+
@Since("INSERT VERSION")
20+
public class LitDoubleMaxValue extends SimpleLiteral<Double> {
21+
22+
static {
23+
Skript.registerExpression(LitDoubleMaxValue.class, Double.class, ExpressionType.SIMPLE, "[the] max[imum] double value");
24+
}
25+
26+
public LitDoubleMaxValue() {
27+
super(Double.MAX_VALUE, false);
28+
}
29+
30+
@Override
31+
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
32+
return true;
33+
}
34+
35+
@Override
36+
public String toString(@Nullable Event event, boolean debug) {
37+
return "max double value";
38+
}
39+
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package ch.njol.skript.literals;
2+
3+
import ch.njol.skript.Skript;
4+
import ch.njol.skript.doc.Description;
5+
import ch.njol.skript.doc.Example;
6+
import ch.njol.skript.doc.Name;
7+
import ch.njol.skript.doc.Since;
8+
import ch.njol.skript.lang.Expression;
9+
import ch.njol.skript.lang.ExpressionType;
10+
import ch.njol.skript.lang.SkriptParser.ParseResult;
11+
import ch.njol.skript.lang.util.SimpleLiteral;
12+
import ch.njol.util.Kleenean;
13+
import org.bukkit.event.Event;
14+
import org.jetbrains.annotations.Nullable;
15+
16+
@Name("Minimum Double Value")
17+
@Description("A number representing the minimum value of a double number type.")
18+
@Example("if {_number} <= minimum double value:")
19+
@Since("INSERT VERSION")
20+
public class LitDoubleMinValue extends SimpleLiteral<Double> {
21+
22+
static {
23+
Skript.registerExpression(LitDoubleMinValue.class, Double.class, ExpressionType.SIMPLE, "[the] min[imum] double value");
24+
}
25+
26+
public LitDoubleMinValue() {
27+
super(Double.MIN_VALUE, false);
28+
}
29+
30+
@Override
31+
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
32+
return true;
33+
}
34+
35+
@Override
36+
public String toString(@Nullable Event event, boolean debug) {
37+
return "min double value";
38+
}
39+
40+
}

src/main/java/ch/njol/skript/expressions/LitEternity.java renamed to src/main/java/ch/njol/skript/literals/LitEternity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ch.njol.skript.expressions;
1+
package ch.njol.skript.literals;
22

33
import ch.njol.skript.Skript;
44
import ch.njol.skript.doc.Description;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package ch.njol.skript.literals;
2+
3+
import ch.njol.skript.Skript;
4+
import ch.njol.skript.doc.Description;
5+
import ch.njol.skript.doc.Example;
6+
import ch.njol.skript.doc.Name;
7+
import ch.njol.skript.doc.Since;
8+
import ch.njol.skript.lang.Expression;
9+
import ch.njol.skript.lang.ExpressionType;
10+
import ch.njol.skript.lang.SkriptParser.ParseResult;
11+
import ch.njol.skript.lang.util.SimpleLiteral;
12+
import ch.njol.util.Kleenean;
13+
import org.bukkit.event.Event;
14+
import org.jetbrains.annotations.Nullable;
15+
16+
@Name("Maximum Float Value")
17+
@Description("A number representing the maximum value of a float number type.")
18+
@Example("if {_number} >= maximum float value:")
19+
@Since("INSERT VERSION")
20+
public class LitFloatMaxValue extends SimpleLiteral<Float> {
21+
22+
static {
23+
Skript.registerExpression(LitFloatMaxValue.class, Float.class, ExpressionType.SIMPLE, "[the] max[imum] float value");
24+
}
25+
26+
public LitFloatMaxValue() {
27+
super(Float.MAX_VALUE, false);
28+
}
29+
30+
@Override
31+
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
32+
return true;
33+
}
34+
35+
@Override
36+
public String toString(@Nullable Event event, boolean debug) {
37+
return "max float value";
38+
}
39+
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package ch.njol.skript.literals;
2+
3+
import ch.njol.skript.Skript;
4+
import ch.njol.skript.doc.Description;
5+
import ch.njol.skript.doc.Example;
6+
import ch.njol.skript.doc.Name;
7+
import ch.njol.skript.doc.Since;
8+
import ch.njol.skript.lang.Expression;
9+
import ch.njol.skript.lang.ExpressionType;
10+
import ch.njol.skript.lang.SkriptParser.ParseResult;
11+
import ch.njol.skript.lang.util.SimpleLiteral;
12+
import ch.njol.util.Kleenean;
13+
import org.bukkit.event.Event;
14+
import org.jetbrains.annotations.Nullable;
15+
16+
@Name("Minimum Float Value")
17+
@Description("A number representing the minimum value of a float number type.")
18+
@Example("if {_number} <= minimum float value:")
19+
@Since("INSERT VERSION")
20+
public class LitFloatMinValue extends SimpleLiteral<Float> {
21+
22+
static {
23+
Skript.registerExpression(LitFloatMinValue.class, Float.class, ExpressionType.SIMPLE, "[the] min[imum] float value");
24+
}
25+
26+
public LitFloatMinValue() {
27+
super(Float.MIN_VALUE, false);
28+
}
29+
30+
@Override
31+
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
32+
return true;
33+
}
34+
35+
@Override
36+
public String toString(@Nullable Event event, boolean debug) {
37+
return "min float value";
38+
}
39+
40+
}

src/main/java/ch/njol/skript/expressions/LitInfinity.java renamed to src/main/java/ch/njol/skript/literals/LitInfinity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ch.njol.skript.expressions;
1+
package ch.njol.skript.literals;
22

33
import ch.njol.skript.Skript;
44
import ch.njol.skript.doc.Description;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package ch.njol.skript.literals;
2+
3+
import ch.njol.skript.Skript;
4+
import ch.njol.skript.doc.Description;
5+
import ch.njol.skript.doc.Example;
6+
import ch.njol.skript.doc.Name;
7+
import ch.njol.skript.doc.Since;
8+
import ch.njol.skript.lang.Expression;
9+
import ch.njol.skript.lang.ExpressionType;
10+
import ch.njol.skript.lang.SkriptParser.ParseResult;
11+
import ch.njol.skript.lang.util.SimpleLiteral;
12+
import ch.njol.util.Kleenean;
13+
import org.bukkit.event.Event;
14+
import org.jetbrains.annotations.Nullable;
15+
16+
@Name("Maximum Integer Value")
17+
@Description("A number representing the maximum value of an integer number type.")
18+
@Example("if {_number} >= maximum integer value:")
19+
@Since("INSERT VERSION")
20+
public class LitIntMaxValue extends SimpleLiteral<Integer> {
21+
22+
static {
23+
Skript.registerExpression(LitIntMaxValue.class, Integer.class, ExpressionType.SIMPLE, "[the] max[imum] integer value");
24+
}
25+
26+
public LitIntMaxValue() {
27+
super(Integer.MAX_VALUE, false);
28+
}
29+
30+
@Override
31+
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
32+
return true;
33+
}
34+
35+
@Override
36+
public String toString(@Nullable Event event, boolean debug) {
37+
return "max integer value";
38+
}
39+
40+
}

0 commit comments

Comments
 (0)