This repository was archived by the owner on Nov 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
220 lines (194 loc) · 9.39 KB
/
start.sh
File metadata and controls
220 lines (194 loc) · 9.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/bash
# Colors for better output
BOLD='\033[1m'
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Function to display ASCII art header
show_header() {
echo -e "${BOLD}${CYAN}"
cat << "EOF"
╔═══════════════════════════════════════════════════════════════╗
║ ║
║ ██████╗██████╗ ███████╗███████╗██████╗ ███████╗██████╗ ║
║ ██╔════╝██╔══██╗██╔════╝██╔════╝██╔══██╗██╔════╝██╔══██╗ ║
║ ██║ ██████╔╝█████╗ █████╗ ██████╔╝█████╗ ██████╔╝ ║
║ ██║ ██╔══██╗██╔══╝ ██╔══╝ ██╔═══╝ ██╔══╝ ██╔══██╗ ║
║ ╚██████╗██║ ██║███████╗███████╗██║ ███████╗██║ ██║ ║
║ ╚═════╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚══════╝╚═╝ ╚═╝ ║
║ ║
║ ██████╗ █████╗ ███████╗████████╗██╗ ███████╗ ║
║ ██╔════╝██╔══██╗██╔════╝╚══██╔══╝██║ ██╔════╝ ║
║ ██║ ███████║███████╗ ██║ ██║ █████╗ ║
║ ██║ ██╔══██║╚════██║ ██║ ██║ ██╔══╝ ║
║ ╚██████╗██║ ██║███████║ ██║ ███████╗███████╗ ║
║ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚══════╝╚══════╝ ║
║ ║
║ FREE HOST ║
║ ║
╚═══════════════════════════════════════════════════════════════╝
EOF
echo -e "${NC}"
}
# Check if server.jar already exists
check_existing_server() {
if [ -f "server.jar" ]; then
echo -e "${BOLD}${YELLOW}⚠️ server.jar already exists!${NC}"
echo ""
# Auto mode - no prompt in Pterodactyl
if [ -t 0 ]; then
# Interactive terminal
echo -e "${BOLD}What would you like to do?${NC}"
echo -e " ${GREEN}1)${NC} Keep existing server.jar and check for Hibernate plugin"
echo -e " ${RED}2)${NC} Delete and download a new version"
echo ""
read -t 10 -p "Enter your choice (1 or 2): " choice 2>/dev/null || choice="1"
echo ""
else
# Non-interactive (Pterodactyl)
echo -e "${CYAN}🔄 Non-interactive mode - Auto-keeping existing server.jar${NC}"
choice="1"
fi
case "$choice" in
2 )
echo -e "${CYAN}🗑️ Removing existing server.jar...${NC}"
rm -f server.jar
return 0
;;
* )
echo -e "${GREEN}✅ Keeping existing server.jar${NC}"
return 1
;;
esac
fi
return 0
}
# Function to get latest build for a version
get_latest_build() {
local version=$1
local builds_url="https://api.papermc.io/v2/projects/paper/versions/${version}"
local builds=$(curl -s "$builds_url" | grep -o '"builds":\[[0-9,]*\]' | grep -o '[0-9]*' | tail -1)
echo "$builds"
}
# Function to download PaperMC
download_paper() {
local version=$1
echo ""
echo -e "${CYAN}Fetching latest build for version ${version}...${NC}"
local build=$(get_latest_build "$version")
if [ -z "$build" ]; then
echo -e "${RED}❌ Error: Could not find build information for version ${version}${NC}"
return 1
fi
local download_url="https://api.papermc.io/v2/projects/paper/versions/${version}/builds/${build}/downloads/paper-${version}-${build}.jar"
echo -e "${CYAN}Downloading PaperMC ${version} (build ${build})...${NC}"
if curl -fsSL -o server.jar "$download_url"; then
return 0
else
return 1
fi
}
# Display version menu
show_version_menu() {
echo -e "${BOLD}${CYAN}Which PaperMC version would you like to download?${NC}"
echo ""
echo -e "${BOLD}Select a version to download:${NC}"
echo ""
# Array of versions
versions=(
"1.8.8" "1.9.4" "1.10.2" "1.11.2" "1.12.2" "1.13.2" "1.14.4" "1.15.2"
"1.16.5" "1.17.1" "1.18.2" "1.19.4" "1.20" "1.20.1" "1.20.2" "1.20.3"
"1.20.4" "1.20.5" "1.20.6" "1.21" "1.21.1" "1.21.2" "1.21.3" "1.21.4"
"1.21.5" "1.21.6" "1.21.7" "1.21.8" "1.21.9" "1.21.10"
)
# Display in 2 columns
for i in "${!versions[@]}"; do
printf "%2d) %-10s" "$((i+1))" "${versions[$i]}"
if [ $(((i+1) % 2)) -eq 0 ]; then
echo ""
fi
done
echo ""
echo ""
# Get user choice
while true; do
read -p "Enter your choice (1-30): " choice
if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le 30 ]; then
selected_version="${versions[$((choice-1))]}"
echo ""
echo -e "${GREEN}Selected version: ${selected_version}${NC}"
break
else
echo -e "${RED}Invalid choice. Please enter a number between 1 and 30.${NC}"
fi
done
}
# Main script execution
show_header
# Check for existing server.jar
if ! check_existing_server; then
# User chose to keep existing file, skip download
SKIP_DOWNLOAD=true
else
SKIP_DOWNLOAD=false
fi
if [ "$SKIP_DOWNLOAD" = false ]; then
show_version_menu
# Download selected version
if download_paper "$selected_version"; then
# Verify download
if [ -f "server.jar" ]; then
echo -e "${GREEN}✅ Download successful!${NC}"
else
echo -e "${RED}❌ Error: Failed to download PaperMC. Please check your connection or try another version.${NC}"
exit 1
fi
else
echo -e "${RED}❌ Error: Failed to download PaperMC. Please check your connection or try another version.${NC}"
exit 1
fi
# Create plugins directory and download Hibernate
echo ""
echo -e "${CYAN}Setting up plugins directory...${NC}"
mkdir -p plugins
echo -e "${CYAN}Downloading Hibernate plugin...${NC}"
if curl -fsSL -o plugins/Hibernate-2.1.0.jar https://github.com/WeThink25/cc/raw/main/Hibernate-2.1.0.jar; then
echo -e "${GREEN}✅ Hibernate plugin downloaded successfully!${NC}"
else
echo -e "${YELLOW}⚠️ Warning: Failed to download Hibernate plugin. You may need to download it manually.${NC}"
fi
else
# Server.jar already exists, just check for Hibernate plugin
echo ""
echo -e "${CYAN}Checking for Hibernate plugin...${NC}"
mkdir -p plugins
if [ -f "plugins/Hibernate-2.1.0.jar" ]; then
echo -e "${GREEN}✅ Hibernate plugin already exists!${NC}"
else
echo -e "${CYAN}Downloading Hibernate plugin...${NC}"
if curl -fsSL -o plugins/Hibernate-2.1.0.jar https://github.com/WeThink25/cc/raw/main/Hibernate-2.1.0.jar; then
echo -e "${GREEN}✅ Hibernate plugin downloaded successfully!${NC}"
else
echo -e "${YELLOW}⚠️ Warning: Failed to download Hibernate plugin. You may need to download it manually.${NC}"
fi
fi
fi
# Completion message
echo ""
echo -e "${BOLD}${GREEN}╔═══════════════════════════════════════════════════════════╗${NC}"
echo -e "${BOLD}${GREEN}║ ║${NC}"
echo -e "${BOLD}${GREEN}║ ✅ Setup complete! ║${NC}"
echo -e "${BOLD}${GREEN}║ ║${NC}"
echo -e "${BOLD}${GREEN}║ Your CreeperCastle server is ready. ║${NC}"
echo -e "${BOLD}${GREEN}║ ║${NC}"
echo -e "${BOLD}${GREEN}╚═══════════════════════════════════════════════════════════╝${NC}"
echo ""
echo -e "${CYAN}Starting server in 3 seconds...${NC}"
sleep 3
echo ""
echo -e "${BOLD}${GREEN}🚀 Launching CreeperCastle Server...${NC}"
echo ""
# Start the server
java -Xms1G -Xmx2G -jar server.jar nogui