Load Permissions synchronously

This commit is contained in:
Fabrizio La Rosa 2020-06-13 06:17:54 +02:00
parent 8cb8f9578f
commit a4e80241b9

View File

@ -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) {