/// <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); }
/// <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); }
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())); } }
public ListedAccount(ProtectedWorld protection, string account) { ProtectionId = protection.Id; AccountName = account; }
/// <summary> /// Removes a world protection /// </summary> /// <param name="world"></param> /// <returns></returns> public async Task <bool> RemoveProtectionAsync(ProtectedWorld world) { return(await world.DeleteAsync()); }