From a4e80241b993069906bde30384b35dd31e5acae8 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 13 Jun 2020 06:17:54 +0200 Subject: [PATCH] Load Permissions synchronously --- .../permission/PermissionManager.java | 154 +++++++++--------- 1 file changed, 76 insertions(+), 78 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 558a71df..b0875307 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -26,86 +26,84 @@ public class PermissionManager { public PermissionManager(SkyBlock plugin) { this.plugin = plugin; - Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> { - // Load default permissions. - registerPermissions( - //Listening - new StoragePermission(plugin), - new DragonEggUsePermission(plugin), - new BeaconPermission(plugin), - new ProjectilePermission(plugin), - new DestroyPermission(plugin), - new AnvilPermission(plugin), - new BedPermission(plugin), - new BrewingPermission(plugin), - new WorkbenchPermission(plugin), - new DoorPermission(plugin), - new EnchantPermission(plugin), - new FurnacePermission(plugin), - new LeverButtonPermission(plugin), - new JukeboxPermission(plugin), - new HopperPermission(plugin), - new NoteblockPermission(plugin), - new RedstonePermission(plugin), - new GatePermission(plugin), - new DropperDispenserPermission(plugin), - new BucketPermission(plugin), - new WaterCollectionPermission(plugin), - new SpawnEggPermission(plugin), - new EntityPlacementPermission(plugin), - new FirePermission(plugin), - new TramplePermission(plugin), - new PressurePlatePermission(plugin), - new CakePermission(plugin), - new PlacePermission(plugin), - new LeashPermission(plugin), - new AnimalBreedingPermission(plugin), - new MinecartPermission(plugin), - new BoatPermission(plugin), - new TradingPermission(plugin), - new MilkingPermission(plugin), - new ShearingPermission(plugin), - new MobRidingPermission(plugin), - new HorseInventoryPermission(plugin), - new MobHurtingPermission(plugin), - new ArmorStandUsePermission(plugin), - new MonsterHurtingPermission(plugin), - new PvpPermission(plugin), - new HangingDestroyPermission(plugin), - new DamagePermission(plugin), - new ExplosionsPermission(plugin), - new MobTamingPermission(plugin), - new MobGriefingPermission(plugin), - new ExperienceOrbPickupPermission(plugin), - new NaturalMobSpawningPermission(), - new HungerPermission(plugin), - new PortalPermission(plugin), - new ItemPickupPermission(), - new ItemDropPermission(), - new FishingPermission(plugin), + // Load default permissions. + registerPermissions( + //Listening + new StoragePermission(plugin), + new DragonEggUsePermission(plugin), + new BeaconPermission(plugin), + new ProjectilePermission(plugin), + new DestroyPermission(plugin), + new AnvilPermission(plugin), + new BedPermission(plugin), + new BrewingPermission(plugin), + new WorkbenchPermission(plugin), + new DoorPermission(plugin), + new EnchantPermission(plugin), + new FurnacePermission(plugin), + new LeverButtonPermission(plugin), + new JukeboxPermission(plugin), + new HopperPermission(plugin), + new NoteblockPermission(plugin), + new RedstonePermission(plugin), + new GatePermission(plugin), + new DropperDispenserPermission(plugin), + new BucketPermission(plugin), + new WaterCollectionPermission(plugin), + new SpawnEggPermission(plugin), + new EntityPlacementPermission(plugin), + new FirePermission(plugin), + new TramplePermission(plugin), + new PressurePlatePermission(plugin), + new CakePermission(plugin), + new PlacePermission(plugin), + new LeashPermission(plugin), + new AnimalBreedingPermission(plugin), + new MinecartPermission(plugin), + new BoatPermission(plugin), + new TradingPermission(plugin), + new MilkingPermission(plugin), + new ShearingPermission(plugin), + new MobRidingPermission(plugin), + new HorseInventoryPermission(plugin), + new MobHurtingPermission(plugin), + new ArmorStandUsePermission(plugin), + new MonsterHurtingPermission(plugin), + new PvpPermission(plugin), + new HangingDestroyPermission(plugin), + new DamagePermission(plugin), + new ExplosionsPermission(plugin), + new MobTamingPermission(plugin), + new MobGriefingPermission(plugin), + new ExperienceOrbPickupPermission(plugin), + new NaturalMobSpawningPermission(), + new HungerPermission(plugin), + new PortalPermission(plugin), + new ItemPickupPermission(), + new ItemDropPermission(), + new FishingPermission(plugin), - // Basic - new MemberPermission(), - new VisitorPermission(), - new KickPermission(), - new BiomePermission(), - new KeepItemsOnDeathPermission(), - new UnbanPermission(), - new BanPermission(), - new BorderPermission(), - new FireSpreadPermission(), - new CoopPlayersPermission(), - new IslandPermission(), - new LeafDecayPermission(), - new WeatherPermission(), - new MainSpawnPermission(), - new VisitorSpawnPermission()); + // Basic + new MemberPermission(), + new VisitorPermission(), + new KickPermission(), + new BiomePermission(), + new KeepItemsOnDeathPermission(), + new UnbanPermission(), + new BanPermission(), + new BorderPermission(), + new FireSpreadPermission(), + new CoopPlayersPermission(), + new IslandPermission(), + new LeafDecayPermission(), + new WeatherPermission(), + new MainSpawnPermission(), + new VisitorSpawnPermission()); - registeredHandlers = registeredHandlers.stream().sorted(Comparator.comparingInt(h -> { - final PermissionHandler permissionHandler = h.getHandler().getAnnotation(PermissionHandler.class); - return permissionHandler.priority().ordinal(); - })).collect(Collectors.toList()); - }, 20L); + registeredHandlers = registeredHandlers.stream().sorted(Comparator.comparingInt(h -> { + final PermissionHandler permissionHandler = h.getHandler().getAnnotation(PermissionHandler.class); + return permissionHandler.priority().ordinal(); + })).collect(Collectors.toList()); } public boolean registerPermission(BasicPermission permission) {