public Player(MiNetServer server, IPEndPoint endPoint, Level level, PluginManager pluginManager, int mtuSize) : base(-1, level) { Rtt = -1; Width = 0.6; Length = 0.6; Height = 1.80; Popups = new List<Popup>(); Server = server; EndPoint = endPoint; _mtuSize = mtuSize; Level = level; _pluginManager = pluginManager; Permissions = new PermissionManager(UserGroup.User); Permissions.AddPermission("*"); //All users can use all commands. (For debugging purposes) Inventory = new PlayerInventory(this); _chunksUsed = new Dictionary<Tuple<int, int>, ChunkColumn>(); IsSpawned = false; IsConnected = true; KnownPosition = new PlayerLocation { X = Level.SpawnPoint.X, Y = Level.SpawnPoint.Y, Z = Level.SpawnPoint.Z, Yaw = 91, Pitch = 28, HeadYaw = 91 }; _sendTicker = new Timer(SendQueue, null, 10, 10); // RakNet send tick-time }
public bool StartServer() { if (_listener != null) return false; // Already started try { Log.Info("Initializing..."); InacvitityTimeout = Config.GetProperty("InacvitityTimeout", 8500); if (Endpoint == null) { var ip = IPAddress.Parse(Config.GetProperty("ip", "0.0.0.0")); int port = Config.GetProperty("port", 19132); Endpoint = new IPEndPoint(ip, port); } ForwardAllPlayers = Config.GetProperty("ForwardAllPlayers", false); if (ForwardAllPlayers) { var ip = IPAddress.Parse(Config.GetProperty("ForwardIP", "127.0.0.1")); int port = Config.GetProperty("ForwardPort", 19132); ForwardTarget = new IPEndPoint(ip, port); } Log.Info("Loading plugins..."); PluginManager = new PluginManager(); PluginManager.LoadPlugins(); Log.Info("Plugins loaded!"); // Bootstrap server PluginManager.ExecuteStartup(this); MotdProvider = MotdProvider ?? new MotdProvider(); IsSecurityEnabled = Config.GetProperty("EnableSecurity", false); if (IsSecurityEnabled) { // http://www.asp.net/identity/overview/extensibility/overview-of-custom-storage-providers-for-aspnet-identity UserManager = UserManager ?? new UserManager<User>(new DefaultUserStore()); RoleManager = RoleManager ?? new RoleManager<Role>(new DefaultRoleStore()); } GreylistManager = GreylistManager ?? new GreylistManager(this); SessionManager = SessionManager ?? new SessionManager(); LevelManager = LevelManager ?? new LevelManager(); PlayerFactory = PlayerFactory ?? new PlayerFactory(); // Cache - remove LevelManager.GetLevel(null, "Default"); ServerInfo = new ServerInfo(LevelManager, _playerSessions); ServerInfo.MaxNumberOfPlayers = Config.GetProperty("MaxNumberOfPlayers", 1000); ServerInfo.MaxNumberOfConcurrentConnects = Config.GetProperty("MaxNumberOfConcurrentConnects", ServerInfo.MaxNumberOfPlayers); //for (int i = 1; i < 10; i++) //{ // Level level = LevelFactory.CreateLevel("" + i); // _levels.Add(level); //} PluginManager.EnablePlugins(this, LevelManager); _listener = new UdpClient(Endpoint); if (IsRunningOnMono()) { _listener.Client.ReceiveBufferSize = 1024*1024*3; _listener.Client.SendBufferSize = 4096; } else { //_listener.Client.ReceiveBufferSize = 1600*40000; _listener.Client.ReceiveBufferSize = int.MaxValue; //_listener.Client.SendBufferSize = 1600*40000; _listener.Client.SendBufferSize = int.MaxValue; _listener.DontFragment = false; _listener.EnableBroadcast = false; // SIO_UDP_CONNRESET (opcode setting: I, T==3) // Windows: Controls whether UDP PORT_UNREACHABLE messages are reported. // - Set to TRUE to enable reporting. // - Set to FALSE to disable reporting. uint IOC_IN = 0x80000000; uint IOC_VENDOR = 0x18000000; uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12; _listener.Client.IOControl((int) SIO_UDP_CONNRESET, new byte[] {Convert.ToByte(false)}, null); // //WARNING: We need to catch errors here to remove the code above. // } _ackTimer = new Timer(SendAckQueue, null, 0, 50); _cleanerTimer = new Timer(Update, null, 10, Timeout.Infinite); _listener.BeginReceive(ReceiveCallback, _listener); // Measure latency through system //_internalPingTimer = new Timer(delegate(object state) //{ // var playerSession = _playerSessions.Values.FirstOrDefault(); // if (playerSession != null) // { // var ping = new InternalPing(); // ping.Timer.Start(); // HandlePackage(ping, playerSession); // } //}, null, 1000, 1000); Log.Info("Server open for business on port " + Endpoint.Port + " ..."); return true; } catch (Exception e) { Log.Error("Error during startup!", e); StopServer(); } return false; }
/// <summary> /// Starts the server. /// </summary> /// <returns></returns> public bool StartServer() { if (_listener != null) return false; // Already started try { Log.Info("Initializing..."); Log.Info("Loading settings..."); Motd = Config.GetProperty("motd", "MiNET: MCPE Server"); Log.Info("Loading plugins..."); PluginManager = new PluginManager(); PluginManager.LoadPlugins(); Log.Info("Plugins loaded!"); // Bootstrap server PluginManager.ExecuteStartup(this); if (Config.GetProperty("EnableSecurity", false)) { // http://www.asp.net/identity/overview/extensibility/overview-of-custom-storage-providers-for-aspnet-identity UserManager = UserManager ?? new UserManager<User>(new DefaultUserStore()); RoleManager = RoleManager ?? new RoleManager<Role>(new DefaultRoleStore()); } SessionManager = SessionManager?? new SessionManager(); LevelFactory = LevelFactory ?? new LevelFactory(); PlayerFactory = PlayerFactory ?? new PlayerFactory(); _level = LevelFactory.CreateLevel("Default"); _levels.Add(_level); //for (int i = 1; i < 10; i++) //{ // Level level = LevelFactory.CreateLevel("" + i); // _levels.Add(level); //} PluginManager.EnablePlugins(this, _levels); _listener = new UdpClient(_endpoint); if (IsRunningOnMono()) { _listener.Client.ReceiveBufferSize = 1024*1024*3; _listener.Client.SendBufferSize = 4096; } else { _listener.Client.ReceiveBufferSize = int.MaxValue; //_listener.Client.SendBufferSize = 1024 * 1024 * 8; _listener.Client.SendBufferSize = int.MaxValue; //_listener.DontFragment = true; // SIO_UDP_CONNRESET (opcode setting: I, T==3) // Windows: Controls whether UDP PORT_UNREACHABLE messages are reported. // - Set to TRUE to enable reporting. // - Set to FALSE to disable reporting. uint IOC_IN = 0x80000000; uint IOC_VENDOR = 0x18000000; uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12; _listener.Client.IOControl((int) SIO_UDP_CONNRESET, new byte[] {Convert.ToByte(false)}, null); // //WARNING: We need to catch errors here to remove the code above. // } _ackTimer = new Timer(SendAckQueue, null, 0, 30); _cleanerTimer = new Timer(Update, null, 0, 10); _listener.BeginReceive(ReceiveCallback, _listener); // Measure latency through system //_internalPingTimer = new Timer(delegate(object state) //{ // var playerSession = _playerSessions.Values.FirstOrDefault(); // if (playerSession != null) // { // var ping = new InternalPing(); // ping.Timer.Start(); // HandlePackage(ping, playerSession); // } //}, null, 1000, 1000); Log.Info("Server open for business..."); return true; } catch (Exception e) { Log.Error(e); StopServer(); } return false; }
public PluginContext(MiNetServer server, PluginManager pluginManager, List<Level> levels) { Server = server; PluginManager = pluginManager; Levels = levels; }
public PluginContext(PluginManager pluginManager, List<Level> levels) { PluginManager = pluginManager; Levels = levels; }
public PluginContext(MiNetServer server, PluginManager pluginManager, LevelManager levelManager) { Server = server; PluginManager = pluginManager; LevelManager = levelManager; }