Add default permissions
This commit is contained in:
parent
ade3fe4311
commit
a22f57c1f5
@ -46,7 +46,7 @@ public class YamlConfig implements ConfigurationAdapter
|
|||||||
|
|
||||||
if (config == null)
|
if (config == null)
|
||||||
{
|
{
|
||||||
config = new LinkedHashMap<>();
|
config = new HashMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
@ -54,6 +54,25 @@ 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>());
|
||||||
|
if (permissions.isEmpty())
|
||||||
|
{
|
||||||
|
permissions.put("default", Arrays.asList(new String[]
|
||||||
|
{
|
||||||
|
"bungeecord.command.server", "bungeecord.command.list"
|
||||||
|
}));
|
||||||
|
permissions.put("admin", Arrays.asList(new String[]
|
||||||
|
{
|
||||||
|
"bungeecord.command.alert", "bungeecord.command.end", "bungeecord.command.ip", "bungeecord.command.reload"
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> groups = get("groups", new HashMap<String, Object>());
|
||||||
|
if (groups.isEmpty())
|
||||||
|
{
|
||||||
|
groups.put("md_5", Collections.singletonList("admin"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T get(String path, T def)
|
private <T> T get(String path, T def)
|
||||||
@ -87,7 +106,7 @@ public class YamlConfig implements ConfigurationAdapter
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
String first = path.substring(0, index);
|
String first = path.substring(0, index);
|
||||||
String second = path.substring(index, path.length());
|
String second = path.substring(index + 1, path.length());
|
||||||
Map sub = (Map) submap.get(first);
|
Map sub = (Map) submap.get(first);
|
||||||
return (sub != null) ? get(second, def, sub) : def;
|
return (sub != null) ? get(second, def, sub) : def;
|
||||||
}
|
}
|
||||||
@ -172,7 +191,7 @@ public class YamlConfig implements ConfigurationAdapter
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Collection<String> getGroups(String player)
|
public Collection<String> getGroups(String player)
|
||||||
{
|
{
|
||||||
return get("groups." + player, Collections.EMPTY_SET);
|
return get("groups." + player, Collections.singleton("default"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user