コード例 #1
0
ファイル: VanillaWorld.cs プロジェクト: mctraveler/MineSharp
 void KickSlot(Client player)
 {
     player.TellSystem(Chat.Aqua, "Sorry your slot was taken over");
     player.SetWorld(World.Wait);
     player.TellSystem(Chat.Gold, "See /donate for guaranteed slot");
 }
コード例 #2
0
ファイル: VanillaWorld.cs プロジェクト: mctraveler/MineSharp
        public sealed override WorldSession Join(Client player)
        {	
            //reset scoreboard
            player.Score = null;

            if (Suspended)
            {
                player.TellSystem(Chat.Purple, "Vanilla is suspended by admin, it will be right back");
                return null;
            }

            StartBackend();

            lock (players)
            {
                int pc = 0;
                foreach (VanillaSession r in players)
                    if (r.Player.Settings.Cloaked == null)
                        pc++;
				
                if (pc >= MinecraftServer.MaxSlots && player.Settings.Cloaked == null)
                {
					
                    //Kick old player
                    //New visitors are given an advantage
                    if (player.Uptime.TotalMinutes < 15)
                    {
                        //Kick normal player
                        foreach (VanillaSession r in players)
                        {
                            if (r.Player.Settings.Cloaked != null)
                                continue;
                            if (Donors.IsDonor(r.Player))
                                continue;
                            if (r.Player.Uptime.TotalMinutes < 15)
                                continue;
                            KickSlot(r.Player);
                            World.Main.Say(Chat.Gray, r.Player.Name + " left its slot to " + player.Name + "(new)");
                            goto slotFree;
                        }
                    }
					
                    if (Donors.IsDonor(player.MinecraftUsername))
                    {
                        //Kick any non donor
                        foreach (VanillaSession r in players)
                        {
                            if (r.Player.Settings.Cloaked != null)
                                continue;
                            if (Donors.IsDonor(r.Player))
                                continue;
                            if (r.Player.Uptime.TotalMinutes < 15)
                                continue;
                            KickSlot(r.Player);
                            this.Say(Chat.Gray, r.Player.Name + " left its slot to donor " + player.Name);
                            goto slotFree;
                        }
                        foreach (VanillaSession r in players)
                        {
                            if (r.Player.Settings.Cloaked != null)
                                continue;
                            if (Donors.IsDonor(r.Player))
                                continue;
                            KickSlot(r.Player);
                            this.Say(Chat.Gray, r.Player.Name + " left its slot to donor " + player.Name);
                            goto slotFree;
                        }
                        goto slotFree;
                    }
					
                    //Block
                    Chat.ReadFile("full.txt", Chat.Aqua, player);
                    this.Say(Chat.DarkGreen, "No free slot for " + player.Name);
                    return null;
                }
				
                slotFree:
				
                var server = BackendManager.StartServer(ServerName);
                if(server.Running.WaitOne(10) == false)
                    Log.WriteServer("Timeout waiting for server to start");

                VanillaSession s = CreateSession(player);
                players.Add(s);
                base.Join(s);
#if DEBUG
                Console.WriteLine(s.Player.MinecraftUsername + " Joining Real: " + Players.Length);
#endif
                return s;
            }
			
        }
コード例 #3
0
ファイル: VanillaWorld.cs プロジェクト: mctraveler/MineSharp
 protected virtual VanillaSession CreateSession(Client player)
 {
     return new VanillaSession(this, player);
 }