From 7e9bfd9d436dde8646c1f50c9dc142d1177d5c3b Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Tue, 4 Jan 2011 05:56:09 +0800 Subject: [PATCH 1/3] Added getHighestBlockYAt By: FrozenCow --- .../src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 5cd587b200..31b9d0f0e3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/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); From fcc27e9e407d526718ec5eb55fa59774e017992c Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Tue, 4 Jan 2011 00:43:23 +0000 Subject: [PATCH 2/3] Added command-line arguments, forced nogui By: Dinnerbone --- paper-server/pom.xml | 5 ++ .../org/bukkit/craftbukkit/CraftServer.java | 2 +- .../java/org/bukkit/craftbukkit/Main.java | 71 ++++++++++++++++++- 3 files changed, 74 insertions(+), 4 deletions(-) diff --git a/paper-server/pom.xml b/paper-server/pom.xml index 59d9f90a04..aa623a25b1 100644 --- a/paper-server/pom.xml +++ b/paper-server/pom.xml @@ -27,6 +27,11 @@ jar compile + + net.sf.jopt-simple + jopt-simple + 3.2 + diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index e575805136..216a26b6e5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/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/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java index 786e56d840..0f89768e47 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java @@ -1,16 +1,81 @@ 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("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 asList(String... params) { + return Arrays.asList(params); + } } From 21271ef958ad8cbc47fe67f09c9b56d1323acfb1 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Tue, 4 Jan 2011 01:19:26 +0000 Subject: [PATCH 3/3] Added -w for world directory By: Dinnerbone --- paper-server/src/main/java/org/bukkit/craftbukkit/Main.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java index 0f89768e47..db33837468 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java @@ -35,6 +35,11 @@ public class Main { .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)