/// <summary> /// checks if a user account is valid using plugins and the minecraft.net services /// </summary> /// <param name="proxyConnection"> The proxy server which should be checked. </param> /// <param name="hash"> The 'serverId' hash </param> /// <returns> true if the user account is okay, otherwise false </returns> public async Task<bool> CheckUserAccountAsync(ProxyConnection proxyConnection, string hash) { var args = new CheckAccountEventArgs(null, hash, proxyConnection); await PluginManager.TriggerPlugin.OnUserAccountCheckAsync(args); args.EnsureSuccess (); if (args.Result == null) { try { bool? result = await UserAccountServices.CheckAccountAsync(proxyConnection.Username, hash); if (result.HasValue) return result.Value; _logger.Error("Could not access minecraft.net"); return false; } catch (Exception ex) { _logger.Error("minecraft.net not accessible", ex); return false; } } return (bool) args.Result; }
public override async Task OnUserAccountCheckAsync(CheckAccountEventArgs args) { foreach (PluginBase item in _triggerPlugins) { try { await item.OnUserAccountCheckAsync(args); } catch (Exception ex) { _logger.Warn("Could not pass event 'OnUserAccountCheckAsync' to " + item.Name, ex); } } }
/// <summary> /// In this method a plugin can specify, if a user account is allowed to join with this specific server hash. /// if no plugin specify it the proxy server will contact minecraft.net to check user accounts. /// </summary> /// <param name="args"> Contains the user connection object and the user hash. A plugin can kick users by setting the call canceled </param> /// <returns> </returns> public virtual Task OnUserAccountCheckAsync(CheckAccountEventArgs args) { return Task.FromResult(0); }