[Cherbot-commit] SF.net SVN: cherbot: [98] trunk/src/net/sf/cherbot/CherBot.java
Status: Alpha
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2007-06-25 09:57:21
|
Revision: 98
http://svn.sourceforge.net/cherbot/?rev=98&view=rev
Author: christianhujer
Date: 2007-06-25 02:35:04 -0700 (Mon, 25 Jun 2007)
Log Message:
-----------
Removed code that's now handled in connections.
Made database URL configurable.
Added primitive implementation of module handling.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/CherBot.java
Modified: trunk/src/net/sf/cherbot/CherBot.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBot.java 2007-06-24 21:40:39 UTC (rev 97)
+++ trunk/src/net/sf/cherbot/CherBot.java 2007-06-25 09:35:04 UTC (rev 98)
@@ -6,12 +6,14 @@
package net.sf.cherbot;
-import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
import java.util.List;
-import java.sql.DriverManager;
-import java.sql.Connection;
+import java.util.ArrayList;
import net.sf.japi.io.args.ArgParser;
import net.sf.japi.io.args.BasicCommand;
+import net.sf.japi.io.args.Option;
import org.jetbrains.annotations.NotNull;
/** Main class of Cherbot.
@@ -19,6 +21,21 @@
*/
public class CherBot extends BasicCommand {
+ /** The default database URL. */
+ @NotNull private static final String DEFAULT_DATABASE_URL = "jdbc:derby:cherbotdb;create=true";
+
+ /** The module registry. */
+ @NotNull private final List<Module> modules = new ArrayList<Module>();
+
+ /** The database URL. */
+ @NotNull private String databaseURL = DEFAULT_DATABASE_URL;
+
+ /** Create an instance of CherBot. */
+ public CherBot() {
+ modules.add(new ServerModule());
+ modules.add(new PlayerModule());
+ modules.add(new ClanModule());
+ }
/** Main program.
* @param args Command line arguments (currently ignored).
*/
@@ -31,46 +48,35 @@
/** {@inheritDoc} */
public int run(@NotNull final List<String> strings) throws Exception {
- //DriverManager.registerDriver(new org.apache.derby.jdbc.EmbeddedDriver());
- con = DriverManager.getConnection("jdbc:derby:cherbotdb;create=true");
+ con = DriverManager.getConnection(databaseURL);
System.out.println(con);
+ load();
return 0;
}
- public void metaserver() throws IOException {
- // read "62.75.224.80|177|daimonin.game-server.cc|52|0.9.7|This is the Daimonin 0.9.7 server.|0|0|0\n"
+ /** Loads all modules.
+ * @throws SQLException in case of persistence issues.
+ */
+ private void load() throws SQLException {
+ for (final Module module : modules) {
+ if (module instanceof PersistentModule) {
+ ((PersistentModule) module).load(con);
+ }
+ }
}
- public void connect() throws IOException {
- // write 0x00 0x29 "version 991023 991023 Daimonin SDL Client"
- // read 0x00 0x1e 0x02 "991023 991023 Daimonin Server"
- // write 0x00 0x99 "setup sound 1 map2 cmd 1 mapsize 17x17 darkness 1 facecache 1 skf 3386|dd257ea spf 2737|404f6ead bpf 227483|8ab2a06 stf 2253|16d49f0f amf 262790|ec2627ee"
- // read 0x00 0x75 0x17 " sound 1 map2cmd 1 mapsize 17x17 darkness 1 facecache 1 skf OK spf OK bpf 227639|117ae13a stf OK amf 263415|ec0d5f79"
- // write 0x00 0x04 "rf 4"
- // read lots of data
- // write 0x00 0x04 "rf 3"
- // read lots of data
- // write 0x00 0x05 "addme"
- // read 0x00 0x06 0x18 "4 QN0" 0x00 0x01 0x15
- // write 0x00 0x12 "reply LFoobuzzer49" // L not part of name
- // read 0x00 0x06 0x18 "4 QP0"
- // write 0x00 0x0E "reply xxxxxxxx"
- // read 0x00 0x10 0x06 0x00 0x00 "Welcome Back!"
- // read 0x00 0x24 0x06 0x00 0x00 "Cheristheus has entered the game."
- // read 0x00 0x19 0x11 0x00 0x4e 0x01 0x60 0x00 0x02 0x27 0x2a 0x00 0x00 0x10 0xec 0x0b "Cheristheus"
- // read lots of data
- // read 0x00 0x16 0x05 0x00 0x07 0x02 0x42 0x21 0x80 0x01 "Cheristheus" 0x00 0x90 0xea
- // read 0x00 0x16 0x05 0x00 0x07 0x02 0x42 0x21 0x80 0x01 "Cheristheus" 0x00 0x90 0xeb
- // read 0x00 0x16 0x05 0x00 0x07 0x02 0x42 0x21 0x80 0x01 "Cheristheus" 0x00 0x90 0xec
- // write 0x00 0x0d "ncom " 0x00 0x01 0xff 0xff 0xff 0xff "/n" // north
- // write 0x00 0x0d "ncom " 0x00 0x02 0xff 0xff 0xff 0xff "/n" // north
- // write 0x00 0x0d "ncom " 0x00 0x03 0xff 0xff 0xff 0xff "/e" // east
- // write 0x00 0x0d "ncom " 0x00 0x04 0xff 0xff 0xff 0xff "/s" // south
- // write 0x00 0x0d "ncom " 0x00 0x05 0xff 0xff 0xff 0xff "/w" // west
- // write 0x00 0x0e "ncom " 0x00 0x06 0xff 0xff 0xff 0xff "/sw" // southwest
- // write 0x00 0x0e "ncom " 0x00 0x07 0xff 0xff 0xff 0xff "/se" // southeast
- // write 0x00 0x0e "ncom " 0x00 0x08 0xff 0xff 0xff 0xff "/nw" // northwest
- // write 0x00 0x0e "ncom " 0x00 0x09 0xff 0xff 0xff 0xff "/ne" // northeast
- // write 0x00 0x0f "ncom " 0x00 0x0A 0xff 0xff 0xff 0xff "/who" // /who
+ /** Returns the database URL.
+ * @return The database URL.
+ */
+ @NotNull public String getDatabaseURL() {
+ return databaseURL;
}
+
+ /** Sets the database URL.
+ * @param databaseURL The database URL.
+ */
+ @Option({"databaseURL"})
+ public void setDatabaseURL(@NotNull final String databaseURL) {
+ this.databaseURL = databaseURL;
+ }
} // class CherBot
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|