Skip to content

Commit 12f336c

Browse files
committed
Refactor minecraft_server_gui.py and update README.md
- Refactored the server management logic to utilize a dedicated ServerHandler class for improved process management and command handling. - Enhanced the GUI with new features including a whitelist management panel and improved player management functionalities. - Updated the README to reflect changes in features, installation instructions, and project structure. - Removed unnecessary dependencies from requirements.txt, streamlining the installation process.
1 parent cb13f6a commit 12f336c

17 files changed

+825
-404
lines changed

README.md

Lines changed: 82 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,82 @@
1-
# Minecraft Local Server GUI
2-
3-
A user-friendly desktop application for installing, managing, and running local Minecraft servers on your PC. Built with Python and Tkinter.
4-
5-
## Features
6-
7-
- **Easy Setup Wizard**:
8-
- Install a new server with just a few clicks. Supports **Vanilla, Paper, Spigot, Forge, and Fabric**.
9-
- Or, use a pre-existing server folder.
10-
- **Complete Server Control**:
11-
- One-click **Start, Stop, and Restart** buttons.
12-
- **Live server console** integrated into the GUI to see logs in real-time.
13-
- Send commands directly to the server through the interface.
14-
- **User-Friendly Management Panels**:
15-
- **Properties Editor**: A graphical editor for `server.properties` with categorized, collapsible sections and helpful descriptions for each option.
16-
- **Player Management**: View connected players, op/deop, kick, or ban them with a right-click. Player avatars are displayed next to their names.
17-
- **Operators**: Manage the server's operator list, with support for offline adding/removing.
18-
- **Worlds**: View and create backups of your world folders.
19-
- **Resource Monitoring**: Live graphs showing the server's CPU and RAM usage.
20-
- **Forge & Mod Support**:
21-
- **Mod Management**: View installed mods, enable/disable them, view their config files, and delete them.
22-
- **Smart Startup**: Automatically uses the correct startup script (`run.bat`) for Forge servers.
23-
- **Automatic EULA Handling**: Automatically detects and accepts the EULA when a new server is started for the first time.
24-
- **Customization & Settings**:
25-
- **Custom RAM Allocation**: Easily set the minimum and maximum RAM for your server.
26-
- Remembers your server path and settings between sessions.
27-
28-
## Prerequisites
29-
30-
- **Java**: You must have Java installed on your system and available in your system's PATH for the application to be able to run the Minecraft server.
31-
32-
## How to Use
33-
34-
1. **Clone or Download**: Get the source code from this repository.
35-
```sh
36-
git clone <repository_url>
37-
```
38-
2. **Install Dependencies**: Navigate to the project folder and install the required Python packages.
39-
```sh
40-
pip install -r requirements.txt
41-
```
42-
3. **Run the Application**:
43-
```sh
44-
python minecraft_server_gui.py
45-
```
46-
4. **First-Time Setup**:
47-
- The first time you run the app, a setup wizard will appear.
48-
- Choose to **install a new server** (the app will download all necessary files) or **use an existing server folder**.
49-
- Once configured, the main GUI will launch, and your settings will be saved for the next session.
50-
51-
## License
52-
53-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
1+
# Minecraft Local Server GUI
2+
3+
A user-friendly desktop application for installing, managing, and running local Minecraft servers. Built with Python and Tkinter, this tool provides a complete graphical interface for server administration, from initial setup to daily management.
4+
5+
## Features
6+
7+
- **Easy Setup Wizard**:
8+
- **Install New Servers**: Download and install a new server with just a few clicks. Supports **Vanilla, Paper, Spigot, Forge, and Fabric**.
9+
- **Use Existing Servers**: Easily import and manage a pre-existing server folder.
10+
- **Complete Server Control**:
11+
- **One-Click Actions**: Start, Stop, and Restart the server directly from the GUI.
12+
- **Live Console**: View the live server console, with color-coded messages for errors and warnings.
13+
- **Command Input**: Send commands directly to the server through the interface.
14+
- **Management Panels**:
15+
- **Properties Editor**: A graphical editor for `server.properties` with categorized, collapsible sections and helpful descriptions.
16+
- **Player Management**: View connected players with their avatars, op/de-op, kick, or ban them with a right-click.
17+
- **Operators & Bans**: Manage server operators and banned players/IPs, with support for offline modifications.
18+
- **World Management**: View all world folders and create backups with a single click.
19+
- **Mod Management**: For Forge/Fabric, view installed mods, enable/disable them, view/edit their config files, and delete them.
20+
- **Resource Monitoring**:
21+
- Live graphs showing the server's CPU and RAM usage over time.
22+
- **Smart & Automated**:
23+
- **Automatic EULA Handling**: Automatically detects and accepts the EULA on the first run of a new server.
24+
- **Smart Startup**: Automatically uses the correct startup script (`run.bat`/`run.sh`) for Forge servers.
25+
- **Customization & Settings**:
26+
- **Custom RAM Allocation**: Easily set the minimum and maximum RAM for your server.
27+
- **Configuration Saving**: Remembers your server path and settings between sessions.
28+
29+
## Requirements
30+
31+
- **Python 3.x**
32+
- **Java**: You must have Java installed on your system for the application to run the Minecraft server JAR file.
33+
- The required Python packages are listed in `requirements.txt`:
34+
```
35+
requests
36+
psutil
37+
Pillow
38+
matplotlib
39+
```
40+
41+
## Installation & Usage
42+
43+
1. **Clone the Repository**:
44+
```sh
45+
git clone https://github.com/your-username/Minecraft-Local-Server-GUI.git
46+
cd Minecraft-Local-Server-GUI
47+
```
48+
2. **Install Dependencies**:
49+
```sh
50+
pip install -r requirements.txt
51+
```
52+
3. **Run the Application**:
53+
```sh
54+
python main.py
55+
```
56+
4. **First-Time Setup**:
57+
- The first time you run the app, a setup wizard will appear.
58+
- Choose to **install a new server** (the app will download all necessary files) or **use an existing server folder**.
59+
- Once configured, the main GUI will launch, and your settings will be saved for the next session.
60+
61+
## Project Structure
62+
63+
```
64+
Minecraft-Local-Server-GUI/
65+
├── gui/
66+
│ ├── widgets.py # Custom Tkinter widgets (CollapsiblePane, etc.)
67+
├── server/
68+
│ ├── config_manager.py # Handles saving/loading of GUI and server settings.
69+
│ └── server_handler.py # Manages the Minecraft server process.
70+
├── utils/
71+
│ ├── api_client.py # Handles API calls to fetch server versions, player data, etc.
72+
│ ├── constants.py # Stores UI constants like colors and fonts.
73+
│ └── helpers.py # Utility functions.
74+
├── main.py # Main entry point of the application.
75+
├── minecraft_server_gui.py # The core class for the main GUI window and all its logic.
76+
├── requirements.txt # Python package dependencies.
77+
└── README.md # This file.
78+
```
79+
80+
## License
81+
82+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
171 KB
Binary file not shown.
10.9 KB
Binary file not shown.

