mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-09-27 22:17:35 +02:00
Allow loading of different numbers to BigDecimal (Fixes #225)
Also catch wrong types when loading the config better without completely disabling the plugin and revert "Make sure special parsers are setup" and register the parsers static again.
This commit is contained in:
parent
da1dd94705
commit
4769ae2cf7
@ -63,9 +63,7 @@ public class Configuration {
|
|||||||
writer.write(FieldParser.parse(field));
|
writer.write(FieldParser.parse(field));
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalArgumentException | IllegalAccessException | IOException e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,6 @@ public class ChestShop extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadConfig() {
|
public void loadConfig() {
|
||||||
Properties.setup();
|
|
||||||
Configuration.pairFileAndClass(loadFile("config.yml"), Properties.class);
|
Configuration.pairFileAndClass(loadFile("config.yml"), Properties.class);
|
||||||
Configuration.pairFileAndClass(loadFile("local.yml"), Messages.class);
|
Configuration.pairFileAndClass(loadFile("local.yml"), Messages.class);
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import java.util.logging.Level;
|
|||||||
*/
|
*/
|
||||||
public class Properties {
|
public class Properties {
|
||||||
|
|
||||||
public static void setup() {
|
static {
|
||||||
Configuration.registerParser("StringSet", new ValueParser(){
|
Configuration.registerParser("StringSet", new ValueParser(){
|
||||||
public Object parseToJava(Object object) {
|
public Object parseToJava(Object object) {
|
||||||
if (object instanceof Collection) {
|
if (object instanceof Collection) {
|
||||||
@ -62,6 +62,10 @@ public class Properties {
|
|||||||
public Object parseToJava(Object object) {
|
public Object parseToJava(Object object) {
|
||||||
if (object instanceof Double) {
|
if (object instanceof Double) {
|
||||||
return BigDecimal.valueOf((Double) object);
|
return BigDecimal.valueOf((Double) object);
|
||||||
|
} else if (object instanceof Long) {
|
||||||
|
return BigDecimal.valueOf((Long) object);
|
||||||
|
} else if (object instanceof Integer) {
|
||||||
|
return BigDecimal.valueOf((Integer) object);
|
||||||
}
|
}
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user