예제 #1
0
        internal bool Execte(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
        {
            if (this.Commands.TryGetValue(label, out ICommand command))
            {
                if (command.Permission == null || executor.HasPermission(command.Permission))
                {
                    try
                    {
                        command.OnCommand(executor, label, args);
                    }
                    catch (Exception ex)
                    {
                        CommandManager.Logger.Error(ex);

                        executor.SendMessage("Critical error while executing the command!");
                    }
                }
                else
                {
                    executor.SendMessage("You are lacking the permissions to use this command!");
                }

                return(true);
            }

            return(false);
        }
        public void OnCommand(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
        {
            if (executor is ClientSession session)
            {
                MultiplayerMatchSession matchSession = session.MultiplayerMatchSession;
                if (matchSession != null && matchSession.Match != null)
                {
                    matchSession.Match.Broadcaster = !matchSession.Match.Broadcaster;

                    if (matchSession.Match.Broadcaster)
                    {
                        executor.SendMessage("Broadcaster has been signed to duty!");
                    }
                    else
                    {
                        executor.SendMessage("Broadcaster has been fired, what a shame!");
                    }
                }
                else
                {
                    executor.SendMessage("You need to be in match to use this command");
                }
            }
            else
            {
                executor.SendMessage("This command may only be executed by client session");
            }
        }
    public void OnCommand(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
    {
        if (executor is ClientSession session)
        {
            if (args.Length != 2)
            {
                executor.SendMessage("Usage: /fakeprize [category] [id]");

                return;
            }

            if (!uint.TryParse(args[1], out uint id))
            {
                executor.SendMessage("The id must be unsigned integer");

                return;
            }

            MultiplayerMatchSession matchSession = session.MultiplayerMatchSession;
            if (matchSession != null && matchSession.Match != null)
            {
                ;
                matchSession.Match.SendPacket(new PrizeOutgoingMessage(new MatchPrize(args[0], id), "available"));
            }
            else
            {
                executor.SendMessage("You need to be in match to use this command");
            }
        }
        else
        {
            executor.SendMessage("This command may only be executed by client session");
        }
    }
예제 #4
0
    public void OnCommand(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
    {
        if (executor is ClientSession session)
        {
            if (args.Length != 1)
            {
                executor.SendMessage("Usage: /spawnaliens [amount]");

                return;
            }

            if (!uint.TryParse(args[0], out uint amount))
            {
                executor.SendMessage("The amount must be unsigned integer");

                return;
            }

            MultiplayerMatchSession matchSession = session.MultiplayerMatchSession;
            if (matchSession != null && matchSession.Match != null)
            {
                matchSession.Match.SendPacket(new SpawnAliensOutgoingPacket(amount, new Random().Next(26487)));
            }
            else
            {
                executor.SendMessage("You need to be in match to use this command");
            }
        }
        else
        {
            executor.SendMessage("This command may only be executed by client session");
        }
    }
        public void OnCommand(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
        {
            if (args.Length == 2)
            {
                PlayerUserData playerUserData = UserManager.TryGetUserDataByNameAsync(args[0]).Result;
                if (playerUserData != null)
                {
                    if (!uint.TryParse(args[1], out uint amount))
                    {
                        executor.SendMessage("The amount must be unsigned integer");

                        return;
                    }

                    if (PlatformRacing3Server.ClientManager.TryGetClientSessionByUserId(playerUserData.Id, out ClientSession session) && session.UserData != null)
                    {
                        session.UserData.GiveBonusExp(amount);
                    }
                    else
                    {
                        playerUserData.GiveBonusExp(amount);
                    }
                }
                else
                {
                    executor.SendMessage($"Unable to find user named {args[0]}");
                }
            }
            else
            {
                executor.SendMessage("Usage: /givebonusexp [user] [amount]");
            }
        }
    public void OnCommand(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
    {
        if (args.Length < 1 || args.Length > 2)
        {
            executor.SendMessage("Usage: /life [amount] <target>");

            return;
        }

        if (!uint.TryParse(args[0], out uint amount))
        {
            executor.SendMessage("The amount must be unsigned integer");

            return;
        }

        MultiplayerMatchSession matchSession;

        if (args.Length >= 2)
        {
            ClientSession target = this.clientManager.GetClientSessionByUsername(args[1]);
            if (target == null)
            {
                executor.SendMessage("The target was not found");

                return;
            }

            matchSession = target.MultiplayerMatchSession;
        }
        else if (executor is ClientSession client)
        {
            matchSession = client.MultiplayerMatchSession;
        }
        else
        {
            executor.SendMessage("No valid target was found");

            return;
        }

        if (matchSession != null && matchSession.Match != null && matchSession.MatchPlayer != null)
        {
            matchSession.MatchPlayer.Life = amount;

            if (matchSession.MatchPlayer.GetUpdatePacket(out UpdateOutgoingPacket packet))
            {
                matchSession.Match.SendPacket(packet);
            }
        }
        else
        {
            executor.SendMessage("The target is not currently in a match");
        }
    }
 public void OnCommand(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
 {
     if (executor is ClientSession client)
     {
         executor.SendMessage($"Hello, {client.UserData.Username} !");
     }
     else
     {
         executor.SendMessage("Hello, someone!");
     }
 }
        public void OnCommand(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
        {
            if (executor is ClientSession session)
            {
                session.HostTournament = true;

                executor.SendMessage("The next match you host will be hosted as tournament");
            }
            else
            {
                executor.SendMessage("This command may only be executed by client session");
            }
        }
예제 #9
0
        public void OnCommand(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
        {
            if (args.Length < 1 || args.Length > 2)
            {
                executor.SendMessage("Usage: /item [item] <target>");

                return;
            }

            MultiplayerMatchSession matchSession;

            if (args.Length >= 2)
            {
                ClientSession target = PlatformRacing3Server.ClientManager.GetClientSessionByUsername(args[1]);
                if (target == null)
                {
                    executor.SendMessage("The target was not found");

                    return;
                }

                matchSession = target.MultiplayerMatchSession;
            }
            else if (executor is ClientSession client)
            {
                matchSession = client.MultiplayerMatchSession;
            }
            else
            {
                executor.SendMessage("No valid target was found");

                return;
            }

            if (matchSession != null && matchSession.Match != null && matchSession.MatchPlayer != null)
            {
                matchSession.MatchPlayer.Item = args[0];

                if (matchSession.MatchPlayer.GetUpdatePacket(out UpdateOutgoingPacket packet))
                {
                    matchSession.Match.SendPacket(packet);
                }
            }
            else
            {
                executor.SendMessage("The target is not currently in a match");
            }
        }
예제 #10
0
    public void OnCommand(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
    {
        if (args.Length >= 2 && args.Length <= 3)
        {
            PlayerUserData playerUserData = UserManager.TryGetUserDataByNameAsync(args[0]).Result;
            if (playerUserData != null)
            {
                Hat hat;
                if (uint.TryParse(args[1], out uint hatId))
                {
                    hat = (Hat)hatId;
                }
                else if (!Enum.TryParse(args[1], ignoreCase: true, out hat))
                {
                    executor.SendMessage($"Unable to find part with name {args[1]}");
                }

                bool temp = false;
                if (args.Length >= 3)
                {
                    bool.TryParse(args[2], out temp);
                }

                if (this.clientManager.TryGetClientSessionByUserId(playerUserData.Id, out ClientSession session) && session.UserData != null)
                {
                    session.UserData.GiveHat(hat, temp);
                }
                else if (!temp)
                {
                    UserManager.GiveHat(playerUserData.Id, hat);
                }
            }
            else
            {
                executor.SendMessage($"Unable to find user named {args[0]}");
            }
        }
        else
        {
            executor.SendMessage("Usage: /givehat [user] [id/name] [temporaly(false)]");
        }
    }
예제 #11
0
        public void OnCommand(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
        {
            if (executor is ClientSession session)
            {
                if (args.Length != 1)
                {
                    executor.SendMessage("Usage: /addhat [hat]");

                    return;
                }

                Hat hat;
                if (uint.TryParse(args[0], out uint hatId))
                {
                    hat = (Hat)hatId;
                }
                else if (!Enum.TryParse(args[0], ignoreCase: true, out hat))
                {
                    executor.SendMessage($"Unable to find part with name {args[0]}");
                }

                MultiplayerMatchSession matchSession = session.MultiplayerMatchSession;
                if (matchSession != null && matchSession.Match != null && matchSession.MatchPlayer != null)
                {
                    matchSession.Match.AddHatToPlayer(matchSession.MatchPlayer, hat, session.UserData.CurrentHatColor, spawned: true);
                }
                else
                {
                    executor.SendMessage("You need to be in match to use this command");
                }
            }
            else
            {
                executor.SendMessage("This command may only be executed by client session");
            }
        }
예제 #12
0
    public void OnCommand(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
    {
        if (args.Length >= 1)
        {
            ClientSession target = this.clientManager.GetClientSessionByUsername(args[0]);
            if (target != null)
            {
                if (target.PermissionRank > executor.PermissionRank)
                {
                    executor.SendMessage("You do not have permissions to kick this user");

                    return;
                }

                if (args.Length == 1)
                {
                    target.Disconnect("You got kicked for absolute no reason, I bet some staff must hate you");
                }
                else
                {
                    target.Disconnect(string.Join(' ', args[1..].ToArray()));
    public void OnCommand(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
    {
        if (args.Length >= 3 && args.Length <= 4)
        {
            PlayerUserData playerUserData = UserManager.TryGetUserDataByNameAsync(args[0]).Result;
            if (playerUserData != null)
            {
                Part part;
                if (uint.TryParse(args[2], out uint partId))
                {
                    part = (Part)partId;
                }
                else if (!Enum.TryParse(args[2], ignoreCase: true, out part))
                {
                    executor.SendMessage($"Unable to find part with name {args[2]}");
                }

                bool temp = false;
                if (args.Length >= 4)
                {
                    bool.TryParse(args[3], out temp);
                }

                switch (args[1])
                {
                case "head":
                {
                    if (this.clientManager.TryGetClientSessionByUserId(playerUserData.Id, out ClientSession session) && session.UserData != null)
                    {
                        session.UserData.GiveHead(part, temp);
                    }
                    else if (!temp)
                    {
                        UserManager.GiveHead(playerUserData.Id, part);
                    }
                }
                break;

                case "body":
                {
                    if (this.clientManager.TryGetClientSessionByUserId(playerUserData.Id, out ClientSession session) && session.UserData != null)
                    {
                        session.UserData.GiveBody(part, temp);
                    }
                    else if (!temp)
                    {
                        UserManager.GiveBody(playerUserData.Id, part);
                    }
                }
                break;

                case "feet":
                {
                    if (this.clientManager.TryGetClientSessionByUserId(playerUserData.Id, out ClientSession session) && session.UserData != null)
                    {
                        session.UserData.GiveFeet(part, temp);
                    }
                    else if (!temp)
                    {
                        UserManager.GiveFeet(playerUserData.Id, part);
                    }
                }
                break;

                case "set":
                {
                    if (this.clientManager.TryGetClientSessionByUserId(playerUserData.Id, out ClientSession session) && session.UserData != null)
                    {
                        session.UserData.GiveSet(part, temp);
                    }
                    else if (!temp)
                    {
                        UserManager.GiveSet(playerUserData.Id, part);
                    }
                }
                break;
                }
            }
            else
            {
                executor.SendMessage($"Unable to find user named {args[0]}");
            }
        }
        else
        {
            executor.SendMessage("Usage: /givepart [user] [head/body/feet/set] [id/name] [temporaly(false)]");
        }
    }
    public void OnCommand(ICommandExecutor executor, string label, ReadOnlySpan <string> args)
    {
        if (args.Length < 2 || args.Length > 3)
        {
            executor.SendMessage("Usage: /teleport [x] [y] <target>");

            return;
        }

        if (!double.TryParse(args[0], out double x))
        {
            executor.SendMessage("The x must be double");

            return;
        }

        if (!double.TryParse(args[1], out double y))
        {
            executor.SendMessage("The y must be double");

            return;
        }

        MultiplayerMatchSession matchSession;

        if (args.Length >= 3)
        {
            ClientSession target = this.clientManager.GetClientSessionByUsername(args[2]);
            if (target == null)
            {
                executor.SendMessage("The target was not found");

                return;
            }

            matchSession = target.MultiplayerMatchSession;
        }
        else if (executor is ClientSession client)
        {
            matchSession = client.MultiplayerMatchSession;
        }
        else
        {
            executor.SendMessage("No valid target was found");

            return;
        }

        if (matchSession != null && matchSession.Match != null && matchSession.MatchPlayer != null)
        {
            //40 is for block size in pixels
            matchSession.MatchPlayer.X += x * 40;
            matchSession.MatchPlayer.Y -= y * 40;

            if (matchSession.MatchPlayer.GetUpdatePacket(out UpdateOutgoingPacket packet))
            {
                matchSession.Match.SendPacket(packet);
            }
        }
        else
        {
            executor.SendMessage("The target is not currently in a match");
        }
    }