gui/widgets.py

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import tkinter as tk
2+
from tkinter import ttk
3+
from utils.constants import FONT_UI_HEADER, FONT_UI_NORMAL, SECONDARY_BG, TERTIARY_BG, TEXT_PRIMARY
4+
5+
class CollapsiblePane(ttk.Frame):
6+
"""A collapsible pane widget that can hide or show its content."""
7+
def __init__(self, parent, text="", body_background=SECONDARY_BG):
8+
super().__init__(parent, style='CardInner.TFrame')
9+
10+
self.columnconfigure(0, weight=1)
11+
self.body_background = body_background
12+
13+
# Header
14+
self.header_frame = ttk.Frame(self, style='CardInner.TFrame')
15+
self.header_frame.grid(row=0, column=0, sticky='ew')
16+
self.header_frame.columnconfigure(1, weight=1)
17+
18+
self.toggle_button = ttk.Label(self.header_frame, text="▼", font=('Segoe UI', 10), style='TLabel')
19+
self.toggle_button.grid(row=0, column=0, padx=5, sticky='w')
20+
21+
self.title_label = ttk.Label(self.header_frame, text=text, font=FONT_UI_HEADER, style='Header.TLabel')
22+
self.title_label.grid(row=0, column=1, sticky='w')
23+
24+
# Body
25+
self.body = ttk.Frame(self, style='CardInner.TFrame', padding=(15, 10))
26+
27+
self.toggle_button.bind("<Button-1>", self._toggle)
28+
self.title_label.bind("<Button-1>", self._toggle)
29+
self._is_collapsed = False
30+
self.body.grid(row=1, column=0, sticky='nsew', padx=5, pady=5) # Start expanded
31+
32+
def _toggle(self, event):
33+
if self._is_collapsed:
34+
self.body.grid(row=1, column=0, sticky='nsew', padx=5, pady=5)
35+
self.toggle_button.configure(text="▼")
36+
else:
37+
self.body.grid_remove()
38+
self.toggle_button.configure(text="▶")
39+
self._is_collapsed = not self._is_collapsed
40+
41+
class ToolTip:
42+
def __init__(self, widget, text):
43+
self.widget, self.text, self.tooltip_window = widget, text, None
44+
self.widget.bind("<Enter>", self.show)
45+
self.widget.bind("<Leave>", self.hide)
46+
def show(self, event=None):
47+
if self.tooltip_window or not self.text: return
48+
x, y, _, _ = self.widget.bbox("insert")
49+
x += self.widget.winfo_rootx() + 25
50+
y += self.widget.winfo_rooty() + 25
51+
self.tooltip_window = tw = tk.Toplevel(self.widget)
52+
tw.wm_overrideredirect(True)
53+
tw.wm_geometry(f"+{x}+{y}")
54+
ttk.Label(tw, text=self.text, background=TERTIARY_BG, foreground=TEXT_PRIMARY, font=FONT_UI_NORMAL, relief='solid', borderwidth=1, padding=5).pack()
55+
def hide(self, event=None):
56+
if self.tooltip_window: self.tooltip_window.destroy()
57+
self.tooltip_window = None
58+
59+
class CustomDropdownMenu(ttk.Frame):
60+
def __init__(self, parent, textvariable, options, style_prefix, **kwargs):
61+
super().__init__(parent, **kwargs)
62+
self.textvariable = textvariable
63+
self.options = options
64+
self.style_prefix = style_prefix
65+
self.is_open = False
66+
67+
self.button = ttk.Button(self, textvariable=self.textvariable, command=self.toggle, style=f"{self.style_prefix}.TButton")
68+
self.button.pack(fill=tk.BOTH, expand=True)
69+
70+
self.window = tk.Toplevel(self.master)
71+
self.window.withdraw()
72+
self.window.wm_overrideredirect(True)
73+
74+
self.frame = ttk.Frame(self.window, style=f"{self.style_prefix}.TFrame")
75+
self.frame.pack()
76+
77+
self.canvas = tk.Canvas(self.frame, background=SECONDARY_BG, highlightthickness=0)
78+
self.scrollbar = ttk.Scrollbar(self.frame, orient="vertical", command=self.canvas.yview, style="Vertical.TScrollbar")
79+
self.scrollable_frame = ttk.Frame(self.canvas, style=f"{self.style_prefix}.TFrame")
80+
81+
self.scrollable_frame.bind("<Configure>", lambda e: self.canvas.configure(scrollregion=self.canvas.bbox("all")))
82+
self.canvas.create_window((0, 0), window=self.scrollable_frame, anchor="nw")
83+
self.canvas.configure(yscrollcommand=self.scrollbar.set)
84+
85+
self.canvas.pack(side="left", fill="both", expand=True)
86+
self.scrollbar.pack(side="right", fill="y")
87+
88+
self.master.bind("<Configure>", self.hide)
89+
self.button.bind("<Destroy>", self.hide)
90+
91+
def toggle(self, event=None):
92+
if self.is_open:
93+
self.hide()
94+
else:
95+
self.show()
96+
97+
def show(self):
98+
self.is_open = True
99+
self.update_options(self.options)
100+
x = self.button.winfo_rootx()
101+
y = self.button.winfo_rooty() + self.button.winfo_height()
102+
self.window.wm_geometry(f"+{x}+{y}")
103+
self.window.deiconify()
104+
self.window.lift()
105+
self.window.bind("<FocusOut>", self.hide)
106+
self.window.focus_set()
107+
108+
def hide(self, event=None):
109+
self.is_open = False
110+
self.window.withdraw()
111+
112+
def update_options(self, options):
113+
for widget in self.scrollable_frame.winfo_children():
114+
widget.destroy()
115+
116+
self.options = options
117+
for option in self.options:
118+
btn = ttk.Button(self.scrollable_frame, text=option,
119+
command=lambda o=option: self.select(o),
120+
style=f"{self.style_prefix}.Item.TButton")
121+
btn.pack(fill=tk.X, expand=True)
122+
123+
def select(self, option):
124+
self.textvariable.set(option)
125+
self.hide()

main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import tkinter as tk
2+
from minecraft_server_gui import ServerControlGUI
3+
4+
if __name__ == '__main__':
5+
root = tk.Tk()
6+
ws, hs = root.winfo_screenwidth(), root.winfo_screenheight()
7+
w, h = 1000, 750
8+
x, y = (ws/2) - (w/2), (hs/2) - (h/2)
9+
root.geometry(f'{w}x{h}+{int(x)}+{int(y)}')
10+
root.minsize(900, 650)
11+
app = ServerControlGUI(root)
12+
root.mainloop()

0 commit comments

Comments
 (0)