mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
v 1.9:
Optimize populating Bukkit perms so we no longer calculate the child nodes (Bukkit already does this).
This commit is contained in:
parent
1a0b03db4d
commit
89c41b0508
5 changed files with 58 additions and 30 deletions
|
@ -102,3 +102,5 @@ v 1.8:
|
||||||
You can now mirror groups.yml, users.yml or both files between different worlds.
|
You can now mirror groups.yml, users.yml or both files between different worlds.
|
||||||
- Catch NullPointerErrors generated by blank permission nodes.
|
- Catch NullPointerErrors generated by blank permission nodes.
|
||||||
- Removed '- bukkit.command' form the globalgroups permission nodes.
|
- Removed '- bukkit.command' form the globalgroups permission nodes.
|
||||||
|
v 1.9:
|
||||||
|
- Optimize populating Bukkit perms so we no longer calculate the child nodes (Bukkit already does this).
|
|
@ -90,13 +90,24 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns All permissions (including inheritance and sub groups) for the
|
* Returns All permissions (including inheritance and sub groups) for the
|
||||||
* player.
|
* player, including child nodes from Bukkit.
|
||||||
*
|
*
|
||||||
* @param userName
|
* @param userName
|
||||||
* @return List<String> of all players permissions.
|
* @return List<String> of all players permissions.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> getAllPlayersPermissions(String userName) {
|
public List<String> getAllPlayersPermissions(String userName) {
|
||||||
|
return getAllPlayersPermissions(userName, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns All permissions (including inheritance and sub groups) for the
|
||||||
|
* player. With or without Bukkit child nodes.
|
||||||
|
*
|
||||||
|
* @param userName
|
||||||
|
* @return List<String> of all players permissions.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<String> getAllPlayersPermissions(String userName, Boolean includeChildren) {
|
||||||
|
|
||||||
List<String> playerPermArray = new ArrayList<String>();
|
List<String> playerPermArray = new ArrayList<String>();
|
||||||
|
|
||||||
|
@ -104,6 +115,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||||
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-" + perm))) {
|
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-" + perm))) {
|
||||||
playerPermArray.add(perm);
|
playerPermArray.add(perm);
|
||||||
|
|
||||||
|
if (includeChildren) {
|
||||||
Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren(perm, playerPermArray);
|
Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren(perm, playerPermArray);
|
||||||
|
|
||||||
if (children != null) {
|
if (children != null) {
|
||||||
|
@ -116,12 +128,14 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (String group : getGroups(userName)) {
|
for (String group : getGroups(userName)) {
|
||||||
if (group.startsWith("g:") && GroupManager.getGlobalGroups().hasGroup(group)) {
|
if (group.startsWith("g:") && GroupManager.getGlobalGroups().hasGroup(group)) {
|
||||||
for (String perm : GroupManager.getGlobalGroups().getGroupsPermissions(group)) {
|
for (String perm : GroupManager.getGlobalGroups().getGroupsPermissions(group)) {
|
||||||
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-" + perm))) {
|
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-" + perm))) {
|
||||||
playerPermArray.add(perm);
|
playerPermArray.add(perm);
|
||||||
|
|
||||||
|
if (includeChildren) {
|
||||||
Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren(perm, playerPermArray);
|
Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren(perm, playerPermArray);
|
||||||
if (children != null) {
|
if (children != null) {
|
||||||
for (String child : children.keySet()) {
|
for (String child : children.keySet()) {
|
||||||
|
@ -132,11 +146,13 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (String perm : ph.getGroup(group).getPermissionList()) {
|
for (String perm : ph.getGroup(group).getPermissionList()) {
|
||||||
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-" + perm))) {
|
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-" + perm))) {
|
||||||
playerPermArray.add(perm);
|
playerPermArray.add(perm);
|
||||||
|
|
||||||
|
if (includeChildren) {
|
||||||
Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren(perm, playerPermArray);
|
Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren(perm, playerPermArray);
|
||||||
if (children != null) {
|
if (children != null) {
|
||||||
for (String child : children.keySet()) {
|
for (String child : children.keySet()) {
|
||||||
|
@ -150,6 +166,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Collections.sort(playerPermArray,
|
// Collections.sort(playerPermArray,
|
||||||
// StringPermissionComparator.getInstance());
|
// StringPermissionComparator.getInstance());
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class BukkitPermissions {
|
||||||
|
|
||||||
public BukkitPermissions(GroupManager plugin) {
|
public BukkitPermissions(GroupManager plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
//this.collectPermissions();
|
this.collectPermissions();
|
||||||
this.registerEvents();
|
this.registerEvents();
|
||||||
this.updateAllPlayers();
|
this.updateAllPlayers();
|
||||||
|
|
||||||
|
@ -105,16 +105,21 @@ public class BukkitPermissions {
|
||||||
manager.registerEvent(Event.Type.PLUGIN_DISABLE, serverListener, Event.Priority.Normal, plugin);
|
manager.registerEvent(Event.Type.PLUGIN_DISABLE, serverListener, Event.Priority.Normal, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public void collectPermissions() {
|
public void collectPermissions() {
|
||||||
registeredPermissions.clear();
|
registeredPermissions.clear();
|
||||||
|
/*
|
||||||
for (Plugin bukkitPlugin : Bukkit.getServer().getPluginManager().getPlugins()) {
|
for (Plugin bukkitPlugin : Bukkit.getServer().getPluginManager().getPlugins()) {
|
||||||
for (Permission permission : bukkitPlugin.getDescription().getPermissions())
|
for (Permission permission : bukkitPlugin.getDescription().getPermissions())
|
||||||
registeredPermissions.push(permission);
|
registeredPermissions.push(permission);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
registeredPermissions = new LinkedList<Permission>(Bukkit.getPluginManager().getPermissions());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void updatePermissions(Player player) {
|
public void updatePermissions(Player player) {
|
||||||
this.updatePermissions(player, null);
|
this.updatePermissions(player, null);
|
||||||
}
|
}
|
||||||
|
@ -194,7 +199,7 @@ public class BukkitPermissions {
|
||||||
|
|
||||||
// Add all permissions for this player (GM only)
|
// Add all permissions for this player (GM only)
|
||||||
// child nodes will be calculated by Bukkit.
|
// child nodes will be calculated by Bukkit.
|
||||||
List<String> playerPermArray = worldData.getPermissionsHandler().getAllPlayersPermissions(player.getName());
|
List<String> playerPermArray = worldData.getPermissionsHandler().getAllPlayersPermissions(player.getName(), false);
|
||||||
Map<String, Boolean> newPerms = new HashMap<String, Boolean>();
|
Map<String, Boolean> newPerms = new HashMap<String, Boolean>();
|
||||||
|
|
||||||
for (String permission : playerPermArray) {
|
for (String permission : playerPermArray) {
|
||||||
|
@ -210,6 +215,7 @@ public class BukkitPermissions {
|
||||||
*/
|
*/
|
||||||
newPerms.put(permission, value);
|
newPerms.put(permission, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//player.recalculatePermissions();
|
//player.recalculatePermissions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -373,13 +379,13 @@ public class BukkitPermissions {
|
||||||
if (!GroupManager.isLoaded())
|
if (!GroupManager.isLoaded())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//collectPermissions();
|
collectPermissions();
|
||||||
updateAllPlayers();
|
updateAllPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPluginDisable(PluginDisableEvent event) {
|
public void onPluginDisable(PluginDisableEvent event) {
|
||||||
// collectPermissions();
|
collectPermissions();
|
||||||
// updateAllPlayers();
|
// updateAllPlayers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,4 +234,6 @@ public abstract class PermissionsReaderInterface {
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
public abstract List<String> getAllPlayersPermissions(String userName);
|
public abstract List<String> getAllPlayersPermissions(String userName);
|
||||||
|
|
||||||
|
public abstract List<String> getAllPlayersPermissions(String userName, Boolean includeChildren);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
name: GroupManager
|
name: GroupManager
|
||||||
version: "1.8 (Phoenix)"
|
version: GMBuildVer (Phoenix)
|
||||||
main: org.anjocaido.groupmanager.GroupManager
|
main: org.anjocaido.groupmanager.GroupManager
|
||||||
website: http://www.anjocaido.info/
|
website: http://www.anjocaido.info/
|
||||||
description: Provides on-the-fly system for permissions system created by Nijikokun. But all in memory, and with flat-file saving schedule.
|
description: Provides on-the-fly system for permissions system created by Nijikokun. But all in memory, and with flat-file saving schedule.
|
||||||
authors:
|
authors:
|
||||||
- AnjoCaido
|
- AnjoCaido
|
||||||
- Gabriel Couto
|
- Gabriel Couto
|
||||||
|
- ElgarL
|
||||||
commands:
|
commands:
|
||||||
manuadd:
|
manuadd:
|
||||||
description: Move a player to desired group.(Adds to the file if not exists)
|
description: Move a player to desired group.(Adds to the file if not exists)
|
||||||
|
|
Loading…
Reference in a new issue