[Minecraft Server] Eigenen Server Starter programmieren ! Aber Wie ?

  • VB.NET

Es gibt 23 Antworten in diesem Thema. Der letzte Beitrag () ist von DarkestMan.

    [Minecraft Server] Eigenen Server Starter programmieren ! Aber Wie ?

    Hallo Forum,


    Wie ihr in der Überschrift schon gelesen habt geht es um einem Server Starter für meinen Minecraft Server !


    Zu meiner Frage:

    Ich habe eine Form die so aussieht:



    Ich will nun folgendes realisieren:

    Bei der Combobox soll man den Server auswählen!
    wenn man auf Server Starten klick startet der Server (hab ich hinbekommen)!
    Nun will ich das der Verlauf des Servers in der Richtextbox live wiedergegeben wird (wie geht das ?)
    Und wenn ich Unter der Richttextbox einen Befehl eingebe und ich danach auf Ausführen klicke soll dies ausgeführt werden (wie geht das ?)
    Wenn ich in Die Textbox1 (Spielername) einen Namen eingebe und auf einen der Buttons Klicke soll z.b der Spieler OP werden (wie geht das ?)


    Bitte helf mir das zu realisieren ;(

    Ich weiß das das irgendwie mit Input und Output geht aber ich hab keine Ahnung wie ich das mache


    Ich bitte um Hilfe
    Danke
    msdn.microsoft.com/de-de/libra…ics.process(v=vs.80).aspx
    msdn.microsoft.com/de-de/libra….diagnostics.process.aspx

    Wichtig ist sind StandardOutput und StandardInput. Bei beiden kriegst du einen Stream. Beim Output kannst du logischerweise nur lesen (also das schreiben hat meines Wissens keine Auswirkung) und beim Input genau andersherum.

    Myrax schrieb:

    Mich überliest man mal wieder geschickt: ich hab alles gepostet, was du brauchst.

    Ich hab dich nicht Überlesen :) Danke für die Links aber bei mir kommt bei "Namespace" ein Fehler :S



    VB.NET-Quellcode

    1. Namespace-Anweisungen können nur auf Namespace- oder Dateiebene verwendet werden.


    Was muss ich tun ?

    VB.NET-Quellcode

    1. Imports System.Diagnostics
    2. Imports System.Threading
    3. Imports System.IO
    4. Imports System.Net
    5. Imports System.ComponentModel
    6. Imports System
    7. Public Class ServerStarten
    8. 'Declaration
    9. Public Class Process
    10. Inherits Component
    11. 'Usage
    12. Dim instance As Process
    13. Private output As String
    14. End Class
    15. Namespace MyProcessSample
    16. _
    17. '/ <summary>
    18. '/ Shell for the sample.
    19. '/ </summary>
    20. Class MyProcess
    21. ' These are the Win32 error code for file not found or access denied.
    22. Private ERROR_FILE_NOT_FOUND As Integer = 2
    23. Private ERROR_ACCESS_DENIED As Integer = 5
    24. '/ <summary>
    25. '/ Prints a file with a .doc extension.
    26. '/ </summary>
    27. Sub PrintDoc()
    28. Dim myProcess As New Process()
    29. Try
    30. ' Get the path that stores user documents.
    31. Dim myDocumentsPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
    32. myProcess.StartInfo.FileName = myDocumentsPath + "\MyFile.doc"
    33. myProcess.StartInfo.Verb = "Print"
    34. myProcess.StartInfo.CreateNoWindow = True
    35. myProcess.Start()
    36. Catch e As Win32Exception
    37. If e.NativeErrorCode = ERROR_FILE_NOT_FOUND Then
    38. Console.WriteLine((e.Message + ". Check the path."))
    39. Else
    40. If e.NativeErrorCode = ERROR_ACCESS_DENIED Then
    41. ' Note that if your word processor might generate exceptions
    42. ' such as this, which are handled first.
    43. Console.WriteLine((e.Message + ". You do not have permission to print this file."))
    44. End If
    45. End If
    46. End Try
    47. End Sub 'PrintDoc
    48. Public Shared Sub Main()
    49. Dim myProcess As New MyProcess()
    50. myProcess.PrintDoc()
    51. End Sub 'Main
    52. End Class 'MyProcess
    53. End Namespace 'MyProcessSample
    54. Private Sub getfolders(ByVal Path As String)
    55. Dim folders() As String = System.IO.Directory.GetDirectories(Path)
    56. For Each folder As String In folders
    57. ComboBox1.Items.Add(folder)
    58. getfolders(folder)
    59. Next
    60. End Sub
    61. Sub abrunden(ByVal was As Object, _
    62. ByVal x As Integer, ByVal y As Integer, _
    63. ByVal width As Integer, ByVal height As Integer, _
    64. ByVal radius As Integer)
    65. Dim gp As System.Drawing.Drawing2D.GraphicsPath = _
    66. New System.Drawing.Drawing2D.GraphicsPath()
    67. gp.AddLine(x + radius, y, x + width - radius, y)
    68. gp.AddArc(x + width - radius, y, radius, radius, 270, 90)
    69. gp.AddLine(x + width, y + radius, x + width, y + height - radius)
    70. gp.AddArc(x + width - radius, y + height - radius, radius, radius, 0, 90)
    71. gp.AddLine(x + width - radius, y + height, x + radius, y + height)
    72. gp.AddArc(x, y + height - radius, radius, radius, 90, 90)
    73. gp.AddLine(x, y + height - radius, x, y + radius)
    74. gp.AddArc(x, y, radius, radius, 180, 90)
    75. gp.CloseFigure()
    76. was.region = New System.Drawing.Region(gp)
    77. gp.Dispose()
    78. End Sub
    79. Private mouse_offset As Point
    80. Private Sub Form1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
    81. mouse_offset = New Point(-e.X, -e.Y)
    82. End Sub
    83. Private Sub Form1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
    84. If e.Button = MouseButtons.Left Then
    85. Dim mousePos As Point = Control.MousePosition
    86. mousePos.Offset(mouse_offset.X, mouse_offset.Y)
    87. Location = mousePos
    88. End If
    89. End Sub
    90. Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    91. CONSOLENFEHLER.Visible = True
    92. Timer1.Start()
    93. End Sub
    94. Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
    95. CONSOLENFEHLER.Visible = False
    96. Timer1.Stop()
    97. End Sub
    98. Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
    99. Shell(Application.UserAppDataPath & "\Erstellte Server\" & ComboBox1.Text & "Start.bat", "echo stop")
    100. StartetdenServer.Enabled = True
    101. Button2.Enabled = False
    102. End Sub
    103. Private Sub Label4_Click(sender As System.Object, e As System.EventArgs) Handles Label4.Click
    104. Me.WindowState = FormWindowState.Minimized
    105. End Sub
    106. Private Sub Label3_Click(sender As System.Object, e As System.EventArgs) Handles Label3.Click
    107. Application.Exit()
    108. End Sub
    109. Private Sub ServerStarten_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    110. For Each folder As String In IO.Directory.GetDirectories(Application.UserAppDataPath & "\Erstellte Server\")
    111. ComboBox1.Items.Add(New IO.DirectoryInfo(folder).Name)
    112. Next
    113. abrunden(Me, 0, 0, Me.Width, Me.Height, 10)
    114. End Sub
    115. Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles Button7.Click
    116. Menü.Show()
    117. Me.Close()
    118. End Sub
    119. Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
    120. If ComboBox1.Text > "" Then
    121. ServerWählen.Visible = False
    122. Shell(Application.UserAppDataPath & "\Erstellte Server\" & ComboBox1.Text & "Start.bat", "kick " & InGameName.Text)
    123. Else
    124. ServerWählen.Visible = True
    125. End If
    126. End Sub
    127. Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
    128. If ComboBox1.Text > "" Then
    129. ServerWählen.Visible = False
    130. Shell(Application.UserAppDataPath & "\Erstellte Server\" & ComboBox1.Text & "Start.bat", "ban " & InGameName.Text)
    131. Else
    132. ServerWählen.Visible = True
    133. End If
    134. End Sub
    135. Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
    136. If ComboBox1.Text > "" Then
    137. ServerWählen.Visible = False
    138. Shell(Application.UserAppDataPath & "\Erstellte Server\" & ComboBox1.Text & "Start.bat", "op " & InGameName.Text)
    139. Else
    140. ServerWählen.Visible = True
    141. End If
    142. End Sub
    143. Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click
    144. If ComboBox1.Text > "" Then
    145. ServerWählen.Visible = False
    146. Shell(Application.UserAppDataPath & "\Erstellte Server\" & ComboBox1.Text & "Start.bat", "deop " & InGameName.Text)
    147. Else
    148. ServerWählen.Visible = True
    149. End If
    150. End Sub
    151. End Class


    Derzeit benutze ich diesen Code;
    Au... das ist kein CP.

    VB.NET-Quellcode

    1. Dim myProcess As Process = New Process()
    2. myProcess.StartInfo.FileName = pfad
    3. myProcess.Start()
    4. 'Input Stream
    5. Dim inputStream As System.IO.Stream = myProcess.StandartInput
    6. Dim outputStream As System.IO.Stream = myProcess.StandartOutput

    Myrax schrieb:

    Au... das ist kein CP.

    VB.NET-Quellcode

    1. Dim myProcess As Process = New Process()
    2. myProcess.StartInfo.FileName = pfad
    3. myProcess.Start()
    4. 'Input Stream
    5. Dim inputStream As System.IO.Stream = myProcess.StandartInput
    6. Dim outputStream As System.IO.Stream = myProcess.StandartOutput



    Wenn ich diesen Code benutze kommt folgende Fehlermeldung:

    VB.NET-Quellcode

    1. StandartInput" ist kein Member von "System.Diagnostics.Process".

    VB.NET-Quellcode

    1. StandartOutput" ist kein Member von "System.Diagnostics.Process".


    Was Tun ?
    sry mein Fehler :S

    EDIT: Jetzt kommt bei dem Code:

    VB.NET-Quellcode

    1. Dim inputStream As System.IO.Stream = myProcess.StandardInput
    2. Dim outputStream As System.IO.Stream = myProcess.StandardOutput


    Folgender Fehler :

    VB.NET-Quellcode

    1. Der Wert vom Typ "System.IO.StreamReader" kann nicht in "System.IO.Stream" konvertiert werden.


    ? :(

    haiyyu schrieb:

    StandardInput ist vom Typ StreamReader, deine Variable aber Stream.



    Danke Problem gelöst =)


    OK wie sage ich nun meiner RichTextbox das sie den Konsolen Verlauf auslesen soll ?

    Ich wollte Folgendes Versuchen

    VB.NET-Quellcode

    1. Richtextbox1.Text = outputstream.ReadToEnd


    Das hat aber ned Funktioniert (Hab ich befürchtet) den da kommt dieser Fehler:

    VB.NET-Quellcode

    1. StandardOut wurde nicht umgeleitet, oder der Prozess wurde noch nicht gestartet.