diff --git a/config/src/main/java/net/md_5/bungee/config/Configuration.java b/config/src/main/java/net/md_5/bungee/config/Configuration.java index a7ddf3a38e..2b29614ae1 100644 --- a/config/src/main/java/net/md_5/bungee/config/Configuration.java +++ b/config/src/main/java/net/md_5/bungee/config/Configuration.java @@ -91,6 +91,11 @@ public T get(String path, T def) return ( val != null ) ? (T) val : def; } + public boolean contains(String path) + { + return get( path, null ) != null; + } + public Object get(String path) { return get( path, getDefault( path ) ); diff --git a/config/src/test/java/net/md_5/bungee/config/YamlConfigurationTest.java b/config/src/test/java/net/md_5/bungee/config/YamlConfigurationTest.java index c400b92fed..589d3ee46d 100644 --- a/config/src/test/java/net/md_5/bungee/config/YamlConfigurationTest.java +++ b/config/src/test/java/net/md_5/bungee/config/YamlConfigurationTest.java @@ -94,6 +94,12 @@ private void testSection(Configuration conf) conf.set( "other.new.section", "bar" ); Assert.assertEquals( "bar", conf.get( "other.new.section" ) ); + + Assert.assertTrue( conf.contains( "customer.given" ) ); + Assert.assertTrue( customer.contains( "given" ) ); + + Assert.assertFalse( conf.contains( "customer.foo" ) ); + Assert.assertFalse( customer.contains( "foo" ) ); } @Test