Exemplo n.º 1
0
 public SkinViewer( fCraft.PlayerInfo player_ )
 {
     InitializeComponent();
     player = player_;
     PlayerInfo info = player;
     GetSetSkin();
     SetPlayerInfoText( info );
 }
Exemplo n.º 2
0
 public static void PlayerMoved(Player p, fCraft.Events.PlayerMovingEventArgs e)
 {
     if (p.Info.isInfected)
     {
         foreach (Player target in ZombiePlayers)
         {
             if (p.Position == target.Position && !target.Info.isInfected)
             {
                 _world.Players.Message("&c{0} infected {1}!", p.Name, target.Name);
                 target.Message("&cYou were infected by {0}", p.Name);
                 target.Info.isInfected = true;
             }
         }
     }
 }
Exemplo n.º 3
0
 static void Beat( fCraft.SchedulerTask scheduledTask )
 {
     if (fCraft.Server.IsShuttingDown) return;
         SendMinecraftNetBeat();
             SendWoMDirectBeat();
 }
Exemplo n.º 4
0
        //stolen from BuildingCommands
        #region DrawOneBlock
        static void DrawOneBlock ( Player player, Map map, Block drawBlock, Vector3I coord,
                                 BlockChangeContext context, ref int blocks, ref int blocksDenied, fCraft.Drawing.UndoState undoState ) {
            if ( map == null ) return;
            if ( player == null ) throw new ArgumentNullException( "player" );

            if ( !map.InBounds( coord ) ) return;
            Block block = map.GetBlock( coord );
            if ( block == drawBlock ) return;

            if ( player.CanPlace( map, coord, drawBlock, context ) != CanPlaceResult.Allowed ) {
                blocksDenied++;
                return;
            }

            map.QueueUpdate( new BlockUpdate( null, coord, drawBlock ) );
            Player.RaisePlayerPlacedBlockEvent( player, map, coord, block, drawBlock, context );

            if ( !undoState.IsTooLargeToUndo ) {
                if ( !undoState.Add( coord, block ) ) {
                    player.Message( "NOTE: This draw command is too massive to undo." );
                    player.LastDrawOp = null;
                }
            }
            blocks++;
        }
Exemplo n.º 5
0
        public PlayerViewer(fCraft.PlayerInfo player_)
        {
            InitializeComponent();
            player = player_;
            //PlayerInfo info = player;
            PlayerInfo info = player_;
            textBox1.Text = "";
            if (info.LastIP.Equals(System.Net.IPAddress.None))
            {
                textBox1.Text += String.Format("About {0}: \r\n Never seen before.", info.ClassyName);

            }
            else
            {
                if (info != null)
                {
                    TimeSpan idle = info.PlayerObject.IdleTime;
                    if (info.IsHidden)
                    {
                        if (idle.TotalMinutes > 2)
                        {
                            if (player.Can(Permission.ViewPlayerIPs))
                            {
                                textBox1.Text += String.Format("About {0}: HIDDEN from {1} (idle {2})\r\n",
                                                info.Name,
                                                info.LastIP,
                                                idle.ToMiniString());
                            }
                            else
                            {
                                textBox1.Text += String.Format("About {0}:\r\n HIDDEN (idle {1})\r\n",
                                                info.Name,
                                                idle.ToMiniString());
                            }
                        }
                        else
                        {
                            if (player.Can(Permission.ViewPlayerIPs))
                            {
                                textBox1.Text += String.Format("About {0}:\r\n HIDDEN. Online from {1}\r\n",
                                                info.Name,
                                                info.LastIP);
                            }
                            else
                            {
                                textBox1.Text += String.Format("About {0}: HIDDEN.\r\n",
                                                info.Name);
                            }
                        }
                    }
                    else
                    {
                        if (idle.TotalMinutes > 1)
                        {
                            if (player.Can(Permission.ViewPlayerIPs))
                            {
                                textBox1.Text += String.Format("About {0}:\r\n Online now from {1} (idle {2})\r\n",
                                                info.Name,
                                                info.LastIP,
                                                idle.ToMiniString());
                            }
                            else
                            {
                                textBox1.Text += String.Format("About {0}:\r\n Online now (idle {1})\r\n",
                                                info.Name,
                                                idle.ToMiniString());
                            }
                        }
                        else
                        {
                            if (player.Can(Permission.ViewPlayerIPs))
                            {
                                textBox1.Text += String.Format("About {0}:\r\n Online now from {1}\r\n",
                                                info.Name,
                                                info.LastIP);
                            }
                            else
                            {
                                textBox1.Text += String.Format("About {0}:\r\n Online now.\r\n",
                                                info.Name);
                            }
                        }
                    }
                }
                else
                {
                    if (player.Can(Permission.ViewPlayerIPs))
                    {
                        if (info.LeaveReason != LeaveReason.Unknown)
                        {
                            textBox1.Text += String.Format("About {0}:\r\n Last seen {1} ago from {2} ({3}).\r\n",
                                            info.Name,
                                            info.TimeSinceLastSeen.ToMiniString(),
                                            info.LastIP,
                                            info.LeaveReason);
                        }
                        else
                        {
                            textBox1.Text += String.Format("About {0}:\r\n Last seen {1} ago from {2}.\r\n",
                                            info.Name,
                                            info.TimeSinceLastSeen.ToMiniString(),
                                            info.LastIP);
                        }
                    }
                    else
                    {
                        if (info.LeaveReason != LeaveReason.Unknown)
                        {
                            textBox1.Text += String.Format("About {0}:\r\n Last seen {1} ago ({2}).\r\n",
                                            info.Name,
                                            info.TimeSinceLastSeen.ToMiniString(),
                                            info.LeaveReason);
                        }
                        else
                        {
                            textBox1.Text += String.Format("About {0}:\r\n Last seen {1} ago.\r\n",
                                            info.Name,
                                            info.TimeSinceLastSeen.ToMiniString());
                        }
                    }
                }
                // Show login information
                textBox1.Text += String.Format("  Logged in {0} time(s) since {1:d MMM yyyy}.\r\n",
                                info.TimesVisited,
                                info.FirstLoginDate);
            }

            if (info.IsFrozen)
            {
                textBox1.Text += String.Format("  Frozen {0} ago by {1}\r\n",
                                info.TimeSinceFrozen.ToMiniString(),
                                info.FrozenByClassy);
            }

            if (info.IsMuted)
            {
                textBox1.Text += String.Format("  Muted for {0} by {1}\r\n",
                                info.TimeMutedLeft.ToMiniString(),
                                info.MutedByClassy);
                float blocks = ((info.BlocksBuilt + info.BlocksDrawn) - info.BlocksDeleted);
                if (blocks < 0)
                    textBox1.Text += String.Format("  &CWARNING! {0} has deleted more than built!\r\n", info.ClassyName);//<---- LinkLoftWing, lul
            }

            // Show ban information
            IPBanInfo ipBan = IPBanList.Get(info.LastIP);
            switch (info.BanStatus)
            {
                case BanStatus.Banned:
                    if (ipBan != null)
                    {
                        textBox1.Text += String.Format("  Account and IP are BANNED. See /BanInfo\r\n");
                    }
                    else
                    {
                        textBox1.Text += String.Format("  Account is BANNED. See /BanInfo\r\n");
                    }
                    break;
                case BanStatus.IPBanExempt:
                    if (ipBan != null)
                    {
                        textBox1.Text += String.Format("  IP is BANNED, but account is exempt. See /BanInfo\r\n");
                    }
                    else
                    {
                        textBox1.Text += String.Format("  IP is not banned, and account is exempt. See /BanInfo\r\n");
                    }
                    break;
                case BanStatus.NotBanned:
                    if (ipBan != null)
                    {
                        textBox1.Text += String.Format("  IP is BANNED. See /BanInfo\r\n");

                    }
                    break;
            }

            if (!info.LastIP.Equals(System.Net.IPAddress.None))
            {
                // Show alts
                List<PlayerInfo> altNames = new List<PlayerInfo>();
                int bannedAltCount = 0;
                foreach (PlayerInfo playerFromSameIP in PlayerDB.FindPlayers(info.LastIP))
                {
                    if (playerFromSameIP == info) continue;
                    altNames.Add(playerFromSameIP);
                    if (playerFromSameIP.IsBanned)
                    {
                        bannedAltCount++;
                    }
                }

                // Stats
                if (info.BlocksDrawn > 500000000)
                {
                    textBox1.Text += String.Format("  Built {0} and deleted {1} blocks, drew {2}M blocks, wrote {3} messages.\r\n",
                                    info.BlocksBuilt,
                                    info.BlocksDeleted,
                                    info.BlocksDrawn / 1000000,
                                    info.MessagesWritten);
                }
                else if (info.BlocksDrawn > 500000)
                {
                    textBox1.Text += String.Format("  Built {0} and deleted {1} blocks, drew {2}K blocks, wrote {3} messages.\r\n",
                                    info.BlocksBuilt,
                                    info.BlocksDeleted,
                                    info.BlocksDrawn / 1000,
                                    info.MessagesWritten);
                }
                else if (info.BlocksDrawn > 0)
                {
                    textBox1.Text += String.Format("  Built {0} and deleted {1} blocks, drew {2} blocks, wrote {3} messages.\r\n",
                                    info.BlocksBuilt,
                                    info.BlocksDeleted,
                                    info.BlocksDrawn,
                                    info.MessagesWritten);
                }
                else
                {
                    textBox1.Text += String.Format("  Built {0} and deleted {1} blocks, wrote {2} messages.\r\n",
                                    info.BlocksBuilt,
                                    info.BlocksDeleted,
                                    info.MessagesWritten);
                }

                // More stats
                if (info.TimesBannedOthers > 0 || info.TimesKickedOthers > 0 || info.PromoCount > 0)
                {
                    textBox1.Text += String.Format("  Kicked {0}, Promoted {1} and banned {2} players.\r\n", info.TimesKickedOthers, info.PromoCount, info.TimesBannedOthers);
                }

                if (info.TimesKicked > 0)
                {
                    if (info.LastKickDate != DateTime.MinValue)
                    {
                        textBox1.Text += String.Format("  Got kicked {0} times. Last kick {1} ago by {2}\r\n",
                                        info.TimesKicked,
                                        info.TimeSinceLastKick.ToMiniString(),
                                        info.LastKickByClassy);
                    }
                    else
                    {
                        textBox1.Text += String.Format("  Got kicked {0} times.\r\n", info.TimesKicked);
                    }
                    if (info.LastKickReason != null)
                    {
                        textBox1.Text += String.Format("  Kick reason: {0}\r\n", info.LastKickReason);
                    }
                }

                // Promotion/demotion
                if (info.PreviousRank == null)
                {
                    if (info.RankChangedBy == null)
                    {
                        textBox1.Text += String.Format("  Rank is {0} (default).\r\n",
                                        info.Rank.Name);
                    }
                    else
                    {
                        textBox1.Text += String.Format("  Promoted to {0} by {1} {2} ago.\r\n",
                                        info.Rank.Name,
                                        info.RankChangedByClassy,
                                        info.TimeSinceRankChange.ToMiniString());
                        if (info.RankChangeReason != null)
                        {
                            textBox1.Text += String.Format("  Promotion reason: {0}\r\n", info.RankChangeReason);
                        }
                    }
                }
                else if (info.PreviousRank <= info.Rank)
                {
                    textBox1.Text += String.Format("  Promoted from {0} to {1} by {2} {3} ago.\r\n",
                                    info.PreviousRank.Name,
                                    info.Rank.Name,
                                    info.RankChangedByClassy,
                                    info.TimeSinceRankChange.ToMiniString());
                    if (info.RankChangeReason != null)
                    {
                        textBox1.Text += String.Format("  Promotion reason: {0}\r\n", info.RankChangeReason);
                    }
                }
                else
                {
                    textBox1.Text += String.Format("  Demoted from {0} to {1} by {2} {3} ago.\r\n",
                                    info.PreviousRank.Name,
                                    info.Rank.Name,
                                    info.RankChangedByClassy,
                                    info.TimeSinceRankChange.ToMiniString());
                    if (info.RankChangeReason != null)
                    {
                        textBox1.Text += String.Format("  Demotion reason: {0}\r\n", info.RankChangeReason);
                    }
                }

                if (!info.LastIP.Equals(System.Net.IPAddress.None))
                {
                    // Time on the server
                    TimeSpan totalTime = info.TotalTime;
                    if (info != null)
                    {
                        totalTime = totalTime.Add(info.TimeSinceLastLogin);
                    }
                    textBox1.Text += String.Format("  Spent a total of {0:F1} hours ({1:F1} minutes) here.\r\n",
                                    totalTime.TotalHours,
                                    totalTime.TotalMinutes);
                }
            }
        }
