diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftServer.java | 35 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/Main.java | 6 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 1c6c7b96..157e1899 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1,5 +1,9 @@ package org.bukkit.craftbukkit; +import com.avaje.ebean.config.DataSourceConfig; +import com.avaje.ebean.config.ServerConfig; +import com.avaje.ebean.config.dbplatform.SQLitePlatform; +import com.avaje.ebeaninternal.server.lib.sql.TransactionIsolation; import org.bukkit.command.*; import org.bukkit.entity.Player; import org.bukkit.event.world.WorldLoadEvent; @@ -33,6 +37,7 @@ import org.bukkit.plugin.SimplePluginManager; import org.bukkit.plugin.java.JavaPluginLoader; import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.craftbukkit.scheduler.CraftScheduler; +import org.bukkit.util.config.Configuration; public final class CraftServer implements Server { private final String serverName = "Craftbukkit"; @@ -44,6 +49,7 @@ public final class CraftServer implements Server { protected final MinecraftServer console; protected final ServerConfigurationManager server; private final Map<String, World> worlds = new LinkedHashMap<String, World>(); + private final Configuration configuration; public CraftServer(MinecraftServer console, ServerConfigurationManager server) { this.console = console; @@ -53,6 +59,19 @@ public final class CraftServer implements Server { Bukkit.setServer(this); Logger.getLogger("Minecraft").log(Level.INFO, "This server is running " + getName() + " version " + getVersion()); + + configuration = new Configuration((File)console.options.valueOf("bukkit-settings")); + configuration.load(); + loadConfigDefaults(); + configuration.save(); + } + + private void loadConfigDefaults() { + configuration.getString("database.url", "jdbc:sqlite:{DIR}database.db"); + configuration.getString("database.username", "bukkit"); + configuration.getString("database.password", "walrus"); + configuration.getString("database.driver", "org.sqlite.JDBC"); + configuration.getString("database.isolation", "SERIALIZABLE"); } public void loadPlugins() { @@ -365,6 +384,22 @@ public final class CraftServer implements Server { server.d(); } + public void configureDbConfig(ServerConfig config) { + DataSourceConfig ds = new DataSourceConfig(); + ds.setDriver(configuration.getString("database.driver")); + ds.setUrl(configuration.getString("database.url")); + ds.setUsername(configuration.getString("database.username")); + ds.setPassword(configuration.getString("database.password")); + ds.setIsolationLevel(TransactionIsolation.getLevel(configuration.getString("database.isolation"))); + + if (ds.getDriver().contains("sqlite")) { + config.setDatabasePlatform(new SQLitePlatform()); + config.getDatabasePlatform().getDbDdlSyntax().setIdentity(""); + } + + config.setDataSourceConfig(ds); + } + // Inner class to capture the output of default server commands class CommandListener implements ICommandListener { private final CommandSender commandSender; diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index a60e0bcb..f0863edd 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -59,6 +59,12 @@ public class Main { .withRequiredArg() .ofType(SimpleDateFormat.class) .describedAs("Log date format"); + + acceptsAll(asList("b", "bukkit-settings"), "File for bukkit settings") + .withRequiredArg() + .ofType(File.class) + .defaultsTo(new File("bukkit.yml")) + .describedAs("Yml file"); } }; |