Advertisement
EpicKnarvik97

Minecraft Server Controller

Jul 28th, 2013
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.43 KB | None | 0 0
  1. #region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Icon=C:\Users\Kristian\Downloads\Minecraft Icon Version III.ico
  3. #AutoIt3Wrapper_Compression=4
  4. #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
  5.  
  6.  
  7.  
  8. #include <ButtonConstants.au3>
  9. #include <ComboConstants.au3>
  10. #include <GUIConstantsEx.au3>
  11. #include <GuiToolbar.au3>
  12. #include <StaticConstants.au3>
  13. #include <ToolbarConstants.au3>
  14. #include <WindowsConstants.au3>
  15. #include <GUIConstants.au3>
  16. #include <Misc.au3>
  17. #include <EditConstants.au3>
  18. #include <WindowsConstants.au3>
  19. #include <GuiComboBoxEx.au3>
  20. #include <TreeViewConstants.au3>
  21. #include <GuiTreeView.au3>
  22.  
  23.  
  24.  
  25. #region ### START Koda GUI section ### Form=c:\users\kristian\desktop\test.kxf
  26. $Test = GUICreate("KnarCraft MineCraft Server Client -Made by Kristian Knarvik/EpicKnarvik97", 945, 150, 0, 0)
  27.  
  28. $Button1 = GUICtrlCreateButton("Start Server", 24, 85, 75, 25)
  29. $Button2 = GUICtrlCreateButton("Stop Server", 840, 85, 75, 25)
  30. $Button3 = GUICtrlCreateButton("Kick", 112, 85, 75, 25)
  31. $Checkbox1 = GUICtrlCreateCheckbox("Hide Console", 24, 60, 97, 17)
  32. $Command_Arguments = GUICtrlCreateInput("", 392, 85, 320, 21)
  33. $Button4 = GUICtrlCreateButton("Ban", 208, 85, 75, 25)
  34. $Button5 = GUICtrlCreateButton("OP", 304, 85, 75, 25)
  35. $Button6 = GUICtrlCreateButton("Custom Command", 728, 85, 91, 25)
  36. $Button7 = GUICtrlCreateButton("Save Server", 840, 60, 75, 25)
  37. $Label1 = GUICtrlCreateLabel("Choose Server Memory", 24, 10, 166, 20)
  38. GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
  39. $Combo1 = GUICtrlCreateCombo("-Xmx512M", 24, 35, 161, 25, $CBS_DROPDOWNLIST)
  40. GUICtrlSetData(-1, "-Xmx1024M|-Xmx2048M|-Xmx3072M|-Xmx4096M|-Xmx5120M|-Xmx6144M|-Xmx7168M|-Xmx8192M|-Xmx9216M|-Xmx10240M")
  41.  
  42. $filemenu = GUICtrlCreateMenu("File")
  43. $fileitem = GUICtrlCreateMenuItem("Open...", $filemenu)
  44. $separator1 = GUICtrlCreateMenuItem("", $filemenu)
  45. $helpmenu = GUICtrlCreateMenu("Help")
  46. $aboutitem = GUICtrlCreateMenuItem("About", $helpmenu)
  47.  
  48. GUISetState(@SW_SHOW)
  49. #endregion ### END Koda GUI section ###
  50.  
  51.  
  52. ReadStats()
  53.  
  54.  
  55. While 1
  56. $chosen = GUICtrlRead($Combo1)
  57. $args = GUICtrlRead($Command_Arguments)
  58. $nMsg = GUIGetMsg()
  59. If GUICtrlRead($Checkbox1) = 1 Then
  60. $Hide = @SW_HIDE
  61. Else
  62. $Hide = @SW_SHOW
  63. EndIf
  64. Switch $nMsg
  65. Case $GUI_EVENT_CLOSE
  66. $exit = MsgBox(1, "KnarCraft", "Do you want to close the client?")
  67. WriteStats()
  68. If $exit = 1 Then Exit
  69. Case $Button1
  70. Hub_func()
  71. Case $Button3
  72. Opt("WinTitleMatchMode", 3)
  73. $hwnd = WinGetHandle("Minecraft Server")
  74. If @error Then
  75. MsgBox(16, "Failure", "The server isn't running")
  76. Else
  77. SoundPlay("C:\Program Files (x86)\KnarCraft\Blop-Mark_DiAngelo-79054334.mp3", 0)
  78. WinActivate($hwnd)
  79. ControlSend("Minecraft Server", "", $hwnd, 'kick ')
  80. ControlSend("Minecraft Server", "", $hwnd, $args)
  81. ControlSend("Minecraft Server", "", $hwnd, '{ENTER}')
  82. EndIf
  83. Case $Button4
  84. Opt("WinTitleMatchMode", 3)
  85. $hwnd = WinGetHandle("Minecraft Server")
  86. If @error Then
  87. MsgBox(16, "Failure", "The server isn't running")
  88. Else
  89. SoundPlay("C:\Program Files (x86)\KnarCraft\Blop-Mark_DiAngelo-79054334.mp3", 0)
  90. WinActivate($hwnd)
  91. ControlSend("Minecraft Server", "", $hwnd, 'ban ')
  92. ControlSend("Minecraft Server", "", $hwnd, $args)
  93. ControlSend("Minecraft Server", "", $hwnd, '{ENTER}')
  94. EndIf
  95. Case $Button5
  96. Opt("WinTitleMatchMode", 3)
  97. $hwnd = WinGetHandle("Minecraft Server")
  98. If @error Then
  99. MsgBox(16, "Failure", "The server isn't running")
  100. Else
  101. SoundPlay("C:\Program Files (x86)\KnarCraft\Blop-Mark_DiAngelo-79054334.mp3", 0)
  102. WinActivate($hwnd)
  103. ControlSend("Minecraft Server", "", $hwnd, 'op ')
  104. ControlSend("Minecraft Server", "", $hwnd, $args)
  105. ControlSend("Minecraft Server", "", $hwnd, '{ENTER}')
  106. EndIf
  107. Case $Button7
  108. Opt("WinTitleMatchMode", 3)
  109. $hwnd = WinGetHandle("Minecraft Server")
  110. If @error Then
  111. MsgBox(16, "Failure", "The server isn't running")
  112. Else
  113. SoundPlay("C:\Program Files (x86)\KnarCraft\Blop-Mark_DiAngelo-79054334.mp3", 0)
  114. WinActivate($hwnd)
  115. ControlSend("Minecraft Server", "", $hwnd, 'save-all {ENTER}')
  116. EndIf
  117. Case $Button6
  118. Opt("WinTitleMatchMode", 3)
  119. $hwnd = WinGetHandle("Minecraft Server")
  120. If @error Then
  121. MsgBox(16, "Failure", "The server isn't running")
  122. Else
  123. SoundPlay("C:\Program Files (x86)\KnarCraft\Blop-Mark_DiAngelo-79054334.mp3", 0)
  124. WinActivate($hwnd)
  125. ControlSend("Minecraft Server", "", $hwnd, $args)
  126. ControlSend("Minecraft Server", "", $hwnd, '{ENTER}')
  127. EndIf
  128. Case $Button2
  129. Opt("WinTitleMatchMode", 3)
  130. $hwnd = WinGetHandle("Minecraft Server")
  131. If @error Then
  132. MsgBox(16, "Failure", "The server isn't running")
  133. Else
  134. SoundPlay("C:\Program Files (x86)\KnarCraft\Blop-Mark_DiAngelo-79054334.mp3", 0)
  135. ConsoleWrite("Window handle is " & $hwnd & @CRLF)
  136. WinActivate($hwnd)
  137. Send("stop {ENTER}")
  138. EndIf
  139. Case $fileitem
  140. $loc = FileSelectFolder("Choose file location...", "\")
  141. $file = FileOpenDialog("Choose file...", $loc, "Jar Files (*.jar*)")
  142. IniWrite("C:\Program Files (x86)\KnarCraft\Config.ini", "Server File", "File", $file)
  143. IniWrite("C:\Program Files (x86)\KnarCraft\Config.ini", "Server File", "Loc", $loc)
  144. Case $aboutitem
  145. MsgBox(0, "Server Client", "This is a client that lets you easily control the server. Just click File then open and go to your server jarfile. It will be saved with your other settings under C:\Program Files (x86)\KnarCraft\Config.ini Then choose how much server memory you want to dedicate from the dropbox. If you want, you can also check the Hide Console checkbox to prevent the console window from popping up. Then just start the server with the start server button and you are good to go. The kick/ban/op buttons do what they say against the name in the text box. The save server button runs save-all and the stop server button runs stop. The custom command button allows every button you can use from the console. Just type in every command you want in the white box and hit the button. Remember. Since it's a console command, don't use / before the command.")
  146. EndSwitch
  147. WEnd
  148.  
  149.  
  150.  
  151. Func WriteStats()
  152. IniWrite("C:\Program Files (x86)\KnarCraft\Config.ini", "Checkbox", "Check1", GUICtrlRead($Checkbox1))
  153. IniWrite("C:\Program Files (x86)\KnarCraft\Config.ini", "Combo", "Comb1", $chosen)
  154. EndFunc
  155.  
  156. Func ReadStats()
  157. $Read1 = IniRead("C:\Program Files (x86)\KnarCraft\Config.ini", "Checkbox", "Check1", "1")
  158. $Read3 = IniRead("C:\Program Files (x86)\KnarCraft\Config.ini", "Combo", "Comb1", StringSplit("-Xmx1024M|-Xmx2048M|-Xmx3072M|-Xmx4096M", "|"))
  159. Global $file = IniRead("C:\Program Files (x86)\KnarCraft\Config.ini", "Server File", "File", "")
  160. Global $loc = IniRead("C:\Program Files (x86)\KnarCraft\Config.ini", "Server File", "Loc", "")
  161. GUICtrlSetData($Combo1, IniRead("C:\Program Files (x86)\KnarCraft\Config.ini", "Combo", "Comb1", "-Xmx1024M|-Xmx2048M|-Xmx3072M|-Xmx4096M"))
  162. If $Read1 = Int(1) = 1 Then
  163. GUICtrlSetState($Checkbox1, $GUI_CHECKED)
  164. Else
  165. GUICtrlSetState($Checkbox1, $GUI_UNCHECKED)
  166. EndIf
  167. EndFunc
  168.  
  169. Func Hub_func()
  170. If $file = "" Then
  171. MsgBox(16, "Failure", "No Server chosen")
  172. Else
  173. SoundPlay("C:\Program Files (x86)\KnarCraft\Blop-Mark_DiAngelo-79054334.mp3", 0)
  174. Run('java -jar "' & $chosen & '" "' & $file & '"', $loc, $Hide)
  175. Sleep(100)
  176. WinSetTitle("C:\Windows\system32\java.exe", "", "Minecraft Server")
  177. EndIf
  178. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement