Advertisement
EpicKnarvik97

Bungee Controller

Nov 29th, 2013
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Icon=Resources\Diamond Icon.ico
  3. #AutoIt3Wrapper_Outfile_x64=..\..\Desktop\Bungee Server Launcher.exe
  4. #endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
  5. #region Include
  6. #include <GUIConstants.au3>
  7. #include <GUIConstantsEx.au3>
  8. #include <GuiComboBoxEx.au3>
  9. #include <Constants.au3>
  10. #include <ProgressConstants.au3>
  11. #include <GuiStatusBar.au3>
  12. #include <EditConstants.au3>
  13. #include <WindowsConstants.au3>
  14. #include <Constants.au3>
  15. #include <WindowsConstants.au3>
  16. #include <EditConstants.au3>
  17. #include <WinAPI.au3>
  18. #endregion Include
  19. #region GUI
  20. Global $hwnd0, $hwnd1, $hwnd2, $hwnd3, $hwnd4, $hwnd5, $servers, $backupdir, $file0, $file1, $file2, $file3, $file4, $file5, $chosen2, $chosen3, $Combo3, $Read3, $1, $2, $3, $BungeeServer, $GUI, $hwnd00, $Edit1, $Edit2, $Edit3, $Hide = @SW_SHOW, $GUI2;Global variabled needed to be defined because they aren't before further down then they are needed.
  21. $GUI = GUICreate("MineCraft Server Client -Made by EpicKnarvik97", 450, 170, 0, 0);The main GUI
  22. $Tab1 = GUICtrlCreateTab(8, 8, 435, 110);The main tab
  23. $TabSheet1 = GUICtrlCreateTabItem("Basic Controls");Tab 1:Basic controls
  24. $Label1 = GUICtrlCreateLabel("Server(s) are closed", 10, 125);State of the servers (Based on the start and stop server buttons).
  25. $StartG = GUICtrlCreateButton("Start Server", 10, 35, 75, 25);The button that starts the server.
  26. $StopG = GUICtrlCreateButton("Stop Server", 10, 60, 75, 25);The button that stops the server.
  27. $Command_Arguments = GUICtrlCreateInput("", 11, 86, 213, 25);Input to allow command arguments.
  28. $KickG = GUICtrlCreateButton("Kick", 87, 35, 75, 25);The button that kicks a player.
  29. $SaveG = GUICtrlCreateButton("Save Server", 87, 60, 75, 25);The button that saves the server.
  30. $BanG = GUICtrlCreateButton("Ban", 164, 35, 75, 25);The button that bans a player.
  31. $UnbanG = GUICtrlCreateButton("Unban", 164, 60, 75, 25);The button that bans a player.
  32. $OPG = GUICtrlCreateButton("OP", 241, 35, 75, 25);The button that ops a player.
  33. $DEOPG = GUICtrlCreateButton("DEOP", 241, 60, 75, 25);The button that deops a player.
  34. $CCG = GUICtrlCreateButton("Custom Command", 225, 86, 91, 25);The button that runs a command of your choice.
  35. $addw = GUICtrlCreateButton("Add to Whitelist", 318, 35, 115);The button that adds a player to the whitelist.
  36. $delw = GUICtrlCreateButton("Remove from Whitelist", 318, 60, 115);The button that removes a player from the whitelist.
  37. $backup = GUICtrlCreateButton("Backup", 318, 86, 115);The button that commences a backup of the server.
  38. $consoles = GUICtrlCreateButton("Console Output", 318, 120, 115);The button that toggles visibility of the server.
  39. $helpmenu = GUICtrlCreateMenu("Help");Creates a helpmenu
  40. $setupitem = GUICtrlCreateMenuItem("Setup", $helpmenu);Creates a setup item in the helpmenu
  41. $help = GUICtrlCreateMenuItem("Warning", $helpmenu);Creates a warning item in the helpmenu
  42. $info = GUICtrlCreateMenu("Info");Creates an infomenu
  43. $aboutitem = GUICtrlCreateMenuItem("About", $info);Creates an About item in the infomenu
  44. $How = GUICtrlCreateMenuItem("How does it work?", $info);Creates a "How does it work" item in the infomenu
  45. $TabSheet2 = GUICtrlCreateTabItem("Server Config");Tab 2: Server Config
  46. $Bungee = GUICtrlCreateCheckbox("Bungee", 175, 35, 97, 25);The checkboz that enables the Bungee server.
  47. $server1 = GUICtrlCreateCheckbox("Enable Server 1", 175, 60, 97, 25);The checkbox that enabled Server1.
  48. $server2 = GUICtrlCreateCheckbox("Enable Server 2", 175, 85, 97, 25);The checkbox that enabled Server2.
  49. $server3 = GUICtrlCreateCheckbox("Enable Server 3", 300, 35, 97, 25);The checkbox that enabled Server3.
  50. $server4 = GUICtrlCreateCheckbox("Enable Server 4", 300, 60, 97, 25);The checkbox that enabled Server4.
  51. $server5 = GUICtrlCreateCheckbox("Enable Server 5", 300, 85, 97, 25);The checkbox that enabled Server5.
  52. $DelConf = GUICtrlCreateButton("Delete all configurations and exit", 10, 120, 160, 25);The button that deletes all of your configurations.
  53. $Combo1 = GUICtrlCreateCombo("Server Memory", 10, 35, 161, 25, $CBS_DROPDOWNLIST);A combo defined as a dropbox to choose server memory.
  54. GUICtrlSetData($Combo1, "-Xmx1024M|-Xmx2048M|-Xmx3072M|-Xmx4096M|-Xmx5120M|-Xmx6144M|-Xmx7168M|-Xmx8192M|-Xmx9216M|-Xmx10240M");This sets the data aka the different choices of the dropbox.
  55. $Combo2 = GUICtrlCreateCombo("Server Type", 10, 60, 161, 25, $CBS_DROPDOWNLIST)
  56. GUICtrlSetData($Combo2, "Vanilla|Snapshot|Spigot|CB Dev|CB Stable|CB Beta")
  57. If RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Combo2") = "Vanilla" Then
  58.     GUISwitch($GUI, $TabSheet2)
  59.     $Combo3 = GUICtrlCreateCombo("Choose Version", 10, 85, 161, 25, $CBS_DROPDOWNLIST)
  60.     GUICtrlSetData($Combo3, "Latest|1.6.4|1.6.2|1.5.2|1.4.7|1.4.5")
  61.     GUISwitch($GUI, $TabSheet1)
  62. EndIf
  63. $TabSheet3 = GUICtrlCreateTabItem("Extra cmd settings")
  64. GUICtrlCreateLabel("Coming Soon", 60, 50, 200, 40)
  65. GUICtrlSetFont(-1, 20, 400, "", "Verdana")
  66. GUICtrlCreateTabItem("")
  67. GUISetState(@SW_SHOW)
  68. #endregion GUI
  69. #region Loc prompt and readstats
  70. ReadStats()
  71. If $backupdir = "" Then $backupdir = FileSelectFolder("Choose Backups Location", "");Prompts for a location if it isn't defined.
  72. If GUICtrlRead($Bungee) = 1 And $file0 = "" Then $file0 = FileSelectFolder("Choose Bungee Server Location...", "");Prompts for a location if it isn't defined.
  73. If GUICtrlRead($server1) = 1 And $file1 = "" Then $file1 = FileSelectFolder("Choose Server 1 Location...", "");Prompts for a location if it isn't defined.
  74. If GUICtrlRead($server2) = 1 And $file2 = "" Then $file2 = FileSelectFolder("Choose Server 2 Location...", "");Prompts for a location if it isn't defined.
  75. If GUICtrlRead($server3) = 1 And $file3 = "" Then $file3 = FileSelectFolder("Choose Server 3 Location...", "");Prompts for a location if it isn't defined.
  76. If GUICtrlRead($server4) = 1 And $file4 = "" Then $file4 = FileSelectFolder("Choose Server 4 Location...", "");Prompts for a location if it isn't defined.
  77. If GUICtrlRead($server5) = 1 And $file5 = "" Then $file5 = FileSelectFolder("Choose Server 5 Location...", "");Prompts for a location if it isn't defined.
  78. #endregion Loc prompt and readstats
  79. While 1;The script's loop.
  80.     $chosen = GUICtrlRead($Combo1)
  81.     $chosen2 = GUICtrlRead($Combo2)
  82.     $chosen3 = GUICtrlRead($Combo3)
  83.     $args = GUICtrlRead($Command_Arguments)
  84.     $nMsg = GUIGetMsg()
  85.     Switch $nMsg
  86.         Case $GUI_EVENT_CLOSE
  87.             WriteStats()
  88.             Exit
  89.         Case $Combo2;Makes a combo to choose vanilla version.
  90.             If $chosen2 = "Vanilla" Then
  91.                 GUISwitch($GUI, $TabSheet2)
  92.                 $Combo3 = GUICtrlCreateCombo("Choose Version", 10, 85, 161, 25, $CBS_DROPDOWNLIST)
  93.                 GUICtrlSetData($Combo3, "Latest|1.6.4|1.6.2|1.5.2|1.4.7|1.4.5")
  94.                 $Read9 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Combo3")
  95.                 If Not $Read9 = "" Then
  96.                     GUICtrlSetData($Combo3, $Read9)
  97.                 EndIf
  98.                 GUICtrlCreateTabItem("")
  99.             Else
  100.                 RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Combo3", "REG_SZ", GUICtrlRead($Combo3))
  101.                 GUISwitch($GUI, $TabSheet2)
  102.                 GUICtrlDelete($Combo3)
  103.             EndIf
  104.         Case $consoles;Changes the state of the comsoles window.
  105.             If $servers = "RUNNING" Then
  106.                 If BitAND(WinGetState($GUI2), 2) Then
  107.                     GUISetState(@SW_HIDE, $GUI2)
  108.                 Else
  109.                     GUISetState(@SW_SHOW, $GUI2)
  110.                 EndIf
  111.             Else
  112.                 MsgBox(16, "Failure", "The server isn't running")
  113.             EndIf
  114.         Case $StartG;Starts the servers as long as at least one is selected.
  115.             If GUICtrlRead($Bungee) = $GUI_UNCHECKED And GUICtrlRead($server1) = $GUI_UNCHECKED And GUICtrlRead($server2) = $GUI_UNCHECKED And GUICtrlRead($server3) = $GUI_UNCHECKED And GUICtrlRead($server4) = $GUI_UNCHECKED And GUICtrlRead($server5) = $GUI_UNCHECKED Then
  116.                 MsgBox(-1, "ERROR", "No servers enabled")
  117.             Else
  118.                 Start()
  119.             EndIf
  120.         Case $KickG;Kicks a player
  121.             If $servers = "RUNNING" Then
  122.                 ControlSend("Server1", "", $hwnd1, 'kick ' & $args & '{ENTER}')
  123.                 ControlSend("Server2", "", $hwnd2, 'kick ' & $args & '{ENTER}')
  124.                 ControlSend("Server3", "", $hwnd3, 'kick ' & $args & '{ENTER}')
  125.                 ControlSend("Server4", "", $hwnd4, 'kick ' & $args & '{ENTER}')
  126.                 ControlSend("Server5", "", $hwnd5, 'kick ' & $args & '{ENTER}')
  127.             Else
  128.                 MsgBox(16, "Failure", "The server isn't running")
  129.             EndIf
  130.         Case $BanG;Bans a player
  131.             If $servers = "RUNNING" Then
  132.                 ControlSend("Server1", "", $hwnd1, 'ban ' & $args & '{ENTER}')
  133.                 ControlSend("Server2", "", $hwnd2, 'ban ' & $args & '{ENTER}')
  134.                 ControlSend("Server3", "", $hwnd3, 'ban ' & $args & '{ENTER}')
  135.                 ControlSend("Server4", "", $hwnd4, 'ban ' & $args & '{ENTER}')
  136.                 ControlSend("Server5", "", $hwnd5, 'ban ' & $args & '{ENTER}')
  137.             Else
  138.                 MsgBox(16, "Failure", "The server isn't running")
  139.             EndIf
  140.         Case $UnbanG;Unbans a player
  141.             If $servers = "RUNNING" Then
  142.                 ControlSend("Server1", "", $hwnd1, 'pardon ' & $args & '{ENTER}')
  143.                 ControlSend("Server2", "", $hwnd2, 'pardon ' & $args & '{ENTER}')
  144.                 ControlSend("Server3", "", $hwnd3, 'pardon ' & $args & '{ENTER}')
  145.                 ControlSend("Server4", "", $hwnd4, 'pardon ' & $args & '{ENTER}')
  146.                 ControlSend("Server5", "", $hwnd5, 'pardon ' & $args & '{ENTER}')
  147.             Else
  148.                 MsgBox(16, "Failure", "The server isn't running")
  149.             EndIf
  150.         Case $OPG;Ops a player
  151.             If $servers = "RUNNING" Then
  152.                 ControlSend("Server1", "", $hwnd1, 'op ' & $args & '{ENTER}')
  153.                 ControlSend("Server2", "", $hwnd2, 'op ' & $args & '{ENTER}')
  154.                 ControlSend("Server3", "", $hwnd3, 'op ' & $args & '{ENTER}')
  155.                 ControlSend("Server4", "", $hwnd4, 'op ' & $args & '{ENTER}')
  156.                 ControlSend("Server5", "", $hwnd5, 'op ' & $args & '{ENTER}')
  157.             Else
  158.                 MsgBox(16, "Failure", "The server isn't running")
  159.             EndIf
  160.         Case $DEOPG;Deops a player
  161.             If $servers = "RUNNING" Then
  162.                 ControlSend("Server1", "", $hwnd1, 'deop ' & $args & '{ENTER}')
  163.                 ControlSend("Server2", "", $hwnd2, 'deop ' & $args & '{ENTER}')
  164.                 ControlSend("Server3", "", $hwnd3, 'deop ' & $args & '{ENTER}')
  165.                 ControlSend("Server4", "", $hwnd4, 'deop ' & $args & '{ENTER}')
  166.                 ControlSend("Server5", "", $hwnd5, 'deop ' & $args & '{ENTER}')
  167.             Else
  168.                 MsgBox(16, "Failure", "The server isn't running")
  169.             EndIf
  170.         Case $SaveG;Saving the servers' blockstates.
  171.             If $servers = "RUNNING" Then
  172.                 ControlSend("Consoles", "", $hwnd00, ControlSend("Server1", "", $hwnd1, 'save-all' & '{ENTER}'))
  173.                 ControlSend("Server2", "", $hwnd2, 'save-all' & '{ENTER}')
  174.                 ControlSend("Server3", "", $hwnd3, 'save-all' & '{ENTER}')
  175.                 ControlSend("Server4", "", $hwnd4, 'save-all' & '{ENTER}')
  176.                 ControlSend("Server5", "", $hwnd5, 'save-all' & '{ENTER}')
  177.             Else
  178.                 MsgBox(16, "Failure", "The server isn't running")
  179.             EndIf
  180.         Case $CCG;Executes the arguments you've written. Has to be a command without the "/".
  181.             If $servers = "RUNNING" Then
  182.                 ControlSend("Server1", "", $hwnd1, $args & '{ENTER}')
  183.                 ControlSend("Server2", "", $hwnd2, $args & '{ENTER}')
  184.                 ControlSend("Server3", "", $hwnd3, $args & '{ENTER}')
  185.                 ControlSend("Server4", "", $hwnd4, $args & '{ENTER}')
  186.                 ControlSend("Server5", "", $hwnd5, $args & '{ENTER}')
  187.             Else
  188.                 MsgBox(16, "Failure", "The server isn't running")
  189.             EndIf
  190.         Case $StopG;Stops the servers.
  191.             If $servers = "RUNNING" Then
  192.                 $servers = "CLOSED"
  193.                 ControlSend("Bungee", "", $hwnd0, 'end' & '{ENTER}')
  194.                 ControlSend("Server1", "", $hwnd1, 'stop' & '{ENTER}')
  195.                 ControlSend("Server2", "", $hwnd2, 'stop' & '{ENTER}')
  196.                 ControlSend("Server3", "", $hwnd3, 'stop' & '{ENTER}')
  197.                 ControlSend("Server4", "", $hwnd4, 'stop' & '{ENTER}')
  198.                 ControlSend("Server5", "", $hwnd5, 'stop' & '{ENTER}')
  199.                 GUICtrlSetData($Label1, "Server(s) are closed")
  200.             EndIf
  201.         Case $backup;Backups all of the server folders with the current date and time.
  202.             Backup()
  203.         Case $addw;Adds a player to the whitekist.
  204.             If $servers = "RUNNING" Then
  205.                 ControlSend("Server1", "", $hwnd1, 'whitelist add ' & '{ENTER}')
  206.                 ControlSend("Server2", "", $hwnd2, 'whitelist add ' & '{ENTER}')
  207.                 ControlSend("Server3", "", $hwnd3, 'whitelist add ' & '{ENTER}')
  208.                 ControlSend("Server4", "", $hwnd4, 'whitelist add ' & '{ENTER}')
  209.                 ControlSend("Server5", "", $hwnd5, 'whitelist add ' & '{ENTER}')
  210.             Else
  211.                 MsgBox(16, "Failure", "The server isn't running")
  212.             EndIf
  213.         Case $delw;Removes a player from the whitelist.
  214.             If $servers = "RUNNING" Then
  215.                 ControlSend("Server1", "", $hwnd1, 'whitelist remove ' & '{ENTER}')
  216.                 ControlSend("Server2", "", $hwnd2, 'whitelist remove ' & '{ENTER}')
  217.                 ControlSend("Server3", "", $hwnd3, 'whitelist remove ' & '{ENTER}')
  218.                 ControlSend("Server4", "", $hwnd4, 'whitelist remove ' & '{ENTER}')
  219.                 ControlSend("Server5", "", $hwnd5, 'whitelist remove ' & '{ENTER}')
  220.             Else
  221.                 MsgBox(16, "Failure", "The server isn't running")
  222.             EndIf
  223.         Case $aboutitem;Information about what this is.
  224.             MsgBox(0, "Server Client", "This is a sort of server controller both for bungee users, users with more than 1 server and users wanting to easily and fast change configuration or platform." & @LF & @LF & "If you are using more than one server, the settings will count for every server except for the bungee server which is set to 512M of ram and newest download from the jenkins page.")
  225.         Case $setupitem;Information about the setup.
  226.             MsgBox(0, "Setup Steps", "1. Choose your settings" & @LF & "2. Exit the program" & @LF & "3. Start the program" & @LF & "4. Choose the locations of your chosen servers(folder must excist)" & @LF & "5. Click the Start server button" & @LF & "Also stop the server and set them up if you are starting new servers")
  227.         Case $How;Information about how the program works.
  228.             MsgBox(0, "How does this work?", "The program uses a lot of variables to do things to every server instead of just one." & @LF & "Everything is saved when you close the GUI." & @LF & "The server versions are downloaded from the official pages. The bukkit ones from the bukkit website, the spigot and bungee from the jenkins page. The vanilla and Snapshot versions come from a link to the amazonaws server generated using the versions file has.")
  229.         Case $help;Explains some "Rules".
  230.             MsgBox(0, "Warnings", "1. Always restart the program after changing settings. The only exception is server ram and servers you have chosen the directory for earlier." & @LF & "2. The program may seem like it has crashed, but it's just waiting for something to finish.")
  231.         Case $DelConf;Delete all the saved configurations and setting it all to default. Afterwards closing the program to prevent any bugs.
  232.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Bungee")
  233.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server1")
  234.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server2")
  235.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server3")
  236.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server4")
  237.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server5")
  238.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Combo")
  239.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Combo2")
  240.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc0")
  241.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc1")
  242.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc2")
  243.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc3")
  244.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc4")
  245.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc5")
  246.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Version")
  247.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "SnapshotVersion")
  248.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Backup")
  249.             RegDelete("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Combo3")
  250.             Exit
  251.     EndSwitch
  252. WEnd
  253. Func Start();Checking what servers are started and then launching with the opttions selected.
  254.     ServerType()
  255.     $GUI2 = GUICreate("Consoles", 1020, 600, 1282, 300, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_CLIPCHILDREN, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS))
  256.     $hwnd00 = WinGetHandle("Consoles")
  257.     If GUICtrlRead($Bungee) = 1 Then
  258.         $BungeeServer = Run("java -Xmx512M -jar " & '"' & $file0 & "\BungeeCord.jar" & '"', $file0, $Hide)
  259.         If Not ProcessWait($BungeeServer) = 0 Then
  260.             WinSetTitle("C:\Windows\system32\java.exe", "", "Bungee")
  261.             WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Bungee")
  262.             Global $hwnd0 = WinGetHandle("Bungee")
  263.         EndIf
  264.     EndIf
  265.     If GUICtrlRead($server1) = 1 Then
  266.         $1 = Run("java " & $chosen & " -jar " & '"' & $file1 & '"' & "\minecraft_server.jar", $file1, $Hide)
  267.         If Not ProcessWait($1) = 0 Then
  268.             WinSetTitle("C:\Windows\system32\java.exe", "", "Server1")
  269.             WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server1")
  270.             Global $hwnd1 = WinGetHandle("Server1")
  271.         EndIf
  272.     EndIf
  273.     If GUICtrlRead($server2) = 1 Then
  274.         $2 = Run("java " & $chosen & " -jar " & '"' & $file2 & '"' & "\minecraft_server.jar", $file2, $Hide)
  275.         If Not ProcessWait($2) = 0 Then
  276.             WinSetTitle("C:\Windows\system32\java.exe", "", "Server2")
  277.             WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server2")
  278.             Global $hwnd2 = WinGetHandle("Server2")
  279.         EndIf
  280.     EndIf
  281.     If GUICtrlRead($server3) = 1 Then
  282.         $3 = Run("java " & $chosen & " -jar " & '"' & $file3 & '"' & "\minecraft_server.jar", $file3, $Hide)
  283.         If Not ProcessWait($3) = 0 Then
  284.             WinSetTitle("C:\Windows\system32\java.exe", "", "Server3")
  285.             WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server3")
  286.             Global $hwnd3 = WinGetHandle("Server3")
  287.         EndIf
  288.     EndIf
  289.     If GUICtrlRead($server4) = 1 Then
  290.         $4 = Run("java " & $chosen & " -jar " & '"' & $file4 & '"' & "\minecraft_server.jar", $file4, $Hide)
  291.         If Not ProcessWait($4) = 0 Then
  292.             WinSetTitle("C:\Windows\system32\java.exe", "", "Server4")
  293.             WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server4")
  294.             Global $hwnd4 = WinGetHandle("Server4")
  295.         EndIf
  296.     EndIf
  297.     If GUICtrlRead($server5) = 1 Then
  298.         $5 = Run("java " & $chosen & " -jar " & '"' & $file5 & '"' & "\minecraft_server.jar", $file5, $Hide)
  299.         If Not ProcessWait($5) = 0 Then
  300.             WinSetTitle("C:\Windows\system32\java.exe", "", "Server5")
  301.             WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server5")
  302.             Global $hwnd5 = WinGetHandle("Server5")
  303.         EndIf
  304.     EndIf
  305.     _WinAPI_SetWindowLong($hwnd0, $GWL_EXSTYLE, $WS_EX_MDICHILD)
  306.     _WinAPI_SetParent($hwnd0, $GUI2)
  307.     _WinAPI_SetWindowLong($hwnd1, $GWL_EXSTYLE, $WS_EX_MDICHILD)
  308.     _WinAPI_SetParent($hwnd1, $GUI2)
  309.     _WinAPI_SetWindowLong($hwnd2, $GWL_EXSTYLE, $WS_EX_MDICHILD)
  310.     _WinAPI_SetParent($hwnd2, $GUI2)
  311.     _WinAPI_SetWindowLong($hwnd3, $GWL_EXSTYLE, $WS_EX_MDICHILD)
  312.     _WinAPI_SetParent($hwnd3, $GUI2)
  313.     _WinAPI_SetWindowLong($hwnd4, $GWL_EXSTYLE, $WS_EX_MDICHILD)
  314.     _WinAPI_SetParent($hwnd4, $GUI2)
  315.     _WinAPI_SetWindowLong($hwnd5, $GWL_EXSTYLE, $WS_EX_MDICHILD)
  316.     _WinAPI_SetParent($hwnd5, $GUI2)
  317.     WinMove($hwnd0, "", 0, 0, 340, 300)
  318.     WinMove($hwnd1, "", 340, 0, 340, 300)
  319.     WinMove($hwnd2, "", 680, 0, 340, 300)
  320.     WinMove($hwnd3, "", 0, 300, 340, 300)
  321.     WinMove($hwnd4, "", 340, 300, 340, 300)
  322.     WinMove($hwnd5, "", 680, 300, 340, 300)
  323.     Global $servers = "Running"
  324.     GUICtrlSetData($Label1, "Server(s) are running");Changing the state of the servers shown in the GUI as running.
  325. EndFunc   ;==>Start
  326. Func ServerType();Checking what servers are enabled and downloading to the selected folder.
  327.     GUISetState(@SW_HIDE, $GUI);Hides the main GUI.
  328.     $Pgui = GUICreate("Downloading jars", 280, 25);Making a new GUI named Downloading jars.
  329.     GUISetState(@SW_SHOW, $Pgui);Setting the state of the new gui as shown.
  330.     $Progress = GUICtrlCreateProgress("", "", 280, 25, BitOR($PBS_SMOOTH, $WS_BORDER), $WS_EX_CLIENTEDGE);Creates a progress bar that shows what jars have been downloaded.
  331.     GUICtrlSetData($Progress, 0);Setting the progress of the progress bar to 0%
  332.     If GUICtrlRead($Bungee) = 1 Then InetGet("http://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/BungeeCord.jar", $file0 & "\BungeeCord.jar");Downloads the newest bungee version.
  333.     GUICtrlSetData($Progress, 16);Setting the progress of the progress bar to 16%
  334.     If GUICtrlRead($server1) = 1 Then Download($file1);Downloads the jarfile selected to the location of server1.
  335.     GUICtrlSetData($Progress, 30);Setting the progress of the progress bar to 30%
  336.     If GUICtrlRead($server2) = 1 Then Download($file2);Downloads the jarfile selected to the location of server2.
  337.     GUICtrlSetData($Progress, 50);Setting the progress of the progress bar to 50%
  338.     If GUICtrlRead($server3) = 1 Then Download($file3);Downloads the jarfile selected to the location of server3.
  339.     GUICtrlSetData($Progress, 66);Setting the progress of the progress bar to 66%
  340.     If GUICtrlRead($server4) = 1 Then Download($file4);Downloads the jarfile selected to the location of server4.
  341.     GUICtrlSetData($Progress, 82);Setting the progress of the progress bar to 82%
  342.     If GUICtrlRead($server5) = 1 Then Download($file5);Downloads the jarfile selected to the location of server5.
  343.     GUICtrlSetData($Progress, 100);Setting the progress of the progress bar to 100%
  344.     GUIDelete($Pgui);Deletes the Downloading jars GUI.
  345.     GUISetState(@SW_SHOW, $GUI);Shows the main GUI.
  346. EndFunc   ;==>ServerType
  347. Func Download($loc);Downloads whatever is chosen to the location defined while calling this function.
  348.     If $chosen2 = "Spigot" Then InetGet("http://ci.md-5.net/job/Spigot-1.7/lastSuccessfulBuild/artifact/Spigot-Server/target/spigot.jar", $loc & "\minecraft_server.jar", 1, 0)
  349.     If $chosen2 = "CB Dev" Then InetGet("http://dl.bukkit.org/latest-dev/craftbukkit-dev.jar", $loc & "\minecraft_server.jar", 1, 0)
  350.     If $chosen2 = "CB Stable" Then InetGet("http://dl.bukkit.org/latest-rb/craftbukkit.jar", $loc & "\minecraft_server.jar", 1, 0)
  351.     If $chosen2 = "CB Beta" Then InetGet("http://dl.bukkit.org/latest-beta/craftbukkit-beta.jar", $loc & "\minecraft_server.jar", 1, 0)
  352.     If $chosen2 = "Vanilla" Then Vanilla($loc)
  353.     If $chosen2 = "Snapshot" Then;This generates a download link to the newest minecraft snapshot.
  354.         $Read = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "SnapshotVersion")
  355.         $Path1 = @TempDir & "\versions.json"
  356.         InetGet("https://s3.amazonaws.com/Minecraft.Download/versions/versions.json", $Path1, 1, 0)
  357.         $FF = FileOpen($Path1)
  358.         $RF = FileReadLine($FF, 3)
  359.         If $Read = $RF And FileExists($loc) Then
  360.         Else
  361.             $ver = StringReplace(StringReplace($RF, '    "snapshot": "', ""), '",', "")
  362.             If InetGet('https://s3.amazonaws.com/Minecraft.Download/versions/' & $ver & "/minecraft_server." & $ver & ".jar", $loc & "\minecraft_server.jar", 1, 0) = 1 Then RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Snapshot", "Version", "REG_SZ", $RF)
  363.         EndIf
  364.         FileDelete($Path1)
  365.     EndIf
  366. EndFunc   ;==>Download
  367. Func Vanilla($loc);The function for downloading the latest Vanilla build unless a certain version is chosen.
  368.     If GUICtrlRead($Combo2) = "Vanilla" And GUICtrlRead($Combo3) = "Latest" Then
  369.         $Read = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Version")
  370.         $Path1 = @TempDir & "\versions.json"
  371.         InetGet("https://s3.amazonaws.com/Minecraft.Download/versions/versions.json", $Path1, 1, 0)
  372.         $FF = FileOpen($Path1)
  373.         $RF = FileReadLine($FF, 4)
  374.         If $Read = $RF And FileExists($loc) Then
  375.         Else
  376.             $ver = StringReplace(StringReplace($RF, '    "release": "', ""), '"', "")
  377.             If InetGet('https://s3.amazonaws.com/Minecraft.Download/versions/' & $ver & "/minecraft_server." & $ver & ".jar", $loc & "\minecraft_server.jar", 1, 0) = 1 Then RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Snapshot", "Version", "REG_SZ", $RF)
  378.         EndIf
  379.         FileDelete($Path1)
  380.         Sleep(1)
  381.     EndIf
  382.     VanillaCustom($loc)
  383. EndFunc   ;==>Vanilla
  384. Func VanillaCustom($loc);The function for downloading a certain vanilla version.
  385.     If GUICtrlRead($Combo2) = "Vanilla" And GUICtrlRead($Combo3) = "1.6.4" Then InetGet('https://s3.amazonaws.com/Minecraft.Download/versions/' & "1.6.4" & "/minecraft_server." & "1.6.4" & ".jar", $loc & "\minecraft_server.jar", 1, 0);If your chosen vanilla version is 1.6.4, it downloads it.
  386.     If GUICtrlRead($Combo2) = "Vanilla" And GUICtrlRead($Combo3) = "1.6.2" Then InetGet('https://s3.amazonaws.com/Minecraft.Download/versions/' & "1.6.2" & "/minecraft_server." & "1.6.2" & ".jar", $loc & "\minecraft_server.jar", 1, 0);If your chosen vanilla version is 1.6.2, it downloads it.
  387.     If GUICtrlRead($Combo2) = "Vanilla" And GUICtrlRead($Combo3) = "1.5.2" Then InetGet('https://s3.amazonaws.com/Minecraft.Download/versions/' & "1.5.2" & "/minecraft_server." & "1.5.2" & ".jar", $loc & "\minecraft_server.jar", 1, 0);If your chosen vanilla version is 1.5.2, it downloads it.
  388.     If GUICtrlRead($Combo2) = "Vanilla" And GUICtrlRead($Combo3) = "1.4.7" Then InetGet('https://s3.amazonaws.com/Minecraft.Download/versions/' & "1.4.7" & "/minecraft_server." & "1.4.7" & ".jar", $loc & "\minecraft_server.jar", 1, 0);If your chosen vanilla version is 1.4.7, it downloads it.
  389.     If GUICtrlRead($Combo2) = "Vanilla" And GUICtrlRead($Combo3) = "1.4.5" Then InetGet('https://s3.amazonaws.com/Minecraft.Download/versions/' & "1.4.5" & "/minecraft_server." & "1.4.5" & ".jar", $loc & "\minecraft_server.jar", 1, 0);If your chosen vanilla version is 1.4.5, it downloads it.
  390. EndFunc   ;==>VanillaCustom
  391. Func WriteStats();The function for saving settings.
  392.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Bungee", "Reg_SZ", GUICtrlRead($Bungee));Saves the value of the Bungee Control.
  393.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server1", "REG_SZ", GUICtrlRead($server1));Saves the value of the server1 Control.
  394.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server2", "REG_SZ", GUICtrlRead($server2));Saves the value of the server2 Control.
  395.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server3", "REG_SZ", GUICtrlRead($server3));Saves the value of the server3 Control.
  396.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server4", "REG_SZ", GUICtrlRead($server4));Saves the value of the server4 Control.
  397.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server5", "REG_SZ", GUICtrlRead($server5));Saves the value of the server5 Control.
  398.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Combo", "REG_SZ", $chosen);Saves the value of the chosen Control.
  399.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Combo2", "REG_SZ", $chosen2);Saves the value of the chosen2 Control.
  400.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Combo3", "REG_SZ", $chosen3);Saves the value of the chosen3 Control.
  401.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Backup", "REG_SZ", $backupdir);Saves the value of the backupdir Control.
  402.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc0", "REG_SZ", $file0);Saves the value of the file0 Control.
  403.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc1", "REG_SZ", $file1);Saves the value of the file1 Control.
  404.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc2", "REG_SZ", $file2);Saves the value of the file2 Control.
  405.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc3", "REG_SZ", $file3);Saves the value of the file3 Control.
  406.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc4", "REG_SZ", $file4);Saves the value of the file4 Control.
  407.     RegWrite("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc5", "REG_SZ", $file5);Saves the value of the file5 Control.
  408. EndFunc   ;==>WriteStats
  409. Func ReadStats();The function for reading saved settings.
  410.     $Read0 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Bungee");Sets the value of Read0 to the saved value of Bungee
  411.     $Read2 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Combo");Sets the value of Read2 to the saved value of chosen
  412.     $Read3 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Combo2");Sets the value of Read3 to the saved value of chosen2
  413.     $Read4 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server1");Sets the value of Read4 to the saved value of server1
  414.     $Read5 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server2");Sets the value of Read5 to the saved value of server2
  415.     $Read6 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server3");Sets the value of Read6 to the saved value of server3
  416.     $Read7 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server4");Sets the value of Read7 to the saved value of server4
  417.     $Read8 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Server5");Sets the value of Read8 to the saved value of server5
  418.     $Read9 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Combo3");Sets the value of Read9 to the saved value of chosen3
  419.     $backupdir = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Backup");Sets the value of backupdir to the saved value of backupdir
  420.     $file0 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc0");Sets the value of file0 to the saved value of file0
  421.     $file1 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc1");Sets the value of file1 to the saved value of file1
  422.     $file2 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc2");Sets the value of file2 to the saved value of file2
  423.     $file3 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc3");Sets the value of file3 to the saved value of file3
  424.     $file4 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc4");Sets the value of file4 to the saved value of file4
  425.     $file5 = RegRead("HKEY_CURRENT_USER\Software\KnarCraft\Bungee Controller", "Loc5");Sets the value of file5 to the saved value of file5
  426.     If Not $Read2 = "" Then GUICtrlSetData($Combo1, $Read2);Sets the value of Combo1 to the value of Read2 unless it's empty.
  427.     If Not $Read3 = "" Then GUICtrlSetData($Combo2, $Read3);Sets the value of Combo2 to the value of Read3 unless it's empty.
  428.     If Not $Read9 = "" Then GUICtrlSetData($Combo3, $Read9);Sets the value of Combo3 to the value of Read9 unless it's empty.
  429.     If $Read4 = 1 Then GUICtrlSetState($server1, $GUI_CHECKED);If the value of Read4 is 1, sets the state of the server1 checkbox to checked.
  430.     If $Read5 = 1 Then GUICtrlSetState($server2, $GUI_CHECKED);If the value of Read5 is 1, sets the state of the server2 checkbox to checked.
  431.     If $Read6 = 1 Then GUICtrlSetState($server3, $GUI_CHECKED);If the value of Read6 is 1, sets the state of the server3 checkbox to checked.
  432.     If $Read7 = 1 Then GUICtrlSetState($server4, $GUI_CHECKED);If the value of Read7 is 1, sets the state of the server4 checkbox to checked.
  433.     If $Read8 = 1 Then GUICtrlSetState($server5, $GUI_CHECKED);If the value of Read8 is 1, sets the state of the server5 checkbox to checked.
  434.     If $Read0 = 1 Then GUICtrlSetState($Bungee, $GUI_CHECKED)
  435. EndFunc   ;==>ReadStats
  436. Func Backup();The function for making a backup of the enabled servers.
  437.     GUISetState(@SW_HIDE, $GUI);Hides the main GUI.
  438.     $Pgui = GUICreate("Backup Progress", 280, 25);Making a new GUI named Backup Progress.
  439.     GUISetState(@SW_SHOW, $Pgui);Setting the state of the new gui as shown.
  440.     $Progress = GUICtrlCreateProgress("", "", 280, 25, BitOR($PBS_SMOOTH, $WS_BORDER), $WS_EX_CLIENTEDGE);Creates a progress bar that shows what servers have been backuped.
  441.     GUICtrlSetData($Progress, 0);Setting the progress of the progress bar to 0%
  442.     If GUICtrlRead($server1) = 1 Then DirCopy($file1, $backupdir & "\Server1\" & " " & @HOUR & ";" & @MIN & " " & @MDAY & "-" & @MON & "-" & @YEAR);Copying the directory of the Server1 folder to the backup folder.
  443.     GUICtrlSetData($Progress, 20);Setting the progress of the progress bar to 20%
  444.     If GUICtrlRead($server2) = 1 Then DirCopy($file2, $backupdir & "\Server2\" & " " & @HOUR & ";" & @MIN & " " & @MDAY & "-" & @MON & "-" & @YEAR);Copying the directory of the Server2 folder to the backup folder.
  445.     GUICtrlSetData($Progress, 40);Setting the progress of the progress bar to 40%
  446.     If GUICtrlRead($server3) = 1 Then DirCopy($file3, $backupdir & "\Server3\" & " " & @HOUR & ";" & @MIN & " " & @MDAY & "-" & @MON & "-" & @YEAR);Copying the directory of the Server3 folder to the backup folder.
  447.     GUICtrlSetData($Progress, 60);Setting the progress of the progress bar to 60%
  448.     If GUICtrlRead($server4) = 1 Then DirCopy($file4, $backupdir & "\Server4\" & " " & @HOUR & ";" & @MIN & " " & @MDAY & "-" & @MON & "-" & @YEAR);Copying the directory of the Server4 folder to the backup folder.
  449.     GUICtrlSetData($Progress, 80);Setting the progress of the progress bar to 80%
  450.     If GUICtrlRead($server5) = 1 Then DirCopy($file5, $backupdir & "\Server5\" & " " & @HOUR & ";" & @MIN & " " & @MDAY & "-" & @MON & "-" & @YEAR);Copying the directory of the Server5 folder to the backup folder.
  451.     GUICtrlSetData($Progress, 100);Setting the progress of the progress bar to 100%
  452.     GUIDelete($Pgui);Deletes the Backup Progress GUI.
  453.     GUISetState(@SW_SHOW, $GUI);Shows the main GUI.
  454. EndFunc   ;==>Backup
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement