summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authordurron597 <martin.jared@gmail.com>2011-01-03 20:21:02 -0500
committerdurron597 <martin.jared@gmail.com>2011-01-03 20:21:02 -0500
commit4c483edf08b2bc893da6d560f6c089f04e3c4bcf (patch)
tree1d7085c8c5724a784e9fc63d76ef773d1ccca9de /src/main/java/org
parent8a717dddad8338a7e249f299c699b24342b2cb85 (diff)
parent8680ee387fb428cef246b2d04702b9a3839630ef (diff)
downloadcraftbukkit-4c483edf08b2bc893da6d560f6c089f04e3c4bcf.tar
craftbukkit-4c483edf08b2bc893da6d560f6c089f04e3c4bcf.tar.gz
craftbukkit-4c483edf08b2bc893da6d560f6c089f04e3c4bcf.tar.lz
craftbukkit-4c483edf08b2bc893da6d560f6c089f04e3c4bcf.tar.xz
craftbukkit-4c483edf08b2bc893da6d560f6c089f04e3c4bcf.zip
Merge remote branch 'upstream/master'
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/Main.java76
3 files changed, 78 insertions, 4 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index e5758051..216a26b6 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -27,7 +27,7 @@ public final class CraftServer implements Server {
pluginManager.RegisterInterface(JavaPluginLoader.class);
- File pluginFolder = new File("plugins");
+ File pluginFolder = (File)console.options.valueOf("plugins");
if (pluginFolder.exists()) {
try {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 5cd587b2..31b9d0f0 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -42,6 +42,10 @@ public class CraftWorld implements World {
return block;
}
+
+ public int getHighestBlockYAt(int x, int z) {
+ return world.d(x, z);
+ }
public Chunk getChunkAt(int x, int z) {
ChunkCoordinate loc = new ChunkCoordinate(x, z);
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 786e56d8..db338374 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -1,16 +1,86 @@
package org.bukkit.craftbukkit;
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import joptsimple.OptionParser;
+import joptsimple.OptionSet;
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");
+
+ 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");
+ }
+ };
+
+ OptionSet options = null;
try {
- MinecraftServer.main(args);
- } catch (Throwable t) {
- t.printStackTrace();
+ 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();
+ }
}
}
+
+ private static List<String> asList(String... params) {
+ return Arrays.asList(params);
+ }
}