mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Num util
This commit is contained in:
parent
353c40cc46
commit
a7e78cc3fb
@ -23,6 +23,8 @@ import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
|
|||||||
import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
|
import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public interface DecreeParameterHandler<T> {
|
public interface DecreeParameterHandler<T> {
|
||||||
/**
|
/**
|
||||||
* Should return the possible values for this type
|
* Should return the possible values for this type
|
||||||
@ -111,4 +113,55 @@ public interface DecreeParameterHandler<T> {
|
|||||||
{
|
{
|
||||||
return "NOEXAMPLE";
|
return "NOEXAMPLE";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default double getMultiplier(AtomicReference<String> g)
|
||||||
|
{
|
||||||
|
double multiplier = 1;
|
||||||
|
String in = g.get();
|
||||||
|
boolean valid = true;
|
||||||
|
while(valid) {
|
||||||
|
boolean trim = false;
|
||||||
|
if (in.toLowerCase().endsWith("k"))
|
||||||
|
{
|
||||||
|
multiplier *= 1000;
|
||||||
|
trim = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(in.toLowerCase().endsWith("m"))
|
||||||
|
{
|
||||||
|
multiplier *= 1000000;
|
||||||
|
trim = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(in.toLowerCase().endsWith("h"))
|
||||||
|
{
|
||||||
|
multiplier *= 100;
|
||||||
|
trim = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(in.toLowerCase().endsWith("c"))
|
||||||
|
{
|
||||||
|
multiplier *= 16;
|
||||||
|
trim = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(in.toLowerCase().endsWith("r"))
|
||||||
|
{
|
||||||
|
multiplier *= (16 * 32);
|
||||||
|
trim = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(trim)
|
||||||
|
{
|
||||||
|
in = in.substring(0, in.length() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g.set(in);
|
||||||
|
return multiplier;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user