Ejemplo n.º 1
0
 public override void OnPlayerServerSelection(PluginResultEventArgs<RemoteServerInfo> args)
 {
     foreach (PluginBase item in _triggerPlugins)
     {
         try
         {
             item.OnPlayerServerSelection(args);
         }
         catch (Exception ex)
         {
             _logger.Warn("Could not pass event 'OnPlayerServerSelection' to " + item.Name, ex);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///   Get the minecraft protocol server of a given minecraft server.
        /// </summary>
        /// <param name="proxyConnection"> The connection this server relates to. </param>
        /// <param name="serverEndPoint"> The current version of the Remote server info. </param>
        public void GetServerVersion(IProxyConnection proxyConnection, RemoteServerInfo serverEndPoint)
        {
            var args = new PluginResultEventArgs<RemoteServerInfo>(serverEndPoint, proxyConnection);

            PluginManager.TriggerPlugin.GetServerVersion(args);

            args.EnsureSuccess ();

            if (serverEndPoint.MinecraftVersion == 0)
            {
                //Look up configuration

                ProxyConfigurationSection settings = ProxyConfigurationSection.Settings;

                IEnumerable<ServerElement> serverList =
                    settings.Server.OfType<ServerElement> ().Where(
                        m => m.EndPoint == serverEndPoint.EndPoint.ToString ());

                ServerElement server = serverList.FirstOrDefault ();

                if (server != null) serverEndPoint.MinecraftVersion = server.MinecraftVersion;
                    //Use default
                else serverEndPoint.MinecraftVersion = ProtocolInformation.MaxSupportedServerVersion;
            }
        }
Ejemplo n.º 3
0
 public override void IsOnlineModeEnabled(PluginResultEventArgs<bool?> args)
 {
     foreach (PluginBase item in _triggerPlugins)
     {
         try
         {
             item.IsOnlineModeEnabled(args);
         }
         catch (Exception ex)
         {
             _logger.Warn("Could not pass event 'IsOnlineModeEnabled' to " + item.Name, ex);
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        ///   Returns true if the online mode is enabled for a specific user or not.
        /// </summary>
        /// <param name="proxyConnection"> The proxy connection which should be checked </param>
        /// <returns> true if the online mode is enabled, otherwise false. </returns>
        public bool OnlineModeEnabled(IProxyConnection proxyConnection)
        {
            var args = new PluginResultEventArgs<bool?>(null, proxyConnection);
            PluginManager.TriggerPlugin.IsOnlineModeEnabled(args);


            if (args.Result == null)
                return OnlineMode;
            return (bool) args.Result;
        }
Ejemplo n.º 5
0
        /// <summary>
        ///   Get a new server end point for a given proxy connection to.
        /// </summary>
        /// <param name="proxyConnection"> The proxy connection which need a new server connection. </param>
        /// <returns> A RemoteServerInfo object which contains important information about the new backend server. </returns>
        public RemoteServerInfo GetServerEndPoint(IProxyConnection proxyConnection)
        {
            ProxyConfigurationSection settings = ProxyConfigurationSection.Settings;

            IOrderedEnumerable<ServerElement> server =
                settings.Server.OfType<ServerElement> ().Where(
                    m => m.IsDefault || (!string.IsNullOrEmpty(m.DnsName) && proxyConnection.Host.StartsWith(m.DnsName)))
                    .OrderBy(m => m.IsDefault);

            ServerElement possibleResult = server.FirstOrDefault ();
            RemoteServerInfo result = possibleResult == null
                                          ? null
                                          : new RemoteServerInfo(possibleResult.Name,
                                                                 Extensions.ParseEndPoint(possibleResult.EndPoint),
                                                                 possibleResult.MinecraftVersion)
                                                {
                                                    KickMessage = possibleResult.KickMessage
                                                };

            var args = new PluginResultEventArgs<RemoteServerInfo>(result, proxyConnection);
            PluginManager.TriggerPlugin.OnPlayerServerSelection(args);
            args.EnsureSuccess ();
            return args.Result;
        }
Ejemplo n.º 6
0
 /// <summary>
 ///   IN this method plugins can specify the protocol version of the server the proxy should connect to
 /// </summary>
 /// <param name="args"> Gives information about server and client </param>
 public virtual void GetServerVersion(PluginResultEventArgs<RemoteServerInfo> args)
 {
 }
Ejemplo n.º 7
0
 /// <summary>
 ///   In this method a plugin can specify if the server should respond to be in online-mode or offline-mode. 
 ///   This can be used to allow administrators to join if minecraft.net is down
 /// </summary>
 /// <param name="args"> The argument contains information about the user and the result of this call. true means authentification enabled, false means authentification disabled. if the result is null the option in the server configuration file is used </param>
 public virtual void IsOnlineModeEnabled(PluginResultEventArgs<bool?> args)
 {
 }
Ejemplo n.º 8
0
 /// <summary>
 ///   This method is called when the proxy server needs to know to which backend server it should connect to. A plugin can change it, specify the minecraft version,
 ///   or cancel it to kick the user.
 /// </summary>
 /// <param name="args"> A UserEventArgs which give access to relevant operations like reading user information, and the current server which is a connect candidate, or methods to cancel the request </param>
 public virtual void OnPlayerServerSelection(PluginResultEventArgs<RemoteServerInfo> args)
 {
 }