mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-19 16:03:22 +02:00
switch to otterlib Num utility
This commit is contained in:
parent
c9cc006245
commit
b190792064
2 changed files with 2 additions and 42 deletions
|
@ -5,10 +5,10 @@ import com.google.gson.JsonSyntaxException;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
|
import one.oth3r.otterlib.base.Num;
|
||||||
import one.oth3r.otterlib.file.CustomFile;
|
import one.oth3r.otterlib.file.CustomFile;
|
||||||
import one.oth3r.otterlib.file.FileSettings;
|
import one.oth3r.otterlib.file.FileSettings;
|
||||||
import one.oth3r.sit.utl.Data;
|
import one.oth3r.sit.utl.Data;
|
||||||
import one.oth3r.sit.utl.Utl;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -370,7 +370,7 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
// skip if not the right size
|
// skip if not the right size
|
||||||
if (split.length < 3 || split.length > 4) continue;
|
if (split.length < 3 || split.length > 4) continue;
|
||||||
// if the other entries aren't correct, skip
|
// if the other entries aren't correct, skip
|
||||||
if (!Utl.Num.isNum(split[2])) continue;
|
if (!Num.isNum(split[2])) continue;
|
||||||
|
|
||||||
// make the block states list if possible
|
// make the block states list if possible
|
||||||
ArrayList<String> blockstates = new ArrayList<>();
|
ArrayList<String> blockstates = new ArrayList<>();
|
||||||
|
|
|
@ -60,46 +60,6 @@ public class Utl {
|
||||||
return Data.getSitEntities().values().stream().noneMatch(entity -> entity.getBlockPos().equals(pos));
|
return Data.getSitEntities().values().stream().noneMatch(entity -> entity.getBlockPos().equals(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Num {
|
|
||||||
|
|
||||||
public static boolean isInt(String string) {
|
|
||||||
try {
|
|
||||||
Integer.parseInt(string);
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Integer toInt(String s) {
|
|
||||||
// return an int no matter what
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(s);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
try {
|
|
||||||
return (int) Double.parseDouble(s);
|
|
||||||
} catch (NumberFormatException e2) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isNum(String s) {
|
|
||||||
// checks if int or a double
|
|
||||||
try {
|
|
||||||
Integer.parseInt(s);
|
|
||||||
return true;
|
|
||||||
} catch (NumberFormatException e1) {
|
|
||||||
try {
|
|
||||||
Double.parseDouble(s);
|
|
||||||
return true;
|
|
||||||
} catch (NumberFormatException e2) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final double HALF_BLOCK = 0.5;
|
public static final double HALF_BLOCK = 0.5;
|
||||||
public static final double CARPET = 0.062;
|
public static final double CARPET = 0.062;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue