Exemple #1
0
        /// <summary>
        /// Gets a protection
        /// </summary>
        /// <param name="whereami"></param>
        /// <returns></returns>
        public async Task <ProtectedWorld> GetProtectionAsync(World world)
        {
            ProtectedWorld pw = new ProtectedWorld(this, world);

            if (!await pw.LoadAsync(Server.DbContext))
            {
                return(null);
            }
            return(pw);
        }
Exemple #2
0
        /// <summary>
        /// Sets or Creates a world protection
        /// </summary>
        /// <param name="whereami"></param>
        /// <param name="mode"></param>
        /// <param name="allowAnonymous"></param>
        /// <returns></returns>
        public async Task <ProtectedWorld> SetProtectionAsync(World world, WhitelistMode mode, bool allowAnonymous)
        {
            var protection = await GetProtectionAsync(world);

            if (protection == null)
            {
                protection = new ProtectedWorld(this, world);
            }

            protection.Mode           = mode;
            protection.AllowAnonymous = allowAnonymous;
            await protection.SaveAsync(DbContext);

            return(protection);
        }
Exemple #3
0
        private async void OnPlayerUpdate(Player player)
        {
            if (player.Location == null)
            {
                return;
            }

            //Load the protected world
            ProtectedWorld pw = await GetProtectionAsync(player.Location);

            if (pw != null && !(await pw.CheckPermissionAsync(player)))
            {
                Logger.Log("Player {0} is not allowed in world {1} because of {2}", player, pw.World, pw.Mode);
                await Server.Kick(player, KickFormat.Replace("{mode}", pw.Mode.ToString()));
            }
        }
Exemple #4
0
 public ListedAccount(ProtectedWorld protection, string account)
 {
     ProtectionId = protection.Id;
     AccountName  = account;
 }
Exemple #5
0
 /// <summary>
 /// Removes a world protection
 /// </summary>
 /// <param name="world"></param>
 /// <returns></returns>
 public async Task <bool> RemoveProtectionAsync(ProtectedWorld world)
 {
     return(await world.DeleteAsync());
 }