Skip to content

Literal Number Max+Min Values #8008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: dev/feature
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/Skript.java
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ public void onEnable() {

try {
getAddonInstance().loadClasses("ch.njol.skript",
"conditions", "effects", "events", "expressions", "entity", "sections", "structures");
"conditions", "effects", "events", "expressions", "entity", "literals", "sections", "structures");
getAddonInstance().loadClasses("org.skriptlang.skript.bukkit", "misc");
// todo: become proper module once registry api is merged
FishingModule.load();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ch.njol.skript.expressions;
package ch.njol.skript.literals;

import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ch.njol.skript.expressions;
package ch.njol.skript.literals;

import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender;
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/ch/njol/skript/literals/LitDoubleMaxValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ch.njol.skript.literals;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Example;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@Name("Maximum Double Value")
@Description("A number representing the maximum value of a double number type.")
@Example("if {_number} >= maximum double value:")
@Since("INSERT VERSION")
public class LitDoubleMaxValue extends SimpleLiteral<Double> {

static {
Skript.registerExpression(LitDoubleMaxValue.class, Double.class, ExpressionType.SIMPLE, "[the] max[imum] double value");
}

public LitDoubleMaxValue() {
super(Double.MAX_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "max double value";
}

}
40 changes: 40 additions & 0 deletions src/main/java/ch/njol/skript/literals/LitDoubleMinValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ch.njol.skript.literals;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Example;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@Name("Minimum Double Value")
@Description("A number representing the minimum value of a double number type.")
@Example("if {_number} <= minimum double value:")
@Since("INSERT VERSION")
public class LitDoubleMinValue extends SimpleLiteral<Double> {

static {
Skript.registerExpression(LitDoubleMinValue.class, Double.class, ExpressionType.SIMPLE, "[the] min[imum] double value");
}

public LitDoubleMinValue() {
super(Double.MIN_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "min double value";
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ch.njol.skript.expressions;
package ch.njol.skript.literals;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/ch/njol/skript/literals/LitFloatMaxValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ch.njol.skript.literals;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Example;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@Name("Maximum Float Value")
@Description("A number representing the maximum value of a float number type.")
@Example("if {_number} >= maximum float value:")
@Since("INSERT VERSION")
public class LitFloatMaxValue extends SimpleLiteral<Float> {

static {
Skript.registerExpression(LitFloatMaxValue.class, Float.class, ExpressionType.SIMPLE, "[the] max[imum] float value");
}

public LitFloatMaxValue() {
super(Float.MAX_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "max float value";
}

}
40 changes: 40 additions & 0 deletions src/main/java/ch/njol/skript/literals/LitFloatMinValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ch.njol.skript.literals;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Example;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@Name("Minimum Float Value")
@Description("A number representing the minimum value of a float number type.")
@Example("if {_number} <= minimum float value:")
@Since("INSERT VERSION")
public class LitFloatMinValue extends SimpleLiteral<Float> {

static {
Skript.registerExpression(LitFloatMinValue.class, Float.class, ExpressionType.SIMPLE, "[the] min[imum] float value");
}

public LitFloatMinValue() {
super(Float.MIN_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "min float value";
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ch.njol.skript.expressions;
package ch.njol.skript.literals;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/ch/njol/skript/literals/LitIntMaxValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ch.njol.skript.literals;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Example;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@Name("Maximum Integer Value")
@Description("A number representing the maximum value of an integer number type.")
@Example("if {_number} >= maximum integer value:")
@Since("INSERT VERSION")
public class LitIntMaxValue extends SimpleLiteral<Integer> {

static {
Skript.registerExpression(LitIntMaxValue.class, Integer.class, ExpressionType.SIMPLE, "[the] max[imum] integer value");
}

public LitIntMaxValue() {
super(Integer.MAX_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "max integer value";
}

}
40 changes: 40 additions & 0 deletions src/main/java/ch/njol/skript/literals/LitIntMinValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ch.njol.skript.literals;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Example;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@Name("Minimum Integer Value")
@Description("A number representing the minimum value of an integer number type.")
@Example("if {_number} <= minimum integer value:")
@Since("INSERT VERSION")
public class LitIntMinValue extends SimpleLiteral<Integer> {

static {
Skript.registerExpression(LitIntMinValue.class, Integer.class, ExpressionType.SIMPLE, "[the] min[imum] integer value");
}

public LitIntMinValue() {
super(Integer.MIN_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "min integer value";
}

}
40 changes: 40 additions & 0 deletions src/main/java/ch/njol/skript/literals/LitLongMaxValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ch.njol.skript.literals;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Example;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@Name("Maximum Long Value")
@Description("A number representing the maximum value of a long number type.")
@Example("if {_number} >= maximum long value:")
@Since("INSERT VERSION")
public class LitLongMaxValue extends SimpleLiteral<Long> {

static {
Skript.registerExpression(LitLongMaxValue.class, Long.class, ExpressionType.SIMPLE, "[the] max[imum] long value");
}

public LitLongMaxValue() {
super(Long.MAX_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "max long value";
}

}
40 changes: 40 additions & 0 deletions src/main/java/ch/njol/skript/literals/LitLongMinValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ch.njol.skript.literals;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Example;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;

@Name("Minimum Long Value")
@Description("A number representing the minimum value of a long number type.")
@Example("if {_number} <= minimum long value:")
@Since("INSERT VERSION")
public class LitLongMinValue extends SimpleLiteral<Long> {

static {
Skript.registerExpression(LitLongMinValue.class, Long.class, ExpressionType.SIMPLE, "[the] min[imum] long value");
}

public LitLongMinValue() {
super(Long.MIN_VALUE, false);
}

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
return true;
}

@Override
public String toString(@Nullable Event event, boolean debug) {
return "min long value";
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ch.njol.skript.expressions;
package ch.njol.skript.literals;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ch.njol.skript.expressions;
package ch.njol.skript.literals;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ch.njol.skript.expressions;
package ch.njol.skript.literals;

import org.bukkit.event.Event;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ch.njol.skript.expressions;
package ch.njol.skript.literals;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
Expand All @@ -7,7 +7,6 @@
import ch.njol.skript.doc.Since;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.util.Kleenean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ test "floating point timespan math":
assert (5 seconds / 2.5) is 2 seconds with "failed floating point division"
assert (5 seconds / infinity value) is 0 seconds with "Division by infinity didn't return 0 seconds"

assert (5 seconds * 10 ^ 308) is {@max-timespan} with "failed to clamp to the long max value"
assert (5 seconds * 10 ^ 308) is {@max-timespan} with "failed to clamp to the max long value"
Loading