#2524: Allow empty groups/permissions

This commit is contained in:
md_5 2018-12-21 10:35:57 +11:00
parent d689ba5904
commit a9a4c900e4

View File

@ -83,23 +83,23 @@ public class YamlConfig implements ConfigurationAdapter
throw new RuntimeException( "Could not load configuration!", ex ); throw new RuntimeException( "Could not load configuration!", ex );
} }
Map<String, Object> permissions = get( "permissions", new HashMap<String, Object>() ); Map<String, Object> permissions = get( "permissions", null );
if ( permissions.isEmpty() ) if ( permissions == null )
{ {
permissions.put( "default", Arrays.asList( new String[] set( "permissions.default", Arrays.asList( new String[]
{ {
"bungeecord.command.server", "bungeecord.command.list" "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" "bungeecord.command.alert", "bungeecord.command.end", "bungeecord.command.ip", "bungeecord.command.reload"
} ) ); } ) );
} }
Map<String, Object> groups = get( "groups", new HashMap<String, Object>() ); Map<String, Object> groups = get( "groups", null );
if ( groups.isEmpty() ) 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") @SuppressWarnings("unchecked")
private void set(String path, Object val, Map submap) private void set(String path, Object val, Map submap)
{ {