Exemplo n.º 6
0
        public static void PlayerMoving(object poo, fCraft.Events.PlayerMovingEventArgs e)
        {
            if (!started)
            {
                return;
            }
            //If the player has the red flag (player is no the blue team)
            if (e.Player.Info.hasRedFlag)
            {
                Vector3I oldPos = e.OldPosition.ToBlockCoords(); //get positions as block coords
                Vector3I newPos = e.NewPosition.ToBlockCoords();

                if (oldPos.X != newPos.X || oldPos.Y != newPos.Y || oldPos.Z != newPos.Z) //check if player has moved at least one block
                {
                    //If the player is near enough to the blue spawn
                    if (e.NewPosition.DistanceSquaredTo(world_.blueCTFSpawn.ToPlayerCoords()) <= 42 * 42)
                    {
                        blueScore++;
                        world_.Players.Message("&f{0} has capped the &cred &fflag. The score is now &cRed&f: {1} and &1Blue&f: {2}.", e.Player.Name, redScore, blueScore);
                        e.Player.Info.hasRedFlag = false;
                        redFlagHolder = null;
                        e.Player.Info.CTFCaptures++;

                        //Replace red block as flag
                        BlockUpdate blockUpdate = new BlockUpdate(null, world_.redFlag, Block.Red);
                        foreach (Player p in world_.Players)
                        {
                            p.World.Map.QueueUpdate(blockUpdate);

                            //set game score
                            if (p.ClassiCube && Heartbeat.ClassiCube())
                            {
                                p.Send(PacketWriter.MakeSpecialMessage((byte)2, "&cRed&f: " + redScore + ",&1 Blue&f: " + blueScore));
                                p.Send(PacketWriter.MakeSpecialMessage((byte)100, e.Player.Name + " has successfully capped the &cred &fflag"));
                            }
                        }
                        world_.redFlagTaken = false;
                        announced = DateTime.Now;
                        return;
                    }
                }
            }
            //If the player has the blue flag (player must be on red team)
            else if (e.Player.Info.hasBlueFlag)
            {
                Vector3I oldPos = e.OldPosition.ToBlockCoords(); //get positions as block coords
                Vector3I newPos = e.NewPosition.ToBlockCoords();

                if (oldPos.X != newPos.X || oldPos.Y != newPos.Y || oldPos.Z != newPos.Z) //check if player has moved at least one block
                {
                    //If the player is near enough to the red spawn
                    if (e.NewPosition.DistanceSquaredTo(world_.redCTFSpawn.ToPlayerCoords()) <= 42 * 42)
                    {
                        redScore++;
                        world_.Players.Message("&f{0} has capped the &1blue &fflag. The score is now &cRed&f: {1} and &1Blue&f: {2}.", e.Player.Name, redScore, blueScore);
                        e.Player.Info.hasBlueFlag = false;
                        blueFlagHolder = null;
                        e.Player.Info.CTFCaptures++;

                        //Replace blue block as flag
                        BlockUpdate blockUpdate = new BlockUpdate(null, world_.blueFlag, Block.Blue);
                        foreach (Player p in world_.Players)
                        {
                            p.World.Map.QueueUpdate(blockUpdate);

                            //set game scorecboard
                            if (p.ClassiCube && Heartbeat.ClassiCube())
                            {
                                p.Send(PacketWriter.MakeSpecialMessage((byte)2, "&cRed&f: " + redScore + ",&1 Blue&f: " + blueScore));
                                p.Send(PacketWriter.MakeSpecialMessage((byte)100, e.Player.Name + " has successfully capped the &cred &fflag"));
                            }
                        }
                        world_.blueFlagTaken = false;
                        announced = DateTime.Now;
                        return;
                    }
                }
            }

            //backstabbing, player with a flag cannot backstab an enemy player
            else
            {
                if (e.Player.Info.stabDisarmed)
                {
                    return;
                }

                Vector3I oldPos = e.OldPosition.ToBlockCoords(); //get positions as block coords
                Vector3I newPos = e.NewPosition.ToBlockCoords();

                if (oldPos.X != newPos.X || oldPos.Y != newPos.Y || oldPos.Z != newPos.Z) //check if player has moved at least one block
                {
                    //loop through each player, detect if current player is "touching" another player
                    foreach (Player p in world_.Players)
                    {
                        Vector3I pos = p.Position.ToBlockCoords(); //convert to block coords

                        //determine if player is "touching" another player
                        if (e.NewPosition.DistanceSquaredTo(pos.ToPlayerCoords()) <= 42 * 42 && p != e.Player)
                        {
                            if ((p.Info.CTFBlueTeam && e.Player.Info.CTFBlueTeam) || (p.Info.CTFRedTeam && e.Player.Info.CTFRedTeam))
                            {
                                //friendly fire, do not stab
                                return;
                            }

                            //create just under a 180 degree semicircle in the direction the target player is facing (90 degrees = 64 pos.R bytes)
                            short lowerLimit = (short)(p.Position.R - 63);
                            short upperLimit = (short)(p.Position.R + 63);

                            //if lower limit is -45 degrees for example, convert to 256 + (-32) = 201 bytes (-45 degrees translates to -32 bytes)
                            if (lowerLimit < 0)
                            {
                                lowerLimit = (short)(256 + lowerLimit);
                            }

                            //if upper limit is 450 degrees for example, convert to 320 - 256 = 54 bytes (450 degrees translates to 320 bytes, 360 degrees translates to 256 bytes)
                            if (upperLimit > 256)
                            {
                                upperLimit = (short)(upperLimit - 256);
                            }

                            //Logger.LogToConsole(upperLimit.ToString() + " " + lowerLimit.ToString() + " " + e.Player.Position.R.ToString() + " " + p.Position.R);

                            bool kill = false;

                            //if target's line of sight contains 0
                            if (p.Position.R > 192 && p.Position.R < 64)
                            {
                                if (Enumerable.Range(lowerLimit, 255).Contains(e.Player.Position.R) || Enumerable.Range(0, upperLimit).Contains(e.Player.Position.R))
                                {
                                    kill = true;
                                }
                            }
                            else
                            {
                                if (Enumerable.Range(lowerLimit, upperLimit).Contains(e.Player.Position.R))
                                {
                                    kill = true;
                                }
                            }

                            if (e.Player.Info.stabAnywhere)
                            {
                                kill = true;
                            }

                            if (kill)
                            {
                                p.KillCTF(world_, String.Format("&f{0}&S was backstabbed by &f{1}", p.Name, e.Player.Name));
                                e.Player.Info.CTFKills++;
                                PowerUp(e.Player);

                                if (p.Info.hasRedFlag)
                                {
                                    world_.Players.Message("The red flag has been returned.");
                                    p.Info.hasRedFlag = false;
                                    redFlagHolder = null;

                                    //Put flag back
                                    BlockUpdate blockUpdate = new BlockUpdate(null, world_.redFlag, Block.Red);
                                    foreach (Player pl in world_.Players)
                                    {
                                        pl.World.Map.QueueUpdate(blockUpdate);
                                    }
                                    world_.redFlagTaken = false;

                                }

                                if (p.Info.hasBlueFlag)
                                {
                                    world_.Players.Message("The blue flag has been returned.");
                                    p.Info.hasBlueFlag = false;
                                    blueFlagHolder = null;

                                    //Put flag back
                                    BlockUpdate blockUpdate = new BlockUpdate(null, world_.blueFlag, Block.Blue);
                                    foreach (Player pl in world_.Players)
                                    {
                                        pl.World.Map.QueueUpdate(blockUpdate);
                                    }
                                    world_.blueFlagTaken = false;
                                }
                            }
                            //target player can see player, do not stab
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
 public static void PlayerMoved(object sender, fCraft.Events.PlayerMovingEventArgs e)
 {
     if (e.Player.Info.IsFrozen || e.Player.SpectatedPlayer != null || !e.Player.SpeedMode)
         return;
     Vector3I oldPos = e.OldPosition.ToBlockCoords();
     Vector3I newPos = e.NewPosition.ToBlockCoords();
     //check if has moved 1 whole block
     if (newPos.X == oldPos.X + 1 || newPos.X == oldPos.X-1 || newPos.Y == oldPos.Y + 1 || newPos.Y == oldPos.Y-1)
     {
         Server.Players.Message("Old: " + newPos.ToString());
         Vector3I move = newPos - oldPos;
         int AccelerationFactor = 4;
         Vector3I acceleratedNewPos = oldPos + move * AccelerationFactor;
         //do not forget to check for all the null pointers here - TODO
         Map m = e.Player.World.Map;
         //check if can move through all the blocks along the path
         Vector3F normal = move.Normalize();
         Vector3I prevBlockPos = e.OldPosition.ToBlockCoords();
         for (int i = 1; i <= AccelerationFactor * move.Length; ++i)
         {
             Vector3I pos = (oldPos + i * normal).Round();
             if (prevBlockPos == pos) //didnt yet hit the next block
                 continue;
             if (!m.InBounds(pos) || m.GetBlock(pos) != Block.Air) //got out of bounds or some solid block
             {
                 acceleratedNewPos = (oldPos + normal * (i - 1)).Round();
                 break;
             }
             prevBlockPos = pos;
         }
         //teleport keeping the same orientation
         Server.Players.Message("New: "+ acceleratedNewPos.ToString());
         e.Player.Send(PacketWriter.MakeSelfTeleport(new Position((short)(acceleratedNewPos.X * 32), (short)(acceleratedNewPos.Y * 32), e.Player.Position.Z, e.NewPosition.R, e.NewPosition.L)));
     }
 }
Exemplo n.º 8
0
        //check if player tagged another player
        public static void PlayerMoved(object poo, fCraft.Events.PlayerMovingEventArgs e)
        {
            if (e.Player.Info.isInfected)
            {
                Vector3I oldPos = new Vector3I( e.OldPosition.X / 32, e.OldPosition.Y / 32, e.OldPosition.Z / 32 ); //get positions as block coords
                Vector3I newPos = new Vector3I( e.NewPosition.X / 32, e.NewPosition.Y / 32, e.NewPosition.Z / 32 );

                if (oldPos.X != newPos.X || oldPos.Y != newPos.Y || oldPos.Z != newPos.Z) //check if player has moved at least one block
                {
                    foreach (Player p in world_.Players)
                    {
                        Vector3I pos = p.Position.ToBlockCoords(); //convert to block coords

                        if (e.NewPosition.DistanceSquaredTo(pos.ToPlayerCoords()) <= 42 * 42 && p != e.Player) //Get blocks on and around player, ignore instances when the target = player
                        {
                            if (!p.Info.isInfected)
                            {
                                Infect(p, e.Player);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
 //check if player left world where infection is being played
 public static void PlayerLeftWorld(object poo, fCraft.Events.PlayerJoinedWorldEventArgs e)
 {
     e.Player.Info.isPlayingInfection = false;
     if (e.Player.Info.isInfected)
     {
         e.Player.Info.isInfected = false;
         e.Player.entityChanged = false;
         e.Player.iName = null;
     }
 }
Exemplo n.º 10
0
 //check if player left server to reset stats
 public static void PlayerLeftServer(object poo, fCraft.Events.PlayerDisconnectedEventArgs e)
 {
     e.Player.Info.isPlayingInfection = false;
     if (e.Player.Info.isInfected)
     {
         e.Player.Info.isInfected = false;
         e.Player.entityChanged = false;
         e.Player.iName = null;
     }
 }