Commits

md_5 authored c86a051a8ee
SPIGOT-3409: Improve performance of registering stupid amounts of permissions in plugin.yml
No tags

src/main/java/org/bukkit/plugin/SimplePluginManager.java

Modified
582 582 throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName() + ". Static getHandlerList method required!");
583 583 }
584 584 }
585 585 }
586 586
587 587 public Permission getPermission(String name) {
588 588 return permissions.get(name.toLowerCase(java.util.Locale.ENGLISH));
589 589 }
590 590
591 591 public void addPermission(Permission perm) {
592 + addPermission(perm, true);
593 + }
594 +
595 + @Deprecated
596 + public void addPermission(Permission perm, boolean dirty) {
592 597 String name = perm.getName().toLowerCase(java.util.Locale.ENGLISH);
593 598
594 599 if (permissions.containsKey(name)) {
595 600 throw new IllegalArgumentException("The permission " + name + " is already defined!");
596 601 }
597 602
598 603 permissions.put(name, perm);
599 - calculatePermissionDefault(perm);
604 + calculatePermissionDefault(perm, dirty);
600 605 }
601 606
602 607 public Set<Permission> getDefaultPermissions(boolean op) {
603 608 return ImmutableSet.copyOf(defaultPerms.get(op));
604 609 }
605 610
606 611 public void removePermission(Permission perm) {
607 612 removePermission(perm.getName());
608 613 }
609 614
610 615 public void removePermission(String name) {
611 616 permissions.remove(name.toLowerCase(java.util.Locale.ENGLISH));
612 617 }
613 618
614 619 public void recalculatePermissionDefaults(Permission perm) {
615 620 if (perm != null && permissions.containsKey(perm.getName().toLowerCase(java.util.Locale.ENGLISH))) {
616 621 defaultPerms.get(true).remove(perm);
617 622 defaultPerms.get(false).remove(perm);
618 623
619 - calculatePermissionDefault(perm);
624 + calculatePermissionDefault(perm, true);
620 625 }
621 626 }
622 627
623 - private void calculatePermissionDefault(Permission perm) {
628 + private void calculatePermissionDefault(Permission perm, boolean dirty) {
624 629 if ((perm.getDefault() == PermissionDefault.OP) || (perm.getDefault() == PermissionDefault.TRUE)) {
625 630 defaultPerms.get(true).add(perm);
626 - dirtyPermissibles(true);
631 + if (dirty) {
632 + dirtyPermissibles(true);
633 + }
627 634 }
628 635 if ((perm.getDefault() == PermissionDefault.NOT_OP) || (perm.getDefault() == PermissionDefault.TRUE)) {
629 636 defaultPerms.get(false).add(perm);
630 - dirtyPermissibles(false);
637 + if (dirty) {
638 + dirtyPermissibles(false);
639 + }
631 640 }
632 641 }
633 642
643 + @Deprecated
644 + public void dirtyPermissibles() {
645 + dirtyPermissibles(true);
646 + dirtyPermissibles(false);
647 + }
648 +
634 649 private void dirtyPermissibles(boolean op) {
635 650 Set<Permissible> permissibles = getDefaultPermSubscriptions(op);
636 651
637 652 for (Permissible p : permissibles) {
638 653 p.recalculatePermissions();
639 654 }
640 655 }
641 656
642 657 public void subscribeToPermission(String permission, Permissible permissible) {
643 658 String name = permission.toLowerCase(java.util.Locale.ENGLISH);

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut