Permalink
Browse files

Avoid recalculating entire permission set after every portal removal in

a batch.
  • Loading branch information...
Joshua Rogers
Joshua Rogers committed Feb 15, 2014
1 parent 229ebf2 commit 00ef9fc091701ab277b30d6a731b10f5cacf5ec1
@@ -167,10 +167,6 @@ private void addToUpperLists() {
allPortalFill.getChildren().put(this.fillPermission.getName(), true);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(all);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allPortals);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allPortalAccess);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allPortalExempt);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allPortalFill);
for(Player player : this.plugin.getServer().getOnlinePlayers()){
player.recalculatePermissions();
}
@@ -136,6 +136,10 @@ private void addUniquePortal(MultiverseWorld world, String name, MVPortal portal
}
public MVPortal removePortal(String portalName, boolean removeFromConfigs) {
return removePortal(portalName, removeFromConfigs, false);
}
private MVPortal removePortal(String portalName, boolean removeFromConfigs, boolean delayRecalculation) {
if (!isPortal(portalName)) {
return null;
}
@@ -155,16 +159,18 @@ public MVPortal removePortal(String portalName, boolean removeFromConfigs) {
Permission portalFill = this.plugin.getServer().getPluginManager().getPermission("multiverse.portal.fill.*");
if (exemptAccess != null) {
exemptAccess.getChildren().remove(removed.getExempt().getName());
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(exemptAccess);
}
if (portalAccess != null) {
portalAccess.getChildren().remove(removed.getPermission().getName());
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(portalAccess);
}
if (portalFill != null) {
portalFill.getChildren().remove(removed.getFillPermission().getName());
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(portalFill);
}
if (!delayRecalculation) {
recalculatePermissions();
}
if (MultiversePortals.ClearOnRemove) {
// Replace portal blocks in the portal with air. This keeps us from
// leaving behind portal blocks (which would take an unsuspecting
@@ -179,6 +185,14 @@ public MVPortal removePortal(String portalName, boolean removeFromConfigs) {
return removed;
}
private void recalculatePermissions() {
String[] permissionsNames = new String[] { "multiverse.portal.access.*", "multiverse.portal.exempt.*", "multiverse.portal.fill.*" };
for (String permissionName : permissionsNames) {
Permission permission = this.plugin.getServer().getPluginManager().getPermission(permissionName);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(permission);
}
}
public List<MVPortal> getAllPortals() {
return new ArrayList<MVPortal>(this.portals.values());
}
@@ -259,8 +273,9 @@ public boolean isPortal(String portalName) {
public void removeAll(boolean removeFromConfigs) {
List<String> iterList = new ArrayList<String>(this.portals.keySet());
for (String s : iterList) {
this.removePortal(s, removeFromConfigs);
this.removePortal(s, removeFromConfigs, true);
}
recalculatePermissions();
}
private void replaceInRegion(World world, MultiverseRegion removedRegion, Material oldMaterial, Material newMaterial) {

0 comments on commit 00ef9fc

Please sign in to comment.