mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-15 03:51:20 +01:00
Add getInt and getLong with bounds parameters.
This commit is contained in:
parent
7a84ed371b
commit
e0b2eb753c
@ -9,7 +9,7 @@ import org.yaml.snakeyaml.DumperOptions;
|
|||||||
public class RawConfigFile extends YamlConfiguration{
|
public class RawConfigFile extends YamlConfiguration{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return double within given bounds, with preset. Mainly used for hidden settings.
|
* Return a double value within given bounds, with preset.
|
||||||
*
|
*
|
||||||
* @param data
|
* @param data
|
||||||
* @param path
|
* @param path
|
||||||
@ -25,6 +25,40 @@ public class RawConfigFile extends YamlConfiguration{
|
|||||||
else return value;
|
else return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a long value within given bounds, with preset.
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @param path
|
||||||
|
* @param min
|
||||||
|
* @param max
|
||||||
|
* @param preset
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public long getLong(final String path, final long min, final long max, final long preset){
|
||||||
|
final long value = getLong(path, preset);
|
||||||
|
if (value < min) return min;
|
||||||
|
else if (value > max) return max;
|
||||||
|
else return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an int value within given bounds, with preset.
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @param path
|
||||||
|
* @param min
|
||||||
|
* @param max
|
||||||
|
* @param preset
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public long getInt(final String path, final int min, final int max, final int preset){
|
||||||
|
final int value = getInt(path, preset);
|
||||||
|
if (value < min) return min;
|
||||||
|
else if (value > max) return max;
|
||||||
|
else return value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to get a type id from the path somehow, return null if nothing found.<br>
|
* Attempt to get a type id from the path somehow, return null if nothing found.<br>
|
||||||
* Will attempt to interpret strings, will return negative or out of range values.
|
* Will attempt to interpret strings, will return negative or out of range values.
|
||||||
|
Loading…
Reference in New Issue
Block a user