-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserwerminecraftnowy.jar
39 lines (32 loc) · 1.33 KB
/
serwerminecraftnowy.jar
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
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class MinecraftServerJarCreator {
public static void main(String[] args) {
String serverName = "serwerminecraftnowy";
String serverDescription = "Nowy serwer";
String serverIP = "mc.bartoszdrusewicz.pl";
createServerJar(serverName, serverDescription, serverIP);
}
private static void createServerJar(String name, String description, String ip) {
String jarFileName = name + ".jar";
try {
FileOutputStream fos = new FileOutputStream(jarFileName);
ZipOutputStream zos = new ZipOutputStream(fos);
addToJar(zos, "server.properties", "server-name=" + name + "\nserver-description=" + description + "\nserver-ip=" + ip + "\n");
zos.close();
fos.close();
System.out.println("Server JAR created successfully: " + jarFileName);
} catch (IOException e) {
e.printStackTrace();
}
}
private static void addToJar(ZipOutputStream zos, String fileName, String content) throws IOException {
ZipEntry entry = new ZipEntry(fileName);
zos.putNextEntry(entry);
zos.write(content.getBytes());
zos.closeEntry();
}
}