public string Command(string Text) { if (Debug) { Console.WriteLine(Text); } return(Client.sendMessage(RCONMessageType.Command, Text)); }
private void sendButton_OnClick(object sender, RoutedEventArgs e) { _vmConsole.McResponse = _rconClient.sendMessage(RCONMessageType.Command, _vmConsole.McCommand); CollectUsedCommands(); ShowCommandsAndResponseOnMonitor(); }
public void SendBTN_Click(object sender, EventArgs e) // Sends doesn't save { string txt = CMDInput.Text; historyStrings.Add(txt); historyPointer = historyStrings.Count; var answer3 = RCONClient.sendMessage(OtherRCON.RCONMessageType.Command, txt); Output.AppendText(AnsiOutput.Reset()); // reset colors Output.AppendText(txt + "\n"); Output.AppendText(answer3); CMDInput.Text = ""; }
public static bool executePlugin(RCONClient rconClient, IEnumerable <string> players) { Monitor.Enter(threadLock); try { if (!pluginIsActive) { return(false); } var isRestrictedWorld = rconClient.sendMessage(RCONMessageType.Command, restrictedWorldCommand).RemoveColorCodes().Trim() == string.Empty; if (!isRestrictedWorld) { // Reset the status if a player gets lost: if (players.Count(n => n != string.Empty) != destinationCountPlayers) { allPlayersPresent = false; } // If not all players are present, delete the inventories: if (!allPlayersPresent && players.Count(n => n != string.Empty) != destinationCountPlayers && players.Count(n => n != string.Empty) > 0) { foreach (var player in players.Where(n => n != string.Empty)) { var name = player.RemoveColorCodes().Trim(); rconClient.sendMessage(RCONMessageType.Command, @"clear " + name); } allPlayersPresent = false; return(true); } // Now, all players are in place: if (items.Length > 0 && !allPlayersPresent) { allPlayersPresent = true; // // First: Clear all inventories (important for the last player who was new) // foreach (var player in players.Where(n => n != string.Empty)) { var name = player.RemoveColorCodes().Trim(); rconClient.sendMessage(RCONMessageType.Command, @"clear " + name); } // // Second: Distribute the items // // Get the right list of items which matches the count of players: var rightItemList = items.Skip(items.Length % destinationCountPlayers).ToArray(); // Memorise the already used items: var usedItems = new List <int>(); for (var n = 0; n < rightItemList.Length / destinationCountPlayers; n++) { foreach (var playerName in players.Where(player => player != string.Empty)) { // Find the next matching number i.e. item's position: var nextNumber = 0; while (true) { nextNumber = BetterRND.INSTANCE.nextInt(0, rightItemList.Length); if (!usedItems.Contains(nextNumber)) { usedItems.Add(nextNumber); break; } else { Thread.Sleep(1); continue; } } // Get the item: var item = " " + rightItemList[nextNumber]; // Build the command: var item4Player = "give " + playerName.RemoveColorCodes().Trim() + item; // Send the command: rconClient.fireAndForgetMessage(RCONMessageType.Command, item4Player); } } } } return(true); } finally { Monitor.Exit(threadLock); } }