Paper/src/main/java/org/bukkit/craftbukkit/Main.java

94 Zeilen
3.4 KiB
Java

2010-12-21 17:52:15 +01:00
package org.bukkit.craftbukkit;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
2010-12-21 17:52:15 +01:00
import net.minecraft.server.MinecraftServer;
public class Main {
public static void main(String[] args) {
// Todo: Installation script
OptionParser parser = new OptionParser() {
{
acceptsAll(asList("?", "help"), "Show the help");
acceptsAll(asList("c", "config"), "Properties file to use")
.withRequiredArg()
.ofType(File.class)
.defaultsTo(new File("server.properties"))
.describedAs("Properties file");
acceptsAll(asList("P", "plugins"), "Plugin directory to use")
.withRequiredArg()
.ofType(File.class)
.defaultsTo(new File("plugins"))
.describedAs("Plugin directory");
acceptsAll(asList("h", "host", "server-ip"), "Host to listen on")
.withRequiredArg()
.ofType(String.class)
.describedAs("Hostname or IP");
2011-01-04 02:19:26 +01:00
acceptsAll(asList("w", "world", "level-name"), "World directory")
.withRequiredArg()
.ofType(String.class)
.describedAs("World dir");
acceptsAll(asList("p", "port", "server-port"), "Port to listen on")
.withRequiredArg()
.ofType(Integer.class)
.describedAs("Port");
acceptsAll(asList("o", "online-mode"), "Whether to use online authentication")
.withRequiredArg()
.ofType(Boolean.class)
.describedAs("Authentication");
acceptsAll(asList("s", "size", "max-players"), "Maximum amount of players")
.withRequiredArg()
.ofType(Integer.class)
.describedAs("Server size");
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");
}
};
OptionSet options = null;
2010-12-21 17:52:15 +01:00
try {
options = parser.parse(args);
} catch (joptsimple.OptionException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage());
}
if ((options == null) || (options.has("?"))) {
try {
parser.printHelpOn(System.out);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
try {
MinecraftServer.main(options);
} catch (Throwable t) {
t.printStackTrace();
}
2010-12-21 17:52:15 +01:00
}
}
private static List<String> asList(String... params) {
return Arrays.asList(params);
}
2010-12-21 17:52:15 +01:00
}