/// <summary>
 /// Hook method for player key press
 /// </summary>
 /// <param name="Event">PlayerKeyPressEvent info</param>
 public virtual void onPlayerKeyPress(PlayerKeyPressEvent Event)
 {
 }
        public override void onPlayerKeyPress(PlayerKeyPressEvent Event)
        {
            //base.onPlayerKeyPress(Event);
            Player player = Event.Player;

            //if (Event.KeysPressed.Left) player.sendMessage("--Left");
            //if (Event.KeysPressed.Right) player.sendMessage("--Right");
            //if (Event.KeysPressed.Up) player.sendMessage("--Up");
            //if (Event.KeysPressed.Down) player.sendMessage("--Down");
            //if (Event.KeysPressed.Jump) player.sendMessage("--Jump");

            if (Event.KeysPressed.Left || Event.KeysPressed.Right)
            {
                int xp = Math.Abs((int)(lastPos[player.whoAmi].X - player.getLocation().X));
                xp += travelerXP.getPlayerValue(player.Name);

                travelerXP.setPlayerValue(player.Name, xp);
                travelerXP.Save();

                lastPos[player.whoAmi] = player.getLocation();

            }

            if (Event.KeysPressed.Up)
            {
                int x = ((int)player.getLocation().X) /16;
                int y = ((int)player.getLocation().Y + 32) /16;

                if (Main.tile[x, y].type == 55) //55-sign
                {
                    player.sendMessage("In front of a sign!");

                    int i = Sign.ReadSign(x, y);
                    int cXP = combatXP.getPlayerValue(player.Name);
                    int dXP = defenseXP.getPlayerValue(player.Name);
                    int tXP = travelerXP.getPlayerValue(player.Name);
                    Sign.TextSign(i, player.Name+"\nCombat XP: " + cXP+"\nDefense XP: "+dXP+"\nTraveler XP: "+tXP+"\n\nLevel: 1\nMagic: 10\nOther: 100");

                }

                else
                {
                    int cXP = combatXP.getPlayerValue(player.Name);
                    int dXP = defenseXP.getPlayerValue(player.Name);
                    int tXP = travelerXP.getPlayerValue(player.Name);
                    player.sendMessage(cXP + " Combat XP, " + dXP + " Defense XP, " + tXP + " Traveler XP");

                }

            }
        }
        public void Process(int start, int length, int num, int whoAmI, byte[] readBuffer, byte bufferData)
        {
            int playerIndex = (int)readBuffer[num++];
            if (playerIndex == Main.myPlayer)
            {
                return;
            }

            Player player = (Player)Main.players[playerIndex].Clone();

            playerIndex = whoAmI;

            player.oldVelocity = player.Velocity;

            int controlMap = (int)readBuffer[num++];
            player.selectedItemIndex = (int)readBuffer[num++];

            player.Position.X = BitConverter.ToSingle(readBuffer, num);
            num += 4;
            player.Position.Y = BitConverter.ToSingle(readBuffer, num);
            num += 4;
            player.Velocity.X = BitConverter.ToSingle(readBuffer, num);
            num += 4;
            player.Velocity.Y = BitConverter.ToSingle(readBuffer, num);
            num += 4;

            player.fallStart = (int)(player.Position.Y / 16f);

            player.controlUp = (controlMap & 1) == 1;
            player.controlDown = (controlMap & 2) == 2;
            player.controlLeft = (controlMap & 4) == 4;
            player.controlRight = (controlMap & 8) == 8;
            player.controlJump = (controlMap & 16) == 16;
            player.controlUseItem = (controlMap & 32) == 32;
            player.direction = (controlMap & 64) == 64 ? 1 : -1;

            PlayerMoveEvent playerEvent = new PlayerMoveEvent();
            playerEvent.Sender = Main.players[playerIndex]; //We want to use the old player. (Possibly, to keep old Data?)
            playerEvent.Location = player.Position;
            playerEvent.Velocity = player.Velocity;
            playerEvent.FallStart = player.fallStart;
            Program.server.PluginManager.processHook(Hooks.PLAYER_MOVE, playerEvent);
            if (playerEvent.Cancelled)
            {
                return;
            }

            PlayerKeyPressEvent playerInteractEvent = new PlayerKeyPressEvent();
            playerInteractEvent.Sender = Main.players[playerIndex];

            Key playerKeysPressed = new Key();
            playerKeysPressed.Up = player.controlUp;
            playerKeysPressed.Down = player.controlDown;
            playerKeysPressed.Left = player.controlLeft;
            playerKeysPressed.Right = player.controlRight;
            playerKeysPressed.Jump = player.controlJump;

            playerInteractEvent.KeysPressed = playerKeysPressed;
            playerInteractEvent.MouseClicked = player.controlUseItem;
            playerInteractEvent.FacingDirection = player.direction;
            Program.server.PluginManager.processHook(Hooks.PLAYER_KEYPRESS, playerInteractEvent);
            if (playerEvent.Cancelled)
            {
                return;
            }

            Main.players[playerIndex] = player;

            if (Netplay.slots[whoAmI].state == SlotState.PLAYING)
            {
                NetMessage.SendData(13, -1, whoAmI, "", playerIndex);
            }
        }