public void HandleResponse(JObject response) { if ((int)response["meta"]["next_check"] > 0) { Tebex.Instance.nextCheck = (int)response["meta"]["next_check"]; } if ((bool)response["meta"]["execute_offline"]) { try { TebexCommandRunner.doOfflineCommands(); } catch (Exception e) { Tebex.logError(e.ToString()); } } JArray players = (JArray)response["players"]; foreach (var player in players) { try { CSteamID steamId = new CSteamID((ulong)player["uuid"]); UnturnedPlayer targetPlayer = UnturnedPlayer.FromCSteamID(steamId); if (targetPlayer.Player != null) { Tebex.logWarning("Execute commands for " + (string)targetPlayer.CharacterName + "(ID: " + targetPlayer.CSteamID.ToString() + ")"); TebexCommandRunner.doOnlineCommands((int)player["id"], (string)targetPlayer.CharacterName, targetPlayer.CSteamID.ToString()); } } catch (Exception e) { Tebex.logError(e.Message); } } }
public void HandleError(Exception e) { Tebex.logError("We are unable to fetch your server queue. Please check your secret key."); Tebex.logError(e.ToString()); }
public void HandleError(Exception e) { Tebex.logError("We are unable to fetch your server details. Please check your secret key."); }
public void HandleError(Exception e) { Tebex.logError("We were unable to validate your secret key."); }
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)); }