Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package org.bukkit.craftbukkit;
2
3import joptsimple.OptionParser;
4import joptsimple.OptionSet;
5import net.minecraft.server.MinecraftServer;
6
7import java.io.File;
8import java.io.IOException;
9import java.text.SimpleDateFormat;
10import java.util.Arrays;
11import java.util.List;
12import java.util.logging.Level;
13import java.util.logging.Logger;
14
15public class Main {
16 public static boolean useJline = true;
17
18 public static void main(String[] args) {
19 // Todo: Installation script
20 OptionParser parser = new OptionParser() {
21 {
22 acceptsAll(asList("?", "help"), "Show the help");
23
24 acceptsAll(asList("c", "config"), "Properties file to use").withRequiredArg().ofType(File.class).defaultsTo(new File("server.properties")).describedAs("Properties file");
25
26 acceptsAll(asList("P", "plugins"), "Plugin directory to use").withRequiredArg().ofType(File.class).defaultsTo(new File("plugins")).describedAs("Plugin directory");
27
28 acceptsAll(asList("h", "host", "server-ip"), "Host to listen on").withRequiredArg().ofType(String.class).describedAs("Hostname or IP");
29
30 acceptsAll(asList("w", "world", "level-name"), "World directory").withRequiredArg().ofType(String.class).describedAs("World dir");
31
32 acceptsAll(asList("p", "port", "server-port"), "Port to listen on").withRequiredArg().ofType(Integer.class).describedAs("Port");
33
34 acceptsAll(asList("o", "online-mode"), "Whether to use online authentication").withRequiredArg().ofType(Boolean.class).describedAs("Authentication");
35
36 acceptsAll(asList("s", "size", "max-players"), "Maximum amount of players").withRequiredArg().ofType(Integer.class).describedAs("Server size");
37
38 acceptsAll(asList("d", "date-format"), "Format of the date to display in the console (for log entries)").withRequiredArg().ofType(SimpleDateFormat.class).describedAs("Log date format");
39
40 acceptsAll(asList("log-pattern"), "Specfies the log filename pattern").withRequiredArg().ofType(String.class).defaultsTo("server.log").describedAs("Log filename");
41
42 acceptsAll(asList("log-limit"), "Limits the maximum size of the log file (0 = unlimited)").withRequiredArg().ofType(Integer.class).defaultsTo(0).describedAs("Max log size");
43
44 acceptsAll(asList("log-count"), "Specified how many log files to cycle through").withRequiredArg().ofType(Integer.class).defaultsTo(1).describedAs("Log count");
45
46 acceptsAll(asList("log-append"), "Whether to append to the log file").withRequiredArg().ofType(Boolean.class).defaultsTo(true).describedAs("Log append");
47
48 acceptsAll(asList("b", "bukkit-settings"), "File for bukkit settings").withRequiredArg().ofType(File.class).defaultsTo(new File("bukkit.yml")).describedAs("Yml file");
49
50 acceptsAll(asList("debug-config"), "Don't load Poseidon.yml, but generate a new one with all the default values");
51
52 acceptsAll(asList("nojline"), "Disables jline and emulates the vanilla console");
53
54 acceptsAll(asList("nogui"), "Some modern panels like to pass this thru. Just ignore it");
55
56 acceptsAll(asList("v", "version"), "Show the CraftBukkit Version");
57 }
58 };
59
60 OptionSet options = null;
61
62 try {
63 options = parser.parse(args);
64 } catch (joptsimple.OptionException ex) {
65 Logger.getLogger(Main.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage());
66 }
67
68 if ((options == null) || (options.has("?"))) {
69 try {
70 parser.printHelpOn(System.out);
71 } catch (IOException ex) {
72 Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
73 }
74 } else if (options.has("v")) {
75 System.out.println(CraftServer.class.getPackage().getImplementationVersion());
76 } else {
77 try {
78 useJline = !"jline.UnsupportedTerminal".equals(System.getProperty("jline.terminal"));
79
80 if (options.has("nojline")) {
81 System.setProperty("jline.terminal", "jline.UnsupportedTerminal");
82 System.setProperty("user.language", "en");
83 useJline = false;
84 }
85
86 MinecraftServer.main(options);
87 } catch (Throwable t) {
88 t.printStackTrace();
89 }
90 }
91 }
92
93 private static List<String> asList(String... params) {
94 return Arrays.asList(params);
95 }
96}