コード例 #1
0
 public void Execute(IRocketPlayer caller, string[] command)
 {
     try
     {
         TebexApiClient wc = new TebexApiClient();
         wc.setPlugin(Tebex.Instance);
         wc.DoGet("information", this);
         wc.Dispose();
     }
     catch (TimeoutException)
     {
         Tebex.logWarning("Timeout!");
     }
 }
コード例 #2
0
 public void Execute(IRocketPlayer caller, string[] command)
 {
     Tebex.logWarning("Checking for commands to be executed...");
     try
     {
         TebexApiClient wc = new TebexApiClient();
         wc.setPlugin(Tebex.Instance);
         wc.DoGet("queue", this);
         wc.Dispose();
     }
     catch (TimeoutException)
     {
         Tebex.logWarning("Timeout!");
     }
 }
コード例 #3
0
        public static void doOnlineCommands(int playerPluginId, string playerName, string playerId)
        {
            Tebex.logWarning("Running online commands for " + playerName + " (" + playerId + ")");

            TebexApiClient wc = new TebexApiClient();

            wc.setPlugin(Tebex.Instance);
            wc.Headers.Add("X-Buycraft-Secret", Tebex.Instance.Configuration.Instance.secret);
            String url = Tebex.Instance.Configuration.Instance.baseUrl + "queue/online-commands/" +
                         playerPluginId.ToString();

            Tebex.logWarning("GET " + url);

            wc.DownloadStringCompleted += (sender, e) =>
            {
                JObject json     = JObject.Parse(e.Result);
                JArray  commands = (JArray)json["commands"];

                int        exCount          = 0;
                List <int> executedCommands = new List <int>();

                foreach (var command in commands.Children())
                {
                    String commandToRun = buildCommand((string)command["command"], playerName, playerId);

                    Tebex.logWarning("Run command " + commandToRun);
                    ConsolePlayer executer = new ConsolePlayer();
                    R.Commands.Execute(executer, commandToRun);
                    executedCommands.Add((int)command["id"]);

                    exCount++;

                    if (exCount % deleteAfter == 0)
                    {
                        try
                        {
                            deleteCommands(executedCommands);
                            executedCommands.Clear();
                        }
                        catch (Exception ex)
                        {
                            Tebex.logError(ex.ToString());
                        }
                    }
                }

                Tebex.logWarning(exCount.ToString() + " online commands executed for " + playerName);
                if (exCount % deleteAfter != 0)
                {
                    try
                    {
                        deleteCommands(executedCommands);
                        executedCommands.Clear();
                    }
                    catch (Exception ex)
                    {
                        Tebex.logError(ex.ToString());
                    }
                }

                wc.Dispose();
            };

            wc.DownloadStringAsync(new Uri(url));
        }