From a9a4c900e45ca50abdcc34b68e215b4137db1a3a Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 21 Dec 2018 10:35:57 +1100 Subject: [PATCH] #2524: Allow empty groups/permissions --- .../java/net/md_5/bungee/conf/YamlConfig.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java b/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java index e15c24c1..4cfb13c0 100644 --- a/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java +++ b/proxy/src/main/java/net/md_5/bungee/conf/YamlConfig.java @@ -83,23 +83,23 @@ public class YamlConfig implements ConfigurationAdapter throw new RuntimeException( "Could not load configuration!", ex ); } - Map permissions = get( "permissions", new HashMap() ); - if ( permissions.isEmpty() ) + Map permissions = get( "permissions", null ); + if ( permissions == null ) { - permissions.put( "default", Arrays.asList( new String[] + set( "permissions.default", Arrays.asList( new String[] { "bungeecord.command.server", "bungeecord.command.list" } ) ); - permissions.put( "admin", Arrays.asList( new String[] + set( "permissions.admin", Arrays.asList( new String[] { "bungeecord.command.alert", "bungeecord.command.end", "bungeecord.command.ip", "bungeecord.command.reload" } ) ); } - Map groups = get( "groups", new HashMap() ); - if ( groups.isEmpty() ) + Map groups = get( "groups", null ); + if ( groups == null ) { - groups.put( "md_5", Collections.singletonList( "admin" ) ); + set( "groups.md_5", Collections.singletonList( "admin" ) ); } } @@ -136,6 +136,11 @@ public class YamlConfig implements ConfigurationAdapter } } + private void set(String path, Object val) + { + set( path, val, config ); + } + @SuppressWarnings("unchecked") private void set(String path, Object val, Map submap) {