Thread: [Cherbot-commit] SF.net SVN: cherbot: [18] trunk/src/net/sf/cherbot
Status: Alpha
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2006-10-28 22:58:47
|
Revision: 18
http://svn.sourceforge.net/cherbot/?rev=18&view=rev
Author: christianhujer
Date: 2006-10-28 15:58:11 -0700 (Sat, 28 Oct 2006)
Log Message:
-----------
Removed unused version information from files.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/BlackListManager.java
trunk/src/net/sf/cherbot/CherBot.java
trunk/src/net/sf/cherbot/CherBotException.java
trunk/src/net/sf/cherbot/CherBotLogger.java
trunk/src/net/sf/cherbot/CherBotPermission.java
trunk/src/net/sf/cherbot/CherBotSecurityManager.java
trunk/src/net/sf/cherbot/CollectionsManager.java
trunk/src/net/sf/cherbot/CommType.java
trunk/src/net/sf/cherbot/CrimeManager.java
trunk/src/net/sf/cherbot/CronManager.java
trunk/src/net/sf/cherbot/DeathsManager.java
trunk/src/net/sf/cherbot/DummyManagerProxy.java
trunk/src/net/sf/cherbot/EmotesManager.java
trunk/src/net/sf/cherbot/ExampleTestCase.java
trunk/src/net/sf/cherbot/ExampleTester.java
trunk/src/net/sf/cherbot/GreetingsManager.java
trunk/src/net/sf/cherbot/GroupManager.java
trunk/src/net/sf/cherbot/LamentsManager.java
trunk/src/net/sf/cherbot/MailManager.java
trunk/src/net/sf/cherbot/Manager.java
trunk/src/net/sf/cherbot/ManagerDocumenter.java
trunk/src/net/sf/cherbot/NoSuchPlayerException.java
trunk/src/net/sf/cherbot/NoobManager.java
trunk/src/net/sf/cherbot/PlayerManager.java
trunk/src/net/sf/cherbot/PollManager.java
trunk/src/net/sf/cherbot/RodBabyManager.java
trunk/src/net/sf/cherbot/RodBabyWannabeManager.java
trunk/src/net/sf/cherbot/SalesManager.java
trunk/src/net/sf/cherbot/SmutException.java
trunk/src/net/sf/cherbot/SmutManager.java
trunk/src/net/sf/cherbot/TestManager.java
trunk/src/net/sf/cherbot/TimeManager.java
Modified: trunk/src/net/sf/cherbot/BlackListManager.java
===================================================================
--- trunk/src/net/sf/cherbot/BlackListManager.java 2006-10-28 22:47:18 UTC (rev 17)
+++ trunk/src/net/sf/cherbot/BlackListManager.java 2006-10-28 22:58:11 UTC (rev 18)
@@ -12,18 +12,12 @@
/**
* Manages a black list of users that may not use Cherbot.
* @author $Author: chris $
- * @version $Id: BlackListManager.java,v 1.13 2005/11/09 20:30:00 chris Exp $
*/
@Manager.Description("Blacklist of players that are denied to use Cherbot.")
@Manager.Features({ "Blacklist players that are denied to use Cherbot." })
public class BlackListManager extends Manager {
/**
- * Version information
- */
- public static final String version = "$Revision: 1.13 $";
-
- /**
* Permission to modify blacklist.
*/
private static final String PERM_BLACKLIST = "Blacklist";
@@ -135,52 +129,3 @@
} // IO Modules
} // class BlackListManager
-
-/*
- * $Log: BlackListManager.java,v $
- * Revision 1.13 2005/11/09 20:30:00 chris
- * Changed player access to allow players with - in their names. Now all non-whitespace chars are allowed for players.
- *
- * Revision 1.12 2005/08/31 13:55:28 chris
- * Improved code quality.
- * Removed console control feature.
- * Changed member count to reflect only real members.
- *
- * Revision 1.11 2005/08/29 15:45:39 chris
- * Some minor improvements.
- *
- * Revision 1.10 2005/04/02 23:08:43 chris
- * Reworked command pattern creation to allow variables.
- * Reworked commands to use variables.
- * Added alliances to groups.
- * Added group membership listing to groups.
- *
- * Revision 1.9 2005/04/01 11:36:23 chris
- * Removed unused boundaries from regexps.
- *
- * Revision 1.8 2005/04/01 11:20:33 chris
- * Added Timemanager, made patterns case insensitive.
- *
- * Revision 1.7 2005/03/23 12:46:32 chris
- * Improved regex handling.
- *
- * Revision 1.6 2005/03/18 16:53:56 chris
- * Improved some regular expressions.
- * Moved lots of I/O code from subclasses to Manager.java.
- *
- * Revision 1.5 2005/03/15 23:49:25 chris
- * Fixed regular expressions with test results.
- *
- * Revision 1.4 2005/03/15 22:41:26 chris
- * Improved regexes.
- *
- * Revision 1.3 2005/03/15 11:43:45 chris
- * Added manager description.
- *
- * Revision 1.2 2005/03/15 01:55:43 chris
- * Refactored matcher, fixed null vs. Blacklist bug.
- *
- * Revision 1.1 2005/03/14 16:55:00 chris
- * Added.
- *
- */
Modified: trunk/src/net/sf/cherbot/CherBot.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBot.java 2006-10-28 22:47:18 UTC (rev 17)
+++ trunk/src/net/sf/cherbot/CherBot.java 2006-10-28 22:58:11 UTC (rev 18)
@@ -25,7 +25,6 @@
/**
* A Daimonin bot.
* @author $Author: chris $
- * @version $Id: CherBot.java,v 1.31 2005/11/09 20:30:00 chris Exp $
* @todo split this class into four: A generic base class for robots, a class handling Daimonin-specific stuff, an interface for network
* implementations implemted by the latter, and this specific CherBot subclass.
* @todo perhaps add a graphical interface.
@@ -485,7 +484,6 @@
/**
* The internal manager.
* @author $Author: chris $
- * @version $Revision: 1.31 $
*/
@Manager.Description("Manages the other modules and gives some general information about the bot.")
@Manager.Features({
Modified: trunk/src/net/sf/cherbot/CherBotException.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBotException.java 2006-10-28 22:47:18 UTC (rev 17)
+++ trunk/src/net/sf/cherbot/CherBotException.java 2006-10-28 22:58:11 UTC (rev 18)
@@ -11,21 +11,10 @@
* These exceptions are runtime exceptions thrown if actors use illegal arguments or commands in a wrong state.
* The message of such an exception must be a message meaningful to the end user (bot user).
* @author $Author: chris $
- * @version $Id: CherBotException.java,v 1.3 2005/03/18 17:35:42 chris Exp $
*/
public class CherBotException extends RuntimeException {
/**
- * Version information
- */
- public static final String version = "$Revision: 1.3 $";
-
- /**
- * Serial Version.
- */
- private static final long serialVersionUID = 1L;
-
- /**
* Create a CherBotException.
* @param msg Message (displayed to end user)
*/
@@ -34,24 +23,3 @@
}
} // class CherBotException
-
-/*
- * $Log: CherBotException.java,v $
- * Revision 1.3 2005/03/18 17:35:42 chris
- * Fixed cocumentation
- *
- * Revision 1.2 2005/03/14 03:06:20 chris
- * Fixed copyright.
- *
- * Revision 1.1 2005/03/09 01:08:23 chris
- * Added annotations to document commands.
- * Improved commands.
- * Unified some regular expressions.
- * Reworked code to only shout in 2 particular cases:
- * a) VOTE for Daimonin adds.
- * b) A known criminal enters.
- * Added PollManager.
- * Added ManagerDocumenter.
- * Reworked Exception Handling to integrate CherBotException.
- *
- */
Modified: trunk/src/net/sf/cherbot/CherBotLogger.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBotLogger.java 2006-10-28 22:47:18 UTC (rev 17)
+++ trunk/src/net/sf/cherbot/CherBotLogger.java 2006-10-28 22:58:11 UTC (rev 18)
@@ -13,16 +13,10 @@
/**
* This class is used for logging within Cherbot.
* @author $Author: chris $
- * @version $Id: CherBotLogger.java,v 1.2 2005/08/31 13:55:28 chris Exp $
*/
public class CherBotLogger {
/**
- * Version information
- */
- public static final String version = "$Revision: 1.2 $";
-
- /**
* The logger.
*/
private PrintWriter log;
@@ -93,15 +87,3 @@
}
} // class CherBotLogger
-
-/*
- * $Log: CherBotLogger.java,v $
- * Revision 1.2 2005/08/31 13:55:28 chris
- * Improved code quality.
- * Removed console control feature.
- * Changed member count to reflect only real members.
- *
- * Revision 1.1 2005/08/29 15:45:39 chris
- * Some minor improvements.
- *
- */
Modified: trunk/src/net/sf/cherbot/CherBotPermission.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBotPermission.java 2006-10-28 22:47:18 UTC (rev 17)
+++ trunk/src/net/sf/cherbot/CherBotPermission.java 2006-10-28 22:58:11 UTC (rev 18)
@@ -11,16 +11,10 @@
/**
* Permissions to access the CherBot.
* @author $Author: chris $
- * @version $Id: CherBotPermission.java,v 1.1 2005/03/01 09:14:02 chris Exp $
*/
public class CherBotPermission extends BasicPermission {
/**
- * Version information
- */
- public static final String version = "$Revision: 1.1 $";
-
- /**
* Serial Version.
*/
private static final long serialVersionUID = 1L;
@@ -34,10 +28,3 @@
}
} // class CherBotPermission
-
-/*
- * $Log: CherBotPermission.java,v $
- * Revision 1.1 2005/03/01 09:14:02 chris
- * First import to version control.
- *
- */
Modified: trunk/src/net/sf/cherbot/CherBotSecurityManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBotSecurityManager.java 2006-10-28 22:47:18 UTC (rev 17)
+++ trunk/src/net/sf/cherbot/CherBotSecurityManager.java 2006-10-28 22:58:11 UTC (rev 18)
@@ -27,18 +27,12 @@
* SecurityManager for CherBot.
* The CherBotSecurityManager manages the permissions granted for the individual modules and actions.
* @author $Author: chris $
- * @version $Id: CherBotSecurityManager.java,v 1.17 2005/11/09 20:30:00 chris Exp $
*/
@Manager.Description("Cherbot has a sophisticated security system, derived from Java. It is comparable with JAAS, the security concept used in Java application servers. This module controls security.")
@Manager.Features({ "Grant permissions", "Revoke permissions", "List permissions" })
public class CherBotSecurityManager extends Manager {
/**
- * Version information
- */
- public static final String version = "$Revision: 1.17 $";
-
- /**
* Permission to grant permissions.
*/
private static final String PERM_GRANT = "Security.Grant";
@@ -321,78 +315,3 @@
}
} // class CherBotSecurityManager
-
-/*
- * $Log: CherBotSecurityManager.java,v $
- * Revision 1.17 2005/11/09 20:30:00 chris
- * Changed player access to allow players with - in their names. Now all non-whitespace chars are allowed for players.
- *
- * Revision 1.16 2005/08/31 13:55:28 chris
- * Improved code quality.
- * Removed console control feature.
- * Changed member count to reflect only real members.
- *
- * Revision 1.15 2005/08/29 15:45:39 chris
- * Some minor improvements.
- *
- * Revision 1.14 2005/04/02 23:08:43 chris
- * Reworked command pattern creation to allow variables.
- * Reworked commands to use variables.
- * Added alliances to groups.
- * Added group membership listing to groups.
- *
- * Revision 1.13 2005/04/01 11:36:23 chris
- * Removed unused boundaries from regexps.
- *
- * Revision 1.12 2005/04/01 11:20:33 chris
- * Added Timemanager, made patterns case insensitive.
- *
- * Revision 1.11 2005/03/23 12:46:32 chris
- * Improved regex handling.
- *
- * Revision 1.10 2005/03/18 16:53:56 chris
- * Improved some regular expressions.
- * Moved lots of I/O code from subclasses to Manager.java.
- *
- * Revision 1.9 2005/03/15 23:49:25 chris
- * Fixed regular expressions with test results.
- *
- * Revision 1.8 2005/03/15 11:43:45 chris
- * Added manager description.
- *
- * Revision 1.7 2005/03/15 01:55:43 chris
- * Refactored matcher, fixed null vs. Blacklist bug.
- *
- * Revision 1.6 2005/03/09 01:08:23 chris
- * Added annotations to document commands.
- * Improved commands.
- * Unified some regular expressions.
- * Reworked code to only shout in 2 particular cases:
- * a) VOTE for Daimonin adds.
- * b) A known criminal enters.
- * Added PollManager.
- * Added ManagerDocumenter.
- * Reworked Exception Handling to integrate CherBotException.
- *
- * Revision 1.5 2005/03/04 11:26:33 chris
- * Refactored to use central actor information.
- * Collections: Minor code improvements.
- * SmutManager: Implemented load/save.
- *
- * Revision 1.4 2005/03/03 18:23:47 chris
- * Improved source code quality.
- * Corrected some regular expressions.
- * Added handling for events and text.
- *
- * Revision 1.3 2005/03/01 10:43:37 chris
- * Added list other facility.
- * Beautified source code.
- * Added some documentation.
- *
- * Revision 1.2 2005/03/01 10:04:27 chris
- * Centralized load/save exception handling.
- *
- * Revision 1.1 2005/03/01 09:14:02 chris
- * First import to version control.
- *
- */
Modified: trunk/src/net/sf/cherbot/CollectionsManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CollectionsManager.java 2006-10-28 22:47:18 UTC (rev 17)
+++ trunk/src/net/sf/cherbot/CollectionsManager.java 2006-10-28 22:58:11 UTC (rev 18)
@@ -19,7 +19,6 @@
/**
* Manager for collectors.
* @author $Author: chris $
- * @version $Id: CollectionsManager.java,v 1.21 2005/11/09 20:30:00 chris Exp $
*/
@Manager.Description("This module allows players to manage a list of items they collect. You can also ask what other players collect or who collects a certain item. Like most modules, querying works also if the queried player is not online.")
@Manager.Features({
@@ -30,11 +29,6 @@
public class CollectionsManager extends Manager {
/**
- * Version information
- */
- public static final String version = "$Revision: 1.21 $";
-
- /**
* Permission to collect.
*/
private static final String PERM_COLLECT = "Collections.Edit";
@@ -42,7 +36,6 @@
/**
* Entry.
* @author $Author: chris $
- * @version $Revision: 1.21 $
*/
private static class Entry implements Comparable<Entry> {
@@ -579,91 +572,3 @@
} // IO Modules
} // class CollectorsManager
-
-/*
- * $Log: CollectionsManager.java,v $
- * Revision 1.21 2005/11/09 20:30:00 chris
- * Changed player access to allow players with - in their names. Now all non-whitespace chars are allowed for players.
- *
- * Revision 1.20 2005/08/31 13:55:28 chris
- * Improved code quality.
- * Removed console control feature.
- * Changed member count to reflect only real members.
- *
- * Revision 1.19 2005/04/26 10:49:45 chris
- * omitted 'want' from C_COLLECT since it has some modal character and is used elsewhere.
- *
- * Revision 1.18 2005/04/02 23:08:43 chris
- * Reworked command pattern creation to allow variables.
- * Reworked commands to use variables.
- * Added alliances to groups.
- * Added group membership listing to groups.
- *
- * Revision 1.17 2005/04/01 11:36:23 chris
- * Removed unused boundaries from regexps.
- *
- * Revision 1.16 2005/04/01 11:20:33 chris
- * Added Timemanager, made patterns case insensitive.
- *
- * Revision 1.15 2005/03/30 22:12:59 chris
- * Listing online collectors.
- *
- * Revision 1.14 2005/03/25 10:25:13 chris
- * Implemented online collections and listening.
- *
- * Revision 1.13 2005/03/23 12:46:32 chris
- * Improved regex handling.
- *
- * Revision 1.12 2005/03/18 16:53:56 chris
- * Improved some regular expressions.
- * Moved lots of I/O code from subclasses to Manager.java.
- *
- * Revision 1.11 2005/03/15 11:44:02 chris
- * Made Cherbot less picky on apostrophes.
- *
- * Revision 1.10 2005/03/15 01:55:43 chris
- * Refactored matcher, fixed null vs. Blacklist bug.
- *
- * Revision 1.9 2005/03/14 03:13:07 chris
- * Improved regular expressions.
- * Added class annotations.
- * Added "I collect nothing" command.
- *
- * Revision 1.8 2005/03/10 14:18:30 chris
- * Improved regular expressions.
- *
- * Revision 1.7 2005/03/09 01:08:23 chris
- * Added annotations to document commands.
- * Improved commands.
- * Unified some regular expressions.
- * Reworked code to only shout in 2 particular cases:
- * a) VOTE for Daimonin adds.
- * b) A known criminal enters.
- * Added PollManager.
- * Added ManagerDocumenter.
- * Reworked Exception Handling to integrate CherBotException.
- *
- * Revision 1.6 2005/03/05 11:18:11 chris
- * Fixed serious security bug.
- *
- * Revision 1.5 2005/03/04 11:26:33 chris
- * Refactored to use central actor information.
- * Collections: Minor code improvements.
- * SmutManager: Implemented load/save.
- *
- * Revision 1.4 2005/03/03 18:23:47 chris
- * Improved source code quality.
- * Corrected some regular expressions.
- * Added handling for events and text.
- *
- * Revision 1.3 2005/03/01 10:59:52 chris
- * Improved source format.
- * Added more commands.
- *
- * Revision 1.2 2005/03/01 10:04:27 chris
- * Centralized load/save exception handling.
- *
- * Revision 1.1 2005/03/01 09:14:02 chris
- * First import to version control.
- *
- */
Modified: trunk/src/net/sf/cherbot/CommType.java
===================================================================
--- trunk/src/net/sf/cherbot/CommType.java 2006-10-28 22:47:18 UTC (rev 17)
+++ trunk/src/net/sf/cherbot/CommType.java 2006-10-28 22:58:11 UTC (rev 18)
@@ -15,7 +15,6 @@
/**
* Enumeration for known communication types, along with matching facility.
* @author $Author: chris $
- * @version $Revision: 1.4 $
*/
public enum CommType {
@@ -61,24 +60,3 @@
}
} // enum CommType
-
-/*
- * $Log: CommType.java,v $
- * Revision 1.4 2005/11/15 20:50:07 chris
- * Fixed some behaviour.
- *
- * Revision 1.3 2005/08/31 13:55:28 chris
- * Improved code quality.
- * Removed console control feature.
- * Changed member count to reflect only real members.
- *
- * Revision 1.2 2005/04/02 23:08:43 chris
- * Reworked command pattern creation to allow variables.
- * Reworked commands to use variables.
- * Added alliances to groups.
- * Added group membership listing to groups.
- *
- * Revision 1.1 2005/03/03 18:22:22 chris
- * Added.
- *
- */
Modified: trunk/src/net/sf/cherbot/CrimeManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CrimeManager.java 2006-10-28 22:47:18 UTC (rev 17)
+++ trunk/src/net/sf/cherbot/CrimeManager.java 2006-10-28 22:58:11 UTC (rev 18)
@@ -18,7 +18,6 @@
/**
* Class to manage crimes.
* @author $Author: chris $
- * @version $Revision: 1.22 $
* @todo timestamps, victims, eyewitnesses.
*/
@Manager.Description("Manages crimes and criminals.")
@@ -31,11 +30,6 @@
public class CrimeManager extends Manager {
/**
- * Version Information.
- */
- public static final String version = "$Revision: 1.22 $";
-
- /**
* Crimetypes.
*/
private SortedSet<String> crimeTypes = new TreeSet<String>();
@@ -393,13 +387,9 @@
///** Class for a crime type.
// * @author $Author: chris $
-// * @version $Revision: 1.22 $
// */
//class CrimeType {
//
-// /** Version Information. */
-// public static final String version = "$Revision: 1.22 $";
-//
// /** ID of this CrimeType. */
// String id;
//
@@ -416,13 +406,9 @@
//
///** Class for a crime.
// * @author $Author: chris $
-// * @version $Revision: 1.22 $
// */
//class Crime {
//
-// /** Version Information. */
-// public static final String version = "$Revision: 1.22 $";
-//
// /** The type of this Crime.
// * Should match with an id from a CrimeType.
// */
@@ -491,92 +477,3 @@
// }
//
//} // class Crime
-
-/*
- * $Log: CrimeManager.java,v $
- * Revision 1.22 2005/11/09 20:30:00 chris
- * Changed player access to allow players with - in their names. Now all non-whitespace chars are allowed for players.
- *
- * Revision 1.21 2005/08/31 13:55:28 chris
- * Improved code quality.
- * Removed console control feature.
- * Changed member count to reflect only real members.
- *
- * Revision 1.20 2005/04/26 10:50:06 chris
- * Fixed regex bug.
- *
- * Revision 1.19 2005/04/02 23:08:43 chris
- * Reworked command pattern creation to allow variables.
- * Reworked commands to use variables.
- * Added alliances to groups.
- * Added group membership listing to groups.
- *
- * Revision 1.18 2005/04/01 11:36:23 chris
- * Removed unused boundaries from regexps.
- *
- * Revision 1.17 2005/04/01 11:20:33 chris
- * Added Timemanager, made patterns case insensitive.
- *
- * Revision 1.16 2005/03/30 22:14:49 chris
- * Inform offline criminals, list online criminals.
- *
- * Revision 1.15 2005/03/25 10:28:25 chris
- * Imrpoved commands.
- *
- * Revision 1.14 2005/03/23 12:46:32 chris
- * Improved regex handling.
- *
- * Revision 1.13 2005/03/18 16:53:56 chris
- * Improved some regular expressions.
- * Moved lots of I/O code from subclasses to Manager.java.
- *
- * Revision 1.12 2005/03/15 23:49:25 chris
- * Fixed regular expressions with test results.
- *
- * Revision 1.11 2005/03/15 11:44:02 chris
- * Made Cherbot less picky on apostrophes.
- *
- * Revision 1.10 2005/03/15 01:55:43 chris
- * Refactored matcher, fixed null vs. Blacklist bug.
- *
- * Revision 1.9 2005/03/14 03:46:42 chris
- * Improved regexp.
- *
- * Revision 1.8 2005/03/14 03:11:27 chris
- * Added class annotations.
- * Fixed output of crime count.
- *
- * Revision 1.7 2005/03/10 21:11:33 chris
- * Added list reported crimes command.
- *
- * Revision 1.6 2005/03/09 01:08:23 chris
- * Added annotations to document commands.
- * Improved commands.
- * Unified some regular expressions.
- * Reworked code to only shout in 2 particular cases:
- * a) VOTE for Daimonin adds.
- * b) A known criminal enters.
- * Added PollManager.
- * Added ManagerDocumenter.
- * Reworked Exception Handling to integrate CherBotException.
- *
- * Revision 1.5 2005/03/04 11:35:10 chris
- * Fixed minor documentation bugs.
- *
- * Revision 1.4 2005/03/04 11:26:33 chris
- * Refactored to use central actor information.
- * Collections: Minor code improvements.
- * SmutManager: Implemented load/save.
- *
- * Revision 1.3 2005/03/03 18:23:47 chris
- * Improved source code quality.
- * Corrected some regular expressions.
- * Added handling for events and text.
- *
- * Revision 1.2 2005/03/01 10:04:27 chris
- * Centralized load/save exception handling.
- *
- * Revision 1.1 2005/03/01 09:14:02 chris
- * First import to version control.
- *
- */
Modified: trunk/src/net/sf/cherbot/CronManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CronManager.java 2006-10-28 22:47:18 UTC (rev 17)
+++ trunk/src/net/sf/cherbot/CronManager.java 2006-10-28 22:58:11 UTC (rev 18)
@@ -14,18 +14,12 @@
* Manager to manage events (commands etc.) that need to be scheduled in some timed intervals.
* It is mainly a proxy handling all manager interaction.
* @author $Author: chris $
- * @version $Id: CronManager.java,v 1.2 2005/09/13 21:00:35 chris Exp $
*/
@Manager.Description("This manager is used for scheduling commands in regular intervals.")
@Manager.Features("This manager is similar to the cron command in UNIX or the task planner in Windows.")
public class CronManager extends Manager {
/**
- * Version information
- */
- public static final String version = "$Revision: 1.2 $";
-
- /**
* The TickEvents.
*/
private final List<CronTask> cronTasks = new ArrayList<CronTask>();
Modified: trunk/src/net/sf/cherbot/DeathsManager.java
===================================================================
--- trunk/src/net/sf/cherbot/DeathsManager.java 2006-10-28 22:47:18 UTC (rev 17)
+++ trunk/src/net/sf/cherbot/DeathsManager.java 2006-10-28 22:58:11 UTC (rev 18)
@@ -15,7 +15,6 @@
* A class that manages deaths.
* Each time a player dies, his/her death is counted.
* @author $Author: chris $
- * @version $Id: DeathsManager.java,v 1.16 2005/11/09 20:30:00 chris Exp $
* @todo statistics and rankings
*/
@Manager.Description("The death manager recognizes that a player died. It counts each death of each player and manages two statistics. One for the deaths of each player and one of the kills from each mob.")
@@ -26,11 +25,6 @@
public class DeathsManager extends Manager {
/**
- * Version information
- */
- public static final String version = "$Revision: 1.16 $";
-
- /**
* Death count.
*/
private Map<String, int[]> deaths = new HashMap<String, int[]>();
@@ -208,69 +202,3 @@
} // IO Modules
} // class DeathsManager
-
-/*
- * $Log: DeathsManager.java,v $
- * Revision 1.16 2005/11/09 20:30:00 chris
- * Changed player access to allow players with - in their names. Now all non-whitespace chars are allowed for players.
- *
- * Revision 1.15 2005/08/31 13:55:28 chris
- * Improved code quality.
- * Removed console control feature.
- * Changed member count to reflect only real members.
- *
- * Revision 1.14 2005/04/01 11:36:23 chris
- * Removed unused boundaries from regexps.
- *
- * Revision 1.13 2005/04/01 11:20:33 chris
- * Added Timemanager, made patterns case insensitive.
- *
- * Revision 1.12 2005/03/30 22:16:02 chris
- * Implemented level-relative kill ranking.
- *
- * Revision 1.11 2005/03/25 10:28:12 chris
- * Improved commands.
- *
- * Revision 1.10 2005/03/23 12:46:32 chris
- * Improved regex handling.
- *
- * Revision 1.9 2005/03/18 16:53:56 chris
- * Improved some regular expressions.
- * Moved lots of I/O code from subclasses to Manager.java.
- *
- * Revision 1.8 2005/03/15 01:55:43 chris
- * Refactored matcher, fixed null vs. Blacklist bug.
- *
- * Revision 1.7 2005/03/14 03:10:15 chris
- * Added class annotations.
- * Improved regexps.
- *
- * Revision 1.6 2005/03/09 01:08:23 chris
- * Added annotations to document commands.
- * Improved commands.
- * Unified some regular expressions.
- * Reworked code to only shout in 2 particular cases:
- * a) VOTE for Daimonin adds.
- * b) A known criminal enters.
- * Added PollManager.
- * Added ManagerDocumenter.
- * Reworked Exception Handling to integrate CherBotException.
- *
- * Revision 1.5 2005/03/05 11:18:27 chris
- * Removed superfluous synchronization.
- *
- * Revision 1.4 2005/03/04 14:53:43 chris
- * Fixed bug in reading regexp.
- *
- * Revision 1.3 2005/03/04 11:26:33 chris
- * Refactored to use central actor information.
- * Collections: Minor code improvements.
- * SmutManager: Implemented load/save.
- *
- * Revision 1.2 2005/03/03 22:56:23 chris
- * Improved code, fixed regexp
- *
- * Revision 1.1 2005/03/03 18:22:22 chris
- * Added.
- *
- */
Modified: trunk/src/net/sf/cherbot/DummyManagerProxy.java
===================================================================
--- trunk/src/net/sf/cherbot/DummyManagerProxy.java 2006-10-28 22:47:18 UTC (rev 17)
+++ trunk/src/net/sf/cherbot/DummyManagerProxy.java 2006-10-28 22:58:11 UTC (rev 18)
@@ -12,7 +12,6 @@
* This allows players to invoke commands from the removed module with a meaningful response like "This dommand was removed." instead of no response at
* all.
* @author $Author: chris $
- * @version $Id: DummyManagerProxy.java,v 1.7 2005/08/31 13:55:28 chris Exp $
*/
@Manager.Description("Only a dummy manager for helping disabling managers.")
@Manager.Features({
@@ -21,11 +20,6 @@
public class DummyManagerProxy extends Manager {
/**
- * Version information
- */
- public static final String version = "$Revision: 1.7 $";
-
- /**
* Create a DummyManager.
* @param cherBot CherBot to create DummyManager for
*/
@@ -52,39 +46,3 @@
}
} // class DUmmyManagerProxy
-
-/*
- * $Log: DummyManagerProxy.java,v $
- * Revision 1.7 2005/08/31 13:55:28 chris
- * Improved code quality.
- * Removed console control feature.
- * Changed member count to reflect only real members.
- *
- * Revision 1.6 2005/03/18 16:53:56 chris
- * Improved some regular expressions.
- * Moved lots of I/O code from subclasses to Manager.java.
- *
- * Revision 1.5 2005/03/15 23:49:25 chris
- * Fixed regular expressions with test results.
- *
- * Revision 1.4 2005/03/15 01:55:43 chris
- * Refactored matcher, fixed null vs. Blacklist bug.
- *
- * Revision 1.3 2005/03/14 03:10:02 chris
- * Added annotations.
- *
- * Revision 1.2 2005/03/09 01:08:23 chris
- * Added annotations to document commands.
- * Improved commands.
- * Unified some regular expressions.
- * Reworked code to only shout in 2 particular cases:
- * a) VOTE for Daimonin adds.
- * b) A known criminal enters.
- * Added PollManager.
- * Added ManagerDocumenter.
- * Reworked Exception Handling to integrate CherBotException.
- *
- * Revision 1.1 2005/03/05 20:18:48 chris
- * DummyManagerProxy.java
- *
- */
Modified: trunk/src/net/sf/cherbot/EmotesManager.java
===================================================================
--- trunk/src/net/sf/cherbot/EmotesManager.java 2006-10-28 22:47:18 UTC (rev 17)
+++ trunk/src/net/sf/cherbot/EmotesManager.java 2006-10-28 22:58:11 UTC (rev 18)
@@ -18,7 +18,6 @@
/**
* The emotes manager reacts on emotes.
* @author $Author: chris $
- * @version $Id: EmotesManager.java,v 1.10 2005/11/09 20:30:00 chris Exp $
* @todo add timestamps to attitude changing commands, so players cannot simply fill their attitude by hugging Cherbot.
*/
@Manager.Description("CherBot can react on some emotes.")
@@ -26,11 +25,6 @@
public class EmotesManager extends Manager {
/**
- * Version information
- */
- public static final String version = "$Revision: 1.10 $";
-
- /**
* Permission to modify lovers and haters.
*/
private static final String PERM_EMOTES = "Emotes";
@@ -804,43 +798,3 @@
} // IOModules
} // class EmotesManager
-
-/*
- * $Log: EmotesManager.java,v $
- * Revision 1.10 2005/11/09 20:30:00 chris
- * Changed player access to allow players with - in their names. Now all non-whitespace chars are allowed for players.
- *
- * Revision 1.9 2005/08/31 13:55:28 chris
- * Improved code quality.
- * Removed console control feature.
- * Changed member count to reflect only real members.
- *
- * Revision 1.8 2005/04/02 23:08:43 chris
- * Reworked command pattern creation to allow variables.
- * Reworked commands to use variables.
- * Added alliances to groups.
- * Added group membership listing to groups.
- *
- * Revision 1.7 2005/04/01 11:36:23 chris
- * Removed unused boundaries from regexps.
- *
- * Revision 1.6 2005/04/01 11:20:33 chris
- * Added Timemanager, made patterns case insensitive.
- *
- * Revision 1.5 2005/03/23 12:46:32 chris
- * Improved regex handling.
- *...
[truncated message content] |
|
From: <chr...@us...> - 2006-10-28 23:03:59
|
Revision: 19
http://svn.sourceforge.net/cherbot/?rev=19&view=rev
Author: christianhujer
Date: 2006-10-28 16:03:23 -0700 (Sat, 28 Oct 2006)
Log Message:
-----------
Updated author information.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/BlackListManager.java
trunk/src/net/sf/cherbot/CherBot.java
trunk/src/net/sf/cherbot/CherBotException.java
trunk/src/net/sf/cherbot/CherBotLogger.java
trunk/src/net/sf/cherbot/CherBotPermission.java
trunk/src/net/sf/cherbot/CherBotSecurityManager.java
trunk/src/net/sf/cherbot/CollectionsManager.java
trunk/src/net/sf/cherbot/CommType.java
trunk/src/net/sf/cherbot/Crime.java
trunk/src/net/sf/cherbot/CrimeManager.java
trunk/src/net/sf/cherbot/CronManager.java
trunk/src/net/sf/cherbot/DeathsManager.java
trunk/src/net/sf/cherbot/DummyManagerProxy.java
trunk/src/net/sf/cherbot/EmotesManager.java
trunk/src/net/sf/cherbot/ExampleTestCase.java
trunk/src/net/sf/cherbot/ExampleTester.java
trunk/src/net/sf/cherbot/GreetingsManager.java
trunk/src/net/sf/cherbot/GroupManager.java
trunk/src/net/sf/cherbot/LamentsManager.java
trunk/src/net/sf/cherbot/MailManager.java
trunk/src/net/sf/cherbot/Manager.java
trunk/src/net/sf/cherbot/ManagerDocumenter.java
trunk/src/net/sf/cherbot/NoSuchPlayerException.java
trunk/src/net/sf/cherbot/NoobManager.java
trunk/src/net/sf/cherbot/PlayerManager.java
trunk/src/net/sf/cherbot/PollManager.java
trunk/src/net/sf/cherbot/RodBabyManager.java
trunk/src/net/sf/cherbot/RodBabyWannabeManager.java
trunk/src/net/sf/cherbot/SalesManager.java
trunk/src/net/sf/cherbot/SmutException.java
trunk/src/net/sf/cherbot/SmutManager.java
trunk/src/net/sf/cherbot/TestManager.java
trunk/src/net/sf/cherbot/TimeManager.java
Modified: trunk/src/net/sf/cherbot/BlackListManager.java
===================================================================
--- trunk/src/net/sf/cherbot/BlackListManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/BlackListManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -11,7 +11,7 @@
/**
* Manages a black list of users that may not use Cherbot.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("Blacklist of players that are denied to use Cherbot.")
@Manager.Features({ "Blacklist players that are denied to use Cherbot." })
Modified: trunk/src/net/sf/cherbot/CherBot.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBot.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/CherBot.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -24,7 +24,7 @@
/**
* A Daimonin bot.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
* @todo split this class into four: A generic base class for robots, a class handling Daimonin-specific stuff, an interface for network
* implementations implemted by the latter, and this specific CherBot subclass.
* @todo perhaps add a graphical interface.
@@ -483,7 +483,7 @@
/**
* The internal manager.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("Manages the other modules and gives some general information about the bot.")
@Manager.Features({
Modified: trunk/src/net/sf/cherbot/CherBotException.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBotException.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/CherBotException.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -10,7 +10,7 @@
* Base Exception for exteptions that could occur when using players.
* These exceptions are runtime exceptions thrown if actors use illegal arguments or commands in a wrong state.
* The message of such an exception must be a message meaningful to the end user (bot user).
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class CherBotException extends RuntimeException {
Modified: trunk/src/net/sf/cherbot/CherBotLogger.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBotLogger.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/CherBotLogger.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -12,7 +12,7 @@
/**
* This class is used for logging within Cherbot.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class CherBotLogger {
Modified: trunk/src/net/sf/cherbot/CherBotPermission.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBotPermission.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/CherBotPermission.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -10,7 +10,7 @@
/**
* Permissions to access the CherBot.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class CherBotPermission extends BasicPermission {
Modified: trunk/src/net/sf/cherbot/CherBotSecurityManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBotSecurityManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/CherBotSecurityManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -26,7 +26,7 @@
/**
* SecurityManager for CherBot.
* The CherBotSecurityManager manages the permissions granted for the individual modules and actions.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("Cherbot has a sophisticated security system, derived from Java. It is comparable with JAAS, the security concept used in Java application servers. This module controls security.")
@Manager.Features({ "Grant permissions", "Revoke permissions", "List permissions" })
Modified: trunk/src/net/sf/cherbot/CollectionsManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CollectionsManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/CollectionsManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -18,7 +18,7 @@
/**
* Manager for collectors.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("This module allows players to manage a list of items they collect. You can also ask what other players collect or who collects a certain item. Like most modules, querying works also if the queried player is not online.")
@Manager.Features({
@@ -35,7 +35,7 @@
/**
* Entry.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
private static class Entry implements Comparable<Entry> {
Modified: trunk/src/net/sf/cherbot/CommType.java
===================================================================
--- trunk/src/net/sf/cherbot/CommType.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/CommType.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -14,7 +14,7 @@
/**
* Enumeration for known communication types, along with matching facility.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public enum CommType {
Modified: trunk/src/net/sf/cherbot/Crime.java
===================================================================
--- trunk/src/net/sf/cherbot/Crime.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/Crime.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -8,7 +8,7 @@
/**
* TODO
- * @author <a href="mailto:ch...@it...">Christian Hujer</a>
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
class Crime {
Modified: trunk/src/net/sf/cherbot/CrimeManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CrimeManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/CrimeManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -17,7 +17,7 @@
/**
* Class to manage crimes.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
* @todo timestamps, victims, eyewitnesses.
*/
@Manager.Description("Manages crimes and criminals.")
@@ -386,7 +386,7 @@
} // class CrimeManager
///** Class for a crime type.
-// * @author $Author: chris $
+// * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
// */
//class CrimeType {
//
@@ -405,7 +405,7 @@
//} // class CrimeType
//
///** Class for a crime.
-// * @author $Author: chris $
+// * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
// */
//class Crime {
//
Modified: trunk/src/net/sf/cherbot/CronManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CronManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/CronManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -13,7 +13,7 @@
/**
* Manager to manage events (commands etc.) that need to be scheduled in some timed intervals.
* It is mainly a proxy handling all manager interaction.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("This manager is used for scheduling commands in regular intervals.")
@Manager.Features("This manager is similar to the cron command in UNIX or the task planner in Windows.")
Modified: trunk/src/net/sf/cherbot/DeathsManager.java
===================================================================
--- trunk/src/net/sf/cherbot/DeathsManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/DeathsManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -14,7 +14,7 @@
/**
* A class that manages deaths.
* Each time a player dies, his/her death is counted.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
* @todo statistics and rankings
*/
@Manager.Description("The death manager recognizes that a player died. It counts each death of each player and manages two statistics. One for the deaths of each player and one of the kills from each mob.")
Modified: trunk/src/net/sf/cherbot/DummyManagerProxy.java
===================================================================
--- trunk/src/net/sf/cherbot/DummyManagerProxy.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/DummyManagerProxy.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -11,7 +11,7 @@
* If a module is removed, you don't remove the module completely, but create a DummyManagerProxy instance and list all removed modules there.
* This allows players to invoke commands from the removed module with a meaningful response like "This dommand was removed." instead of no response at
* all.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("Only a dummy manager for helping disabling managers.")
@Manager.Features({
Modified: trunk/src/net/sf/cherbot/EmotesManager.java
===================================================================
--- trunk/src/net/sf/cherbot/EmotesManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/EmotesManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -17,7 +17,7 @@
/**
* The emotes manager reacts on emotes.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
* @todo add timestamps to attitude changing commands, so players cannot simply fill their attitude by hugging Cherbot.
*/
@Manager.Description("CherBot can react on some emotes.")
Modified: trunk/src/net/sf/cherbot/ExampleTestCase.java
===================================================================
--- trunk/src/net/sf/cherbot/ExampleTestCase.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/ExampleTestCase.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -11,7 +11,7 @@
/**
* Class for a single Test Case that checks an example String against a regular expression.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public final class ExampleTestCase extends TestCase {
// Let not override this class, it wouldn't work as expected because runTest() has changed very much.
Modified: trunk/src/net/sf/cherbot/ExampleTester.java
===================================================================
--- trunk/src/net/sf/cherbot/ExampleTester.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/ExampleTester.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -12,7 +12,7 @@
/**
* Class that tests wether the examples given on the Commands really match the regular expressions.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public final class ExampleTester extends TestSuite {
Modified: trunk/src/net/sf/cherbot/GreetingsManager.java
===================================================================
--- trunk/src/net/sf/cherbot/GreetingsManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/GreetingsManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -12,7 +12,7 @@
/**
* Class to manage greetings.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("Greets players as soon as they enter, works like a kind of \"CherBot Sonar\" - you enter and instantly know wether CherBot is online.")
@Manager.Features({
Modified: trunk/src/net/sf/cherbot/GroupManager.java
===================================================================
--- trunk/src/net/sf/cherbot/GroupManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/GroupManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -24,7 +24,7 @@
/**
* Manager for groups.
* If the mail manager is installed, messages can be sent to all members of a group as well.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("The GroupManager managers groups of players. Please read this carefully: Every modern RPG is very likely to get a really good clan feature of its own. The GroupManager in Cherbot is in no way a replacement for a good clan feature. It's only an interesting feature for testing what commands a magic clan secretary would have to understand. It's very likely that this feature will get removed from CherBot one day.")
@Manager.Features({ "Apply for group creation", "Manage a group", "Manage the status of group members", "Invite players to a group", "Confirm group membership", "Send messages to all members of a group" })
@@ -465,7 +465,7 @@
/**
* A Group.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
private static class Group implements Serializable {
@@ -1186,7 +1186,7 @@
/**
* A member.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
private class Member implements Serializable {
@@ -1307,7 +1307,7 @@
/**
* Member state.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
private enum State {
Modified: trunk/src/net/sf/cherbot/LamentsManager.java
===================================================================
--- trunk/src/net/sf/cherbot/LamentsManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/LamentsManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -13,7 +13,7 @@
/**
* Class to manage laments killings.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("You can have Cherbot lament you or other players when they die.")
@Manager.Features({
Modified: trunk/src/net/sf/cherbot/MailManager.java
===================================================================
--- trunk/src/net/sf/cherbot/MailManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/MailManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -21,7 +21,7 @@
/**
* Mail Manager.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("This manager allows players to leave a message for other players.")
@Manager.Features({
@@ -37,7 +37,7 @@
/**
* Mail.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
private class Mail implements Comparable<Mail> {
Modified: trunk/src/net/sf/cherbot/Manager.java
===================================================================
--- trunk/src/net/sf/cherbot/Manager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/Manager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -54,7 +54,7 @@
* Synchronization of methods is not neccessary. The bot has basically only two threads, which could run on a single group of Manager instances. It's
* the bot's task to synchronize access to Managers for these Threads. Also, that's the reason why it's possible to globally know who the current actor
* is.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
* @todo move some Permission handling to this class to make it possible to list the permissions supported by the manager and to warn on unknown
* permissions in CherBotSecurityManager
*/
@@ -522,7 +522,7 @@
* A command understood by the bot.
* It is basically a regular expression, a method ({@link Command#perform(String)} that checks for the regular expression and invokes another
* method ({@link Command#performImpl()}) if the regular expression matches.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
* @todo eventually move permission handling here, that would probably be more secure and it would be more informative because a centralized
* interface for querying the required permissions would be available.
* Note: a single Command instance is <em>not thread-safe</em>.
@@ -666,7 +666,7 @@
/**
* An Loader module.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public abstract class IOModule {
@@ -696,7 +696,7 @@
/**
* A Text file loader / saver module.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
* @todo think about making three classes out of this: add two inner classes for not mixing up load and save.
*/
public abstract class AbstractTextIOModule<Data> extends IOModule implements Iterable<Data> {
@@ -794,7 +794,7 @@
/**
* Class for IO using text.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
protected abstract class TextIOModule extends AbstractTextIOModule<String> {
@@ -838,7 +838,7 @@
/**
* Iterator for reading input lines.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
private class ReadIterator implements Iterator<String> {
@@ -905,7 +905,7 @@
/**
* Class for IO using regular expression patterns.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
protected abstract class RegexIOModule extends AbstractTextIOModule<Matcher> {
@@ -961,7 +961,7 @@
/**
* Iterator for matching input lines.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
private class MatcherIterator implements Iterator<Matcher> {
@@ -1032,7 +1032,7 @@
/**
* IOModule for loading / saving a collection.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
protected final class CollectionIOModule extends TextIOModule {
@@ -1084,7 +1084,7 @@
/**
* Converter used by MapIOMOdule.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
protected static abstract class Converter<ValueType> {
@@ -1171,7 +1171,7 @@
/**
* Converter for Enums.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
protected static class EnumConverter<En extends Enum> extends Converter<En> {
@@ -1206,7 +1206,7 @@
/**
* IOModule for loading / saving a Map.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
protected final class MapIOModule<ValueType> extends RegexIOModule {
@@ -1293,7 +1293,7 @@
/**
* Annotation for Description of Commands.
* Use this annotation to annotate a Command's performImpl method.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Retention(RUNTIME)
@Target({ METHOD, TYPE })
@@ -1311,7 +1311,7 @@
/**
* Annotation for Examples of Commands.
* Use this annotation to annotate a Command's performImpl method.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Retention(RUNTIME)
@Target({ METHOD })
@@ -1328,7 +1328,7 @@
/**
* Annotation to document the permission required to execute a command.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Retention(RUNTIME)
@Target({ METHOD })
@@ -1344,7 +1344,7 @@
/**
* Annotatin to document the features of a module / Manager
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Retention(RUNTIME)
@Target({ TYPE })
Modified: trunk/src/net/sf/cherbot/ManagerDocumenter.java
===================================================================
--- trunk/src/net/sf/cherbot/ManagerDocumenter.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/ManagerDocumenter.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -16,7 +16,7 @@
/**
* Extracts the documentation from a Manager and writes it to an XML file for further processing.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class ManagerDocumenter {
Modified: trunk/src/net/sf/cherbot/NoSuchPlayerException.java
===================================================================
--- trunk/src/net/sf/cherbot/NoSuchPlayerException.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/NoSuchPlayerException.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -8,7 +8,7 @@
/**
* RuntimeException that is thrown if a player is used but not known to CherBot.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class NoSuchPlayerException extends CherBotException {
Modified: trunk/src/net/sf/cherbot/NoobManager.java
===================================================================
--- trunk/src/net/sf/cherbot/NoobManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/NoobManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -14,7 +14,7 @@
/**
* Manages some Noob help.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("This module manages some information that's interesting especially for newbies.")
@Manager.Features({
Modified: trunk/src/net/sf/cherbot/PlayerManager.java
===================================================================
--- trunk/src/net/sf/cherbot/PlayerManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/PlayerManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -32,7 +32,7 @@
* It keeps track of players.
* It can be asked if he knows a player.
* Also it can be asked what level a certain player has.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
* @todo tell when a player was last seen online.
*/
@Manager.Description("Manages overall player information. Keeps track of player names, so everywhere you insert a player name in a command, CherBot can make sure that the player name is correct. Also keeps track of all player's levels and manages a ranking. Detects after a while that a player levelled and can congratulate on this.")
@@ -865,7 +865,7 @@
/**
* Enum for genders.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
private static enum Gender {
Modified: trunk/src/net/sf/cherbot/PollManager.java
===================================================================
--- trunk/src/net/sf/cherbot/PollManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/PollManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -31,7 +31,7 @@
* A Poll has a unique number to distinguish the poll from others, a title and a text.
* Also, a Poll has a number of votes each player can give.
* For a Poll, at least two Choices exist, each with a choice index number (starting at 1 per Poll) and a text.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("With the poll manager, you can manage and run polls.")
@Manager.Features({
@@ -321,7 +321,7 @@
/**
* The state of a poll.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
private static enum PollState {
@@ -334,7 +334,7 @@
* Design question: It could be possible to a) store each player with its vote or b) store a vote count for each choice and a set of players that
* voted.
* I chose b) because it is closer to real elections and anonymous.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
private class Poll implements Comparable<Poll> {
Modified: trunk/src/net/sf/cherbot/RodBabyManager.java
===================================================================
--- trunk/src/net/sf/cherbot/RodBabyManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/RodBabyManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -11,7 +11,7 @@
/**
* A manager to keep track of rod babies.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("This module manages a black list of rod babies. For most players of no interest, requested feature by some players. A rod baby is a user with magic devices as main skill and unbalanced other skills. A rod baby is a player whose main level is magic devices, where the magic devices level outlevels all other skill levels by far and who still nearly only kills with a rod, horn or heavy rod. Some hlps don't like rod babies.")
@Manager.Features({
Modified: trunk/src/net/sf/cherbot/RodBabyWannabeManager.java
===================================================================
--- trunk/src/net/sf/cherbot/RodBabyWannabeManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/RodBabyWannabeManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -11,7 +11,7 @@
/**
* A manager to keep track of rod baby wannabes.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("This module manages a black list of rod baby wannabes. For most players of no interest, requested feature by some players. A rod baby wannabe is a user who wants to become a rod baby and begs for rods and horns.")
@Manager.Features({
Modified: trunk/src/net/sf/cherbot/SalesManager.java
===================================================================
--- trunk/src/net/sf/cherbot/SalesManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/SalesManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -12,7 +12,7 @@
import java.util.regex.Matcher;
/**
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("Allows to place sales adds.")
@Manager.Features({
@@ -29,7 +29,7 @@
/**
* Entry.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
private static class Entry {
Modified: trunk/src/net/sf/cherbot/SmutException.java
===================================================================
--- trunk/src/net/sf/cherbot/SmutException.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/SmutException.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -8,7 +8,7 @@
/**
* Exception that is thrown if someone uses smut.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class SmutException extends SecurityException {
Modified: trunk/src/net/sf/cherbot/SmutManager.java
===================================================================
--- trunk/src/net/sf/cherbot/SmutManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/SmutManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -12,7 +12,7 @@
/**
* SmutManager: manages a list of regular expressions that are not allowed.
- * @author $Author: chris $
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("Cherbot manages a list of regular expressions to censor itself.")
@Manager.Features({
Modified: trunk/src/net/sf/cherbot/TestManager.java
===================================================================
--- trunk/src/net/sf/cherbot/TestManager.java 2006-10-28 22:58:11 UTC (rev 18)
+++ trunk/src/net/sf/cherbot/TestManager.java 2006-10-28 23:03:23 UTC (rev 19)
@@ -11,7 +11,7 @@
/**
* Test Manager.
- * @author $Author: chris $
...
[truncated message content] |
|
From: <chr...@us...> - 2006-10-29 00:19:32
|
Revision: 28
http://svn.sourceforge.net/cherbot/?rev=28&view=rev
Author: christianhujer
Date: 2006-10-28 17:19:13 -0700 (Sat, 28 Oct 2006)
Log Message:
-----------
Optimized imports.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/ExampleTestCase.java
trunk/src/net/sf/cherbot/ExampleTester.java
trunk/src/net/sf/cherbot/Manager.java
Modified: trunk/src/net/sf/cherbot/ExampleTestCase.java
===================================================================
--- trunk/src/net/sf/cherbot/ExampleTestCase.java 2006-10-29 00:11:57 UTC (rev 27)
+++ trunk/src/net/sf/cherbot/ExampleTestCase.java 2006-10-29 00:19:13 UTC (rev 28)
@@ -7,7 +7,7 @@
package net.sf.cherbot;
import java.util.regex.Pattern;
-import junit.framework.*;
+import junit.framework.TestCase;
/**
* Class for a single Test Case that checks an example String against a regular expression.
Modified: trunk/src/net/sf/cherbot/ExampleTester.java
===================================================================
--- trunk/src/net/sf/cherbot/ExampleTester.java 2006-10-29 00:11:57 UTC (rev 27)
+++ trunk/src/net/sf/cherbot/ExampleTester.java 2006-10-29 00:19:13 UTC (rev 28)
@@ -8,7 +8,9 @@
import java.lang.reflect.Method;
import java.util.Enumeration;
-import junit.framework.*;
+import junit.framework.Test;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
/**
* Class that tests wether the examples given on the Commands really match the regular expressions.
Modified: trunk/src/net/sf/cherbot/Manager.java
===================================================================
--- trunk/src/net/sf/cherbot/Manager.java 2006-10-29 00:11:57 UTC (rev 27)
+++ trunk/src/net/sf/cherbot/Manager.java 2006-10-29 00:19:13 UTC (rev 28)
@@ -17,6 +17,7 @@
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.Target;
+import java.security.Permission;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -26,7 +27,6 @@
import java.util.NoSuchElementException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.security.Permission;
/**
* Base class for managers.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2006-10-29 13:50:05
|
Revision: 31
http://svn.sourceforge.net/cherbot/?rev=31&view=rev
Author: christianhujer
Date: 2006-10-29 05:49:33 -0800 (Sun, 29 Oct 2006)
Log Message:
-----------
Some code cleanup. Removed several warnings.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/BlackListManager.java
trunk/src/net/sf/cherbot/CherBotLogger.java
trunk/src/net/sf/cherbot/CherBotSecurityManager.java
trunk/src/net/sf/cherbot/CollectionsManager.java
trunk/src/net/sf/cherbot/Crime.java
trunk/src/net/sf/cherbot/CrimeManager.java
trunk/src/net/sf/cherbot/DummyManagerProxy.java
trunk/src/net/sf/cherbot/EmotesManager.java
trunk/src/net/sf/cherbot/ExampleTestCase.java
trunk/src/net/sf/cherbot/ExampleTester.java
trunk/src/net/sf/cherbot/GroupManager.java
trunk/src/net/sf/cherbot/MailManager.java
trunk/src/net/sf/cherbot/Manager.java
trunk/src/net/sf/cherbot/PlayerManager.java
trunk/src/net/sf/cherbot/PollManager.java
trunk/src/net/sf/cherbot/SalesManager.java
trunk/src/net/sf/cherbot/SmutManager.java
Modified: trunk/src/net/sf/cherbot/BlackListManager.java
===================================================================
--- trunk/src/net/sf/cherbot/BlackListManager.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/BlackListManager.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -105,6 +105,7 @@
/**
* Checks wether a player is blacklisted.
* @param player Player to check
+ * @return <code>true</code> if <var>player</var> is blacklisted, otherwise <code>false</code>.
*/
public boolean isBlacklisted(final String player) {
return blacklist.contains(player);
@@ -112,6 +113,7 @@
/**
* Checks wether the actor is blacklisted.
+ * @return <code>true</code> if the actor is blacklisted, otherwise <code>false</code>.
*/
public boolean isBlacklisted() {
return blacklist.contains(getActor());
Modified: trunk/src/net/sf/cherbot/CherBotLogger.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBotLogger.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/CherBotLogger.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -23,6 +23,7 @@
/**
* Create a logger.
+ * @throws IOException in case of I/O problems during logger creation.
*/
@SuppressWarnings({ "IOResourceOpenedButNotSafelyClosed" })
public CherBotLogger() throws IOException {
Modified: trunk/src/net/sf/cherbot/CherBotSecurityManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBotSecurityManager.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/CherBotSecurityManager.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -129,6 +129,7 @@
/**
* Create the SecurityManager.
+ * @param cherBot reference to CherBot instance.
*/
public CherBotSecurityManager(final CherBot cherBot) {
super(cherBot, "security");
@@ -260,20 +261,17 @@
//} finally { try { in.close(); } catch (Exception e) { /* ignore */ } finally { in = null; }
// Binary interface:
- ObjectInputStream in = null;
try {
- in = new ObjectInputStream(new FileInputStream("security.dat"));
- permissions = (Map<String, Permissions>) in.readObject();
- } catch (ClassNotFoundException e) {
- final IOException ioe = new IOException("Error with file \"security.dat\":");
- ioe.initCause(e);
- throw ioe;
- } finally {
+ final ObjectInputStream in = new ObjectInputStream(new FileInputStream("security.dat"));
try {
+ permissions = (Map<String, Permissions>) in.readObject();
+ } finally {
in.close();
- } catch (Exception e) { /* ignore */ } finally {
- in = null;
}
+ } catch (final ClassNotFoundException e) {
+ final IOException ioe = new IOException("Error with file \"security.dat\":");
+ ioe.initCause(e);
+ throw ioe;
}
}
@@ -301,16 +299,11 @@
//} finally { try { out.close(); } catch (Exception e) { /* ignore */ } finally { in = null; }
// Binary interface:
- ObjectOutputStream out = null;
+ final ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("security.dat"));
try {
- out = new ObjectOutputStream(new FileOutputStream("security.dat"));
out.writeObject(permissions);
} finally {
- try {
- out.close();
- } catch (Exception e) { /* ignore */ } finally {
- out = null;
- }
+ out.close();
}
}
Modified: trunk/src/net/sf/cherbot/CollectionsManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CollectionsManager.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/CollectionsManager.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -80,10 +80,10 @@
/**
* {@inheritDoc}
*/
- public int compareTo(final Entry e) {
- int ret = collector.compareTo(e.collector);
+ public int compareTo(final Entry o) {
+ int ret = collector.compareTo(o.collector);
if (ret == 0) {
- ret = collectable.compareTo(e.collectable);
+ ret = collectable.compareTo(o.collectable);
}
return ret;
}
Modified: trunk/src/net/sf/cherbot/Crime.java
===================================================================
--- trunk/src/net/sf/cherbot/Crime.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/Crime.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -24,15 +24,15 @@
this.crimetype = crimetype;
}
- public boolean equals(final Object o) {
- if (o == null || !(o instanceof Crime)) {
+ @Override public boolean equals(final Object obj) {
+ if (obj == null || !(obj instanceof Crime)) {
return false;
}
- Crime c = (Crime) o;
+ Crime c = (Crime) obj;
return c.criminal.equals(criminal) && c.crimetype.equals(crimetype);
}
- public int hashCode() {
+ @Override public int hashCode() {
return criminal.hashCode() ^ crimetype.hashCode();
}
Modified: trunk/src/net/sf/cherbot/CrimeManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CrimeManager.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/CrimeManager.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -166,7 +166,7 @@
//
/**
- * ...
+ * @param cherBot reference to CherBot.
*/
public CrimeManager(final CherBot cherBot) {
super(cherBot, "crimes");
Modified: trunk/src/net/sf/cherbot/DummyManagerProxy.java
===================================================================
--- trunk/src/net/sf/cherbot/DummyManagerProxy.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/DummyManagerProxy.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -22,6 +22,7 @@
/**
* Create a DummyManager.
* @param cherBot CherBot to create DummyManager for
+ * @param managers Managers to register
*/
public DummyManagerProxy(final CherBot cherBot, final Manager... managers) {
super(cherBot, "dummy");
Modified: trunk/src/net/sf/cherbot/EmotesManager.java
===================================================================
--- trunk/src/net/sf/cherbot/EmotesManager.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/EmotesManager.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -215,14 +215,9 @@
} // Commands
/**
- * The current matcher. Create an EmotesManager.
+ * Create an EmotesManager.
* @param cherBot CherBot
- * Create an EmotesManager.
- * @param cherBot CherBot
*/
- /** Create an EmotesManager.
- * @param cherBot CherBot
- */
public EmotesManager(final CherBot cherBot) {
super(cherBot, "emotes");
for (String pat : patternTexts) {
Modified: trunk/src/net/sf/cherbot/ExampleTestCase.java
===================================================================
--- trunk/src/net/sf/cherbot/ExampleTestCase.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/ExampleTestCase.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -53,15 +53,17 @@
/**
* {@inheritDoc}
*/
- @Override public void setUp() {
+ @Override public void setUp() throws Exception {
+ super.setUp();
pat = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
}
/**
* {@inheritDoc}
*/
- @Override public void tearDown() {
+ @Override public void tearDown() throws Exception {
pat = null;
+ super.tearDown();
}
/**
Modified: trunk/src/net/sf/cherbot/ExampleTester.java
===================================================================
--- trunk/src/net/sf/cherbot/ExampleTester.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/ExampleTester.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -29,6 +29,7 @@
/**
* Create a TestSuite for Cherbot.
* @param cherbot CherBot to create TestSuite for
+ * @return TestSuite for CherBot
*/
public static TestSuite createSuite(final CherBot cherbot) {
final TestSuite suite = new ExampleTester();
Modified: trunk/src/net/sf/cherbot/GroupManager.java
===================================================================
--- trunk/src/net/sf/cherbot/GroupManager.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/GroupManager.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -386,44 +386,43 @@
* List the groups for the Wiki.
*/
private void listGroupsForWiki() {
- PrintWriter out = null;
try {
- out = new PrintWriter("groupsForWiki.wiki", "iso-8859-1");
- out
- .append("This list is Cherbot's list of clans found on damn.\n\n")
- .append("If you want to found a clan yourself, read the Clan forum sticky [Clan registry (\"How do I start my own clan?\")|http://www.daimonin.net/index.php?name=PNphpBB2&file=viewtopic&t=665]\n\n")
- .append("|__Name__|__Size__|__Founder__\n")
- ;
- for (final String name : new TreeSet<String>(groups.keySet())) {
- final Group group = groups.get(name);
- if (group.isVisible()) {
- out
- .append('|')
- .append(wikiFix(group.name))
- .append('|')
- .append(Integer.toString(group.getMemberCount()))
- .append('|')
- .append(wikiFix(group.founder))
- .append('\n')
- ;
- }
- }
- out.append("\nNote: The list taken from Cherbot. Please do not modify this page since it is auto-generated. Your changes are likely to be overwritten with the next clan update. For complaints, send a pm to Cheristheus.\n");
- } catch (IOException e) {
- answer(e.toString());
- } finally {
+ final PrintWriter out = new PrintWriter("groupsForWiki.wiki", "iso-8859-1");
try {
+ out
+ .append("This list is Cherbot's list of clans found on damn.\n\n")
+ .append("If you want to found a clan yourself, read the Clan forum sticky [Clan registry (\"How do I start my own clan?\")|http://www.daimonin.net/index.php?name=PNphpBB2&file=viewtopic&t=665]\n\n")
+ .append("|__Name__|__Size__|__Founder__\n")
+ ;
+ for (final String name : new TreeSet<String>(groups.keySet())) {
+ final Group group = groups.get(name);
+ if (group.isVisible()) {
+ out
+ .append('|')
+ .append(escapeForWiki(group.name))
+ .append('|')
+ .append(Integer.toString(group.getMemberCount()))
+ .append('|')
+ .append(escapeForWiki(group.founder))
+ .append('\n')
+ ;
+ }
+ }
+ out.append("\nNote: The list taken from Cherbot. Please do not modify this page since it is auto-generated. Your changes are likely to be overwritten with the next clan update. For complaints, send a pm to Cheristheus.\n");
+ } finally {
out.close();
- } catch (Exception e) { /* ignore */ } finally {
- out = null;
}
+ } catch (final IOException e) {
+ answer(e.toString());
}
}
/**
- * Fix a String for the Wiki.
+ * Escape a String for the Wiki.
+ * @param s String to escape
+ * @return String escaped for Wiki
*/
- private static String wikiFix(final String s) {
+ private static String escapeForWiki(final String s) {
return s.replaceAll("(\\b[A-Z]\\w+[A-Z])", "!$1");
}
@@ -491,7 +490,7 @@
}
return ret;
}
- }
+ } // class MemberRankComparator
/**
* The manager of this Group.
@@ -597,10 +596,7 @@
*/
private boolean isAdmin() {
final Member member = members.get(manager.getActor());
- if (member == null) {
- return false;
- }
- return member.isAdmin();
+ return member != null && member.isAdmin();
}
/**
@@ -609,10 +605,7 @@
*/
private boolean isSender() {
final Member member = members.get(manager.getActor());
- if (member == null) {
- return false;
- }
- return member.isAdmin() || member.isSender();
+ return member != null && (member.isAdmin() || member.isSender());
}
/**
@@ -873,6 +866,7 @@
/**
* Returns wether the player applied for membership in this group.
+ * @param player Player to check whether he's an applicant
* @return <code>true</code> if the player applied for membership in this group
*/
boolean isApplicant(final String player) {
@@ -890,6 +884,7 @@
/**
* Return wether the player was invited to membership in this group.
+ * @param player Player to check whether he's an invitee
* @return <code>true</code> if the player was invited to membership in this group
*/
boolean isInvitee(final String player) {
@@ -1096,6 +1091,7 @@
/**
* Send message to all members.
+ * @param msg Message to send
*/
private void dispatch(final String msg) {
checkMaySend();
@@ -1109,6 +1105,9 @@
/**
* Implementation for deserialization:
* Take care about newly added fields
+ * @param stream Stream to deserialize with
+ * @throws IOException in case of I/O problems during deserialization
+ * @throws ClassNotFoundException in case a class required for deserialization was not found
*/
private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
@@ -1153,7 +1152,7 @@
return false;
}
final Group other = (Group) obj;
- return other.name != null ? other.name.equals(name) : false;
+ return other.name != null && other.name.equals(name);
}
/**
@@ -1374,24 +1373,21 @@
@Override public void load() throws IOException {
// Text interface: TODO
// Binary interface:
- ObjectInputStream in = null;
try {
// The groups are completely restored, not merged on load. This is intentional.
- in = new ObjectInputStream(new FileInputStream("groups.dat"));
- groups = (Map<String, Group>) in.readObject();
- for (Map.Entry<String, Group> entry : groups.entrySet()) {
- entry.getValue().manager = this;
+ final ObjectInputStream in = new ObjectInputStream(new FileInputStream("groups.dat"));
+ try {
+ groups = (Map<String, Group>) in.readObject();
+ for (Map.Entry<String, Group> entry : groups.entrySet()) {
+ entry.getValue().manager = this;
+ }
+ } finally {
+ in.close();
}
- } catch (ClassNotFoundException e) {
+ } catch (final ClassNotFoundException e) {
final IOException ioe = new IOException("Error with file \"groups.dat\":");
ioe.initCause(e);
throw ioe;
- } finally {
- try {
- in.close();
- } catch (Exception e) { /* ignore */ } finally {
- in = null;
- }
}
}
@@ -1401,16 +1397,11 @@
@Override public void save() throws IOException {
// Text interface (loading is unfinished):
// Binary interface:
- ObjectOutputStream out = null;
+ final ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("groups.dat"));
try {
- out = new ObjectOutputStream(new FileOutputStream("groups.dat"));
out.writeObject(groups);
} finally {
- try {
- out.close();
- } catch (Exception e) { /* ignore */ } finally {
- out = null;
- }
+ out.close();
}
}
Modified: trunk/src/net/sf/cherbot/MailManager.java
===================================================================
--- trunk/src/net/sf/cherbot/MailManager.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/MailManager.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -289,6 +289,7 @@
/**
* Checks wether someone has unread mail.
* @param who who has mail
+ * @return <code>true</code> in case <var>who</var> has unread mail, otherwise <code>false</code>.
*/
private boolean hasUnreadMail(final String who) {
final List<Mail> ms = mails.get(who);
@@ -306,6 +307,7 @@
/**
* Checks wether someone has mail.
* @param who who has mail
+ * @return <code>true</code> in case <var>who</var> has mail, otherwise <code>false</code>.
*/
private boolean hasMail(final String who) {
final List<Mail> ms = mails.get(who);
@@ -316,6 +318,7 @@
* Gets a mail.
* @param n number of mail to get
* @throws CherBotException if no such mail
+ * @return mail number <var>n</var> for the actor.
*/
private Mail getMail(final int n) {
try {
@@ -361,9 +364,9 @@
/**
* Send mail.
- * @param from
- * @param to
- * @param msg
+ * @param from Sender
+ * @param to Receiver
+ * @param msg Message body
*/
@Override public void mail(final String from, final String to, final String msg) {
new Mail(from, to, msg);
Modified: trunk/src/net/sf/cherbot/Manager.java
===================================================================
--- trunk/src/net/sf/cherbot/Manager.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/Manager.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -229,10 +229,7 @@
return false;
} // Return false since if not keeping track better treat noone as logged in
assert playerManager != this : "A Manager for \"players\" must override Manager.player(String)!";
- if (playerManager == this) {
- return false;
- } // simply return if assertions aren't enabled, to avoid endless recursion
- return playerManager.isLoggedIn(player);
+ return playerManager != this && playerManager.isLoggedIn(player);
}
/**
@@ -1013,7 +1010,7 @@
} finally {
try {
line = reader().readLine();
- } catch (IOException e) {
+ } catch (final IOException e) {
line = null;
this.e = e;
}
@@ -1067,7 +1064,7 @@
if (clearBeforeLoading) {
col.clear();
}
- for (String line : this) {
+ for (final String line : this) {
col.add(line);
}
}
@@ -1076,7 +1073,7 @@
* {@inheritDoc}
*/
@Override protected final void saveImpl() {
- for (String line : col) {
+ for (final String line : col) {
println(line);
}
}
Modified: trunk/src/net/sf/cherbot/PlayerManager.java
===================================================================
--- trunk/src/net/sf/cherbot/PlayerManager.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/PlayerManager.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -869,7 +869,7 @@
*/
private static enum Gender {
- male, female;
+ MALE, FEMALE
}
} // class LevelManager
Modified: trunk/src/net/sf/cherbot/PollManager.java
===================================================================
--- trunk/src/net/sf/cherbot/PollManager.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/PollManager.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -282,18 +282,13 @@
* {@inheritDoc}
*/
@Override public void save() throws IOException {
- PrintWriter out = null;
+ final PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream("polls.txt")));
try {
- out = new PrintWriter(new OutputStreamWriter(new FileOutputStream("polls.txt")));
- for (Poll poll : polls) {
+ for (final Poll poll : polls) {
poll.writeTo(out);
}
} finally {
- try {
- out.close();
- } catch (Exception e) { /* ignore */ } finally {
- out = null;
- }
+ out.close();
}
}
@@ -301,20 +296,15 @@
* {@inheritDoc}
*/
@Override public void load() throws IOException {
- BufferedReader in = null;
+ BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("polls.txt")));
try {
- in = new BufferedReader(new InputStreamReader(new FileInputStream("polls.txt")));
- try {
- while (polls.add(new Poll(in))) {
- ;
- }
- } catch (NullPointerException e) { /* ignore */ }
- } finally {
- try {
- in.close();
- } catch (Exception e) { /* ignore */ } finally {
- in = null;
+ while (polls.add(new Poll(in))) {
+ ;
}
+ } catch (final NullPointerException e) {
+ /* ignore */
+ } finally {
+ in.close();
}
}
Modified: trunk/src/net/sf/cherbot/SalesManager.java
===================================================================
--- trunk/src/net/sf/cherbot/SalesManager.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/SalesManager.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -133,7 +133,7 @@
/**
* List the sellers that sell a specific ware.
- * @param ware
+ * @param ware Ware to sell
*/
private void listSellers(final String ware) {
final Set<String> sellers = new TreeSet<String>();
Modified: trunk/src/net/sf/cherbot/SmutManager.java
===================================================================
--- trunk/src/net/sf/cherbot/SmutManager.java 2006-10-29 13:13:32 UTC (rev 30)
+++ trunk/src/net/sf/cherbot/SmutManager.java 2006-10-29 13:49:33 UTC (rev 31)
@@ -129,6 +129,7 @@
/**
* Remove a pattern to the list of smut patterns.
* @param pattern pattern to remove
+ * @return whether remove was successful
*/
public boolean remove(final String pattern) {
return patterns.remove(Pattern.compile(pattern));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2006-10-29 14:03:13
|
Revision: 32
http://svn.sourceforge.net/cherbot/?rev=32&view=rev
Author: christianhujer
Date: 2006-10-29 06:02:55 -0800 (Sun, 29 Oct 2006)
Log Message:
-----------
Declared exception variables final, improved some I/O code.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/CherBot.java
trunk/src/net/sf/cherbot/CherBotSecurityManager.java
trunk/src/net/sf/cherbot/EmotesManager.java
trunk/src/net/sf/cherbot/ExampleTester.java
trunk/src/net/sf/cherbot/MailManager.java
trunk/src/net/sf/cherbot/Manager.java
trunk/src/net/sf/cherbot/ManagerDocumenter.java
trunk/src/net/sf/cherbot/NoobManager.java
trunk/src/net/sf/cherbot/PlayerManager.java
trunk/src/net/sf/cherbot/PollManager.java
trunk/src/net/sf/cherbot/TimeManager.java
Modified: trunk/src/net/sf/cherbot/CherBot.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBot.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/CherBot.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -378,7 +378,7 @@
private static void switchColor(final int n) {
try {
System.out.print(colors[n]);
- } catch (ArrayIndexOutOfBoundsException e) {
+ } catch (final ArrayIndexOutOfBoundsException e) {
System.err.println("Unknown color number: " + n);
}
}
@@ -440,9 +440,9 @@
break;
}
}
- } catch (CherBotException e) {
+ } catch (final CherBotException e) {
answer("I can't: " + e.getMessage());
- } catch (SecurityException e) {
+ } catch (final SecurityException e) {
answer("I don't want to: " + e.getMessage());
}
}
@@ -515,7 +515,7 @@
try {
save();
answer("Saved all modules.");
- } catch (Exception e) {
+ } catch (final Exception e) {
answer("Save failed: " + e);
}
}
@@ -529,9 +529,9 @@
try {
managerMap.get(module).save();
answer("Saved module " + module + '.');
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
answer("No such module.");
- } catch (Exception e) {
+ } catch (final Exception e) {
answer("Error while saving module " + module + ": " + e);
}
}
@@ -544,7 +544,7 @@
try {
load();
answer("Loaded.");
- } catch (Exception e) {
+ } catch (final Exception e) {
answer("Save failed: " + e);
}
}
@@ -558,9 +558,9 @@
try {
managerMap.get(module).load();
answer("Loaded module " + module + '.');
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
answer("No such module.");
- } catch (Exception e) {
+ } catch (final Exception e) {
answer("Error while loading module " + module + ": " + e);
}
}
@@ -758,22 +758,19 @@
* What's new.
*/
private void whatsNew() {
- BufferedReader in = null;
try {
- in = new BufferedReader(new InputStreamReader(new FileInputStream("news.txt")));
- final StringBuilder sb = new StringBuilder();
- for (String line; (line = in.readLine()) != null; sb.append(line).append('\n')) {
- ;
- }
- answer(sb.toString());
- } catch (IOException e) {
- answer("No news available.");
- } finally {
+ final BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("news.txt")));
try {
+ final StringBuilder sb = new StringBuilder();
+ for (String line; (line = in.readLine()) != null; sb.append(line).append('\n')) {
+ ;
+ }
+ answer(sb.toString());
+ } finally {
in.close();
- } catch (Exception e) { /* ignore */ } finally {
- in = null;
}
+ } catch (final IOException e) {
+ answer("No news available.");
}
}
@@ -784,7 +781,7 @@
if (manager != InternalManager.this) {
try {
manager.save();
- } catch (Exception e) {
+ } catch (final Exception e) {
System.err.println("Error while saving data from module " + manager.getTopic() + ": " + e);
e.printStackTrace();
}
@@ -797,7 +794,7 @@
if (manager != InternalManager.this) {
try {
manager.load();
- } catch (Exception e) {
+ } catch (final Exception e) {
System.err.println("Error while loading data for module " + manager.getTopic() + ": " + e);
e.printStackTrace();
}
Modified: trunk/src/net/sf/cherbot/CherBotSecurityManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBotSecurityManager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/CherBotSecurityManager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -256,9 +256,9 @@
// for (String line; (line = in.readLine) != null;) {
// // TODO
// }
- //} catch (IOException e) {
+ //} catch (final IOException e) {
// System.err.println(e);
- //} finally { try { in.close(); } catch (Exception e) { /* ignore */ } finally { in = null; }
+ //} finally { try { in.close(); } catch (final Exception e) { /* ignore */ } finally { in = null; }
// Binary interface:
try {
@@ -294,9 +294,9 @@
// }
// out.println();
// }
- //} catch (IOException e) {
+ //} catch (final IOException e) {
// System.err.println(e);
- //} finally { try { out.close(); } catch (Exception e) { /* ignore */ } finally { in = null; }
+ //} finally { try { out.close(); } catch (final Exception e) { /* ignore */ } finally { in = null; }
// Binary interface:
final ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("security.dat"));
Modified: trunk/src/net/sf/cherbot/EmotesManager.java
===================================================================
--- trunk/src/net/sf/cherbot/EmotesManager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/EmotesManager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -563,7 +563,7 @@
int ranking;
try {
ranking = attitude.get(player)[0];
- } catch (Exception e) {
+ } catch (final Exception e) {
ranking = 0;
}
assert!(isLoved && isHated); // Not the best place, but if here it's only needed once.
Modified: trunk/src/net/sf/cherbot/ExampleTester.java
===================================================================
--- trunk/src/net/sf/cherbot/ExampleTester.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/ExampleTester.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -70,7 +70,7 @@
} else {
System.err.println("No examples on " + method);
}
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
assert false;
}
return suite;
Modified: trunk/src/net/sf/cherbot/MailManager.java
===================================================================
--- trunk/src/net/sf/cherbot/MailManager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/MailManager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -323,7 +323,7 @@
private Mail getMail(final int n) {
try {
return mails.get(getActor()).get(n - 1);
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new CherBotException("No such mail: " + n);
}
}
Modified: trunk/src/net/sf/cherbot/Manager.java
===================================================================
--- trunk/src/net/sf/cherbot/Manager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/Manager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -313,7 +313,7 @@
for (IOModule iomodule : iomodules) {
try {
iomodule.load();
- } catch (Exception e) {
+ } catch (final Exception e) {
if (ex == null) {
ex = e;
}
@@ -334,7 +334,7 @@
for (IOModule iomodule : iomodules) {
try {
iomodule.save();
- } catch (Exception e) {
+ } catch (final Exception e) {
if (ex == null) {
ex = e;
}
@@ -579,7 +579,7 @@
parent = clazz;
try {
return (String) clazz.getField("C_" + name).get(null);
- } catch (Exception e) {
+ } catch (final Exception e) {
ex = e;
}
clazz = clazz.getEnclosingClass();
@@ -754,7 +754,7 @@
} finally {
try {
reader.close();
- } catch (Exception e) { /* ignore */ } finally {
+ } catch (final Exception e) { /* ignore */ } finally {
reader = null;
}
}
@@ -770,7 +770,7 @@
} finally {
try {
writer.close();
- } catch (Exception e) { /* ignore */ } finally {
+ } catch (final Exception e) { /* ignore */ } finally {
writer = null;
}
}
@@ -856,7 +856,7 @@
ReadIterator() {
try {
line = readLine();
- } catch (IOException e) {
+ } catch (final IOException e) {
this.e = e;
}
}
@@ -883,7 +883,7 @@
} finally {
try {
line = readLine();
- } catch (IOException e) {
+ } catch (final IOException e) {
line = null;
this.e = e;
}
@@ -979,7 +979,7 @@
MatcherIterator() {
try {
line = reader().readLine();
- } catch (IOException e) {
+ } catch (final IOException e) {
this.e = e;
}
}
Modified: trunk/src/net/sf/cherbot/ManagerDocumenter.java
===================================================================
--- trunk/src/net/sf/cherbot/ManagerDocumenter.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/ManagerDocumenter.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -99,7 +99,7 @@
} else {
System.err.println("No examples on " + method);
}
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
assert false;
}
return ret;
Modified: trunk/src/net/sf/cherbot/NoobManager.java
===================================================================
--- trunk/src/net/sf/cherbot/NoobManager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/NoobManager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -227,7 +227,7 @@
} else {
answer("I don't know where players are. They usually don't tell me. And if they would, that information would be out of date too soon.");
}
- } catch (NoSuchPlayerException e) {
+ } catch (final NoSuchPlayerException e) {
answer("I don't know where " + topic + " is.");
}
}
@@ -256,7 +256,7 @@
try {
howtos.put(Pattern.compile(topic), text);
answer("Howto on " + topic + " successfully added.");
- } catch (PatternSyntaxException e) {
+ } catch (final PatternSyntaxException e) {
answer("I do not understand that regular expression: " + e.getMessage());
}
}
Modified: trunk/src/net/sf/cherbot/PlayerManager.java
===================================================================
--- trunk/src/net/sf/cherbot/PlayerManager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/PlayerManager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -299,7 +299,7 @@
int end = 0;
try {
end = parseInt(gr(2));
- } catch (Exception e) { /* ignore */ }
+ } catch (final Exception e) { /* ignore */ }
if (end < start) {
end = start + 9;
}
@@ -456,7 +456,7 @@
@Override public int getLevel(final String player) {
try {
return levels.get(player);
- } catch (Exception e) {
+ } catch (final Exception e) {
return 0;
}
}
@@ -476,7 +476,7 @@
try {
final long ls = lastSeen.get(player);
answer("I've last seen " + player + " at: " + dateFormat.format(new Date(ls)) + "\nMy current time is: " + dateFormat.format(new Date()));
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
answer("I don't know when " + player + " was last online.");
}
}
@@ -523,7 +523,7 @@
sb.append(highestPlayers.size() > 1 ? " all have " : " has ");
sb.append("level ").append(Integer.toString(level)).append('.');
answer(sb.toString());
- } catch (NoSuchElementException e) {
+ } catch (final NoSuchElementException e) {
answer("I don't know any levels yet.");
}
}
@@ -630,7 +630,7 @@
try {
final int level = levels.get(player);
answer(player + " is level " + level + '.');
- } catch (Exception e) {
+ } catch (final Exception e) {
answer("I don't know the level of player " + player + '.');
}
}
Modified: trunk/src/net/sf/cherbot/PollManager.java
===================================================================
--- trunk/src/net/sf/cherbot/PollManager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/PollManager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -246,7 +246,7 @@
Poll poll;
try {
poll = new Poll(polls.get(polls.size() - 1).getNumber() + 1);
- } catch (Exception e) { // first poll
+ } catch (final Exception e) { // first poll
poll = new Poll(1);
}
polls.add(poll);
@@ -508,7 +508,7 @@
try {
choices.remove(choice);
answer("Choice removed.");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
throw new CherBotException("No such choice on poll #" + number + ": " + choice + '.');
}
}
@@ -634,7 +634,7 @@
choices.add(choice);
votes.put(choice, new int[] { parseInt(matcher.group(2)) });
}
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
throw new EOFException();
}
}
Modified: trunk/src/net/sf/cherbot/TimeManager.java
===================================================================
--- trunk/src/net/sf/cherbot/TimeManager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/TimeManager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -330,7 +330,7 @@
try {
Time t = (Time) obj;
return compareTo(t) == 0;
- } catch (Exception e) {
+ } catch (final Exception e) {
return false;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2006-10-29 14:10:47
|
Revision: 33
http://svn.sourceforge.net/cherbot/?rev=33&view=rev
Author: christianhujer
Date: 2006-10-29 06:10:21 -0800 (Sun, 29 Oct 2006)
Log Message:
-----------
Declared foreach loop variables final.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/CherBot.java
trunk/src/net/sf/cherbot/CherBotSecurityManager.java
trunk/src/net/sf/cherbot/CollectionsManager.java
trunk/src/net/sf/cherbot/CrimeManager.java
trunk/src/net/sf/cherbot/DeathsManager.java
trunk/src/net/sf/cherbot/EmotesManager.java
trunk/src/net/sf/cherbot/ExampleTester.java
trunk/src/net/sf/cherbot/GreetingsManager.java
trunk/src/net/sf/cherbot/GroupManager.java
trunk/src/net/sf/cherbot/MailManager.java
trunk/src/net/sf/cherbot/Manager.java
trunk/src/net/sf/cherbot/ManagerDocumenter.java
trunk/src/net/sf/cherbot/NoobManager.java
trunk/src/net/sf/cherbot/PlayerManager.java
trunk/src/net/sf/cherbot/PollManager.java
trunk/src/net/sf/cherbot/SalesManager.java
Modified: trunk/src/net/sf/cherbot/CherBot.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBot.java 2006-10-29 14:02:55 UTC (rev 32)
+++ trunk/src/net/sf/cherbot/CherBot.java 2006-10-29 14:10:21 UTC (rev 33)
@@ -306,7 +306,7 @@
*/
public void say(final String s) {
final StringBuilder sb = new StringBuilder();
- for (String line : lineSplit(s)) {
+ for (final String line : lineSplit(s)) {
sb.setLength(0);
}
}
@@ -468,7 +468,7 @@
if (username.equals(who)) {
return;
} // avoid lamenting myself
- for (Manager manager : managers) {
+ for (final Manager manager : managers) {
manager.died(who, killer, with);
}
}
@@ -584,7 +584,7 @@
@Examples({ "List modules!", "Show modules!" })
@Override public void performImpl() {
final StringBuilder mods = new StringBuilder();
- for (Manager manager : managers) {
+ for (final Manager manager : managers) {
if (mods.length() > 0) {
mods.append(", ");
} else {
@@ -604,7 +604,7 @@
@Examples({ "List commands!", "Show commands!" })
@Override public void performImpl() {
final StringBuilder sb = new StringBuilder();
- for (Manager manager : managers) {
+ for (final Manager manager : managers) {
if (sb.length() == 0) {
sb.append("Loaded modules: ");
} else {
@@ -622,10 +622,10 @@
@Override public void performImpl() {
final String topic = matcher.group(4);
final StringBuilder sb = new StringBuilder();
- for (Manager manager : managers) {
+ for (final Manager manager : managers) {
if (topic.equals(manager.getTopic())) {
sb.append("Commands for module ").append(topic).append('\n');
- for (Command command : manager.commands()) {
+ for (final Command command : manager.commands()) {
sb.append(command.getPattern()).append('\n');
}
answer(sb.toString());
@@ -647,9 +647,9 @@
@Examples({ "Really list all commands!", "Really show me all commands!" })
@Override public void performImpl() {
final StringBuilder sb = new StringBuilder();
- for (Manager manager : managers) {
+ for (final Manager manager : managers) {
sb.append(manager.getTopic()).append('\n').append(manager.getTopic().replaceAll(".", "-")).append('\n');
- for (Command command : manager.commands()) {
+ for (final Command command : manager.commands()) {
sb.append(command.getPattern()).append('\n');
}
}
@@ -663,7 +663,7 @@
if (topic.equals("usage")) {
answer("Usage: tell me a command. You may also use shout or say but I will nearly always respond in tell. I don't want to bother other players. Use good, clear, correct, complete English sentences, that will work best. Tell me 'help commands' to find out what I understand.");
} else {
- for (Manager manager : managers) {
+ for (final Manager manager : managers) {
if (topic.equalsIgnoreCase(manager.getTopic())) {
manager.help();
}
@@ -737,7 +737,7 @@
*/
@Override public void help() {
final StringBuilder topics = new StringBuilder();
- for (Manager manager : managers) {
+ for (final Manager manager : managers) {
if (topics.length() > 0) {
topics.append(", ");
}
@@ -777,7 +777,7 @@
{ // IO Modules
new IOModule() {
@Override public void save() {
- for (Manager manager : managers) {
+ for (final Manager manager : managers) {
if (manager != InternalManager.this) {
try {
manager.save();
@@ -790,7 +790,7 @@
}
@Override public void load() {
- for (Manager manager : managers) {
+ for (final Manager manager : managers) {
if (manager != InternalManager.this) {
try {
manager.load();
Modified: trunk/src/net/sf/cherbot/CherBotSecurityManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBotSecurityManager.java 2006-10-29 14:02:55 UTC (rev 32)
+++ trunk/src/net/sf/cherbot/CherBotSecurityManager.java 2006-10-29 14:10:21 UTC (rev 33)
@@ -120,7 +120,7 @@
@Override public void performImpl() {
final SortedSet<String> players = new TreeSet<String>(nullStringComparator);
players.addAll(permissions.keySet());
- for (String player : players) {
+ for (final String player : players) {
list(player);
}
}
@@ -283,7 +283,7 @@
//PrintWriter out = null;
//try {
// out = new PrintWriter(new OutputStreamWriter(new FileOutputStream("security.txt")));
- // for (String player : permissions.keySet()) {
+ // for (final String player : permissions.keySet()) {
// if (player != null) {
// out.append(player);
// }
Modified: trunk/src/net/sf/cherbot/CollectionsManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CollectionsManager.java 2006-10-29 14:02:55 UTC (rev 32)
+++ trunk/src/net/sf/cherbot/CollectionsManager.java 2006-10-29 14:10:21 UTC (rev 33)
@@ -264,7 +264,7 @@
* Notifies all registered listeners of what the entering person collects.
*/
@Override public void entered(final String player) {
- for (String listener : listeners) {
+ for (final String listener : listeners) {
if (!player.equals(listener) && isLoggedIn(listener)) {
tellCollectablesFor(listener, player);
}
@@ -320,7 +320,7 @@
if (!isActor(collector)) {
checkPermission(PERM_COLLECT, "You are not allowed to edit somebody elses collections list.");
}
- for (String collectable : collectables) {
+ for (final String collectable : collectables) {
if (collectable.length() > 0 && collections.add(new Entry(collector, collectable))) {
answer("I now know that " + (collector.equals(getActor()) ? "you collect " : collector + " collects ") + collectable + ".");
} else {
@@ -338,7 +338,7 @@
if (!isActor(collector)) {
checkPermission(PERM_COLLECT, "You are not allowed to edit somebody elses collections list.");
}
- for (String collectable : collectables) {
+ for (final String collectable : collectables) {
if (collections.remove(new Entry(collector, collectable))) {
answer("I now know that " + (collector.equals(getActor()) ? "you don't" : collector + " doesn't") + " collect " + collectable + " anymore.");
} else {
@@ -354,7 +354,7 @@
*/
private void tellCollectablesFor(final String player, final String collector) {
final SortedSet<String> items = new TreeSet<String>();
- for (Entry e : collections) {
+ for (final Entry e : collections) {
if (e.collector.equals(collector)) {
items.add(e.collectable);
}
@@ -376,7 +376,7 @@
*/
private void listCollectablesFor(final String collector) {
final SortedSet<String> items = new TreeSet<String>();
- for (Entry e : collections) {
+ for (final Entry e : collections) {
if (e.collector.equals(collector)) {
items.add(e.collectable);
}
@@ -402,7 +402,7 @@
*/
private void listCollectorsFor(final String collectable) {
final Map<String, SortedSet<String>> col = new HashMap<String, SortedSet<String>>();
- for (Entry e : collections) {
+ for (final Entry e : collections) {
if (e.collectable.contains(collectable) || collectable.contains(e.collectable)) {
if (!col.containsKey(e.collector)) {
col.put(e.collector, new TreeSet<String>());
@@ -416,7 +416,7 @@
sb.append(collectable).append(" is/are collected by: ");
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
int i = 0;
- for (String collector : new TreeSet<String>(col.keySet())) {
+ for (final String collector : new TreeSet<String>(col.keySet())) {
sb.append(collector).append(" (");
concat(sb, col.get(collector));
sb.append(')');
@@ -440,7 +440,7 @@
*/
private void listOnlineCollectorsFor(final String collectable) {
final Map<String, SortedSet<String>> col = new HashMap<String, SortedSet<String>>();
- for (Entry e : collections) {
+ for (final Entry e : collections) {
if (e.collectable.contains(collectable) || collectable.contains(e.collectable)) {
if (isLoggedIn(e.collector)) {
if (!col.containsKey(e.collector)) {
@@ -456,7 +456,7 @@
sb.append(collectable).append(" is/are collected by: ");
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
int i = 0;
- for (String collector : new TreeSet<String>(col.keySet())) {
+ for (final String collector : new TreeSet<String>(col.keySet())) {
sb.append(collector).append(" (");
concat(sb, col.get(collector));
sb.append(')');
@@ -479,7 +479,7 @@
*/
private void listCollectors() {
final SortedSet<String> players = new TreeSet<String>();
- for (Entry e : collections) {
+ for (final Entry e : collections) {
players.add(e.collector);
}
if (players.size() > 0) {
@@ -498,7 +498,7 @@
*/
private void listOnlineCollectors() {
final SortedSet<String> players = new TreeSet<String>();
- for (Entry e : collections) {
+ for (final Entry e : collections) {
final String collector = e.collector;
if (isLoggedIn(collector)) {
players.add(collector);
@@ -520,7 +520,7 @@
*/
private void listCollectables() {
final SortedSet<String> items = new TreeSet<String>();
- for (Entry e : collections) {
+ for (final Entry e : collections) {
items.add(e.collectable);
}
if (items.size() > 0) {
@@ -557,7 +557,7 @@
{ // IO Modules
new RegexIOModule("collections.txt", "(.*?): (.*)") {
@Override protected void saveImpl() throws IOException {
- for (Entry collection : collections) {
+ for (final Entry collection : collections) {
println(collection.collector + ": " + collection.collectable);
}
}
Modified: trunk/src/net/sf/cherbot/CrimeManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CrimeManager.java 2006-10-29 14:02:55 UTC (rev 32)
+++ trunk/src/net/sf/cherbot/CrimeManager.java 2006-10-29 14:10:21 UTC (rev 33)
@@ -191,7 +191,7 @@
*/
@Override public void entered(final String player) {
final Set<String> cs = new TreeSet<String>();
- for (Crime crime : crimes.keySet()) {
+ for (final Crime crime : crimes.keySet()) {
if (crime.criminal.equals(player)) {
cs.add(crime.crimetype);
}
@@ -210,12 +210,12 @@
*/
private void listCriminals() {
final Set<String> criminals = new TreeSet<String>();
- for (Crime crime : crimes.keySet()) {
+ for (final Crime crime : crimes.keySet()) {
criminals.add(crime.criminal);
}
if (criminals.size() > 0) {
final StringBuilder sb = new StringBuilder();
- for (String criminal : criminals) {
+ for (final String criminal : criminals) {
if (sb.length() > 0) {
sb.append(", ");
}
@@ -233,7 +233,7 @@
*/
private void listCriminalsOnline() {
final Set<String> criminals = new TreeSet<String>();
- for (Crime crime : crimes.keySet()) {
+ for (final Crime crime : crimes.keySet()) {
final String criminal = crime.criminal;
if (isLoggedIn(criminal)) {
criminals.add(criminal);
@@ -241,7 +241,7 @@
}
if (criminals.size() > 0) {
final StringBuilder sb = new StringBuilder();
- for (String criminal : criminals) {
+ for (final String criminal : criminals) {
if (sb.length() > 0) {
sb.append(", ");
}
@@ -259,7 +259,7 @@
*/
private void listCrimes() {
final StringBuilder sb = new StringBuilder();
- for (Crime crime : crimes.keySet()) {
+ for (final Crime crime : crimes.keySet()) {
sb.append(crime.criminal).append(": ").append(crime.crimetype).append(" (reported by ").append(crime.reporter).append(", ").append(crimes.get(crime)[0]).append(" times)\n");
}
answer(sb.toString());
@@ -278,7 +278,7 @@
*/
private void listCrimesOf(final String criminal) {
final Set<Crime> cs = new HashSet<Crime>();
- for (Crime crime : crimes.keySet()) {
+ for (final Crime crime : crimes.keySet()) {
if (crime.criminal.equals(criminal)) {
cs.add(crime);
}
@@ -287,7 +287,7 @@
answer("I don't know of any crimes " + criminal + " could have committed.");
} else {
final StringBuilder sb = new StringBuilder();
- for (Crime crime : cs) {
+ for (final Crime crime : cs) {
if (sb.length() == 0) {
sb.append(criminal).append(" committed ");
} else {
@@ -354,7 +354,7 @@
private void listCrimeTypes() {
final StringBuilder sb = new StringBuilder();
- for (String crimetype : crimeTypes) {
+ for (final String crimetype : crimeTypes) {
if (sb.length() == 0) {
sb.append("The following actions are considered crimes: ");
} else {
@@ -376,7 +376,7 @@
}
@Override protected void saveImpl() throws IOException {
- for (Crime crime : crimes.keySet()) {
+ for (final Crime crime : crimes.keySet()) {
println(crime.criminal + ": " + crime.reporter + ": " + crimes.get(crime)[0] + ": " + crime.crimetype);
}
}
Modified: trunk/src/net/sf/cherbot/DeathsManager.java
===================================================================
--- trunk/src/net/sf/cherbot/DeathsManager.java 2006-10-29 14:02:55 UTC (rev 32)
+++ trunk/src/net/sf/cherbot/DeathsManager.java 2006-10-29 14:10:21 UTC (rev 33)
@@ -129,7 +129,7 @@
} else {
int max = 0;
final Set<String> players = new TreeSet<String>();
- for (String player : deaths.keySet()) {
+ for (final String player : deaths.keySet()) {
final int n = deaths.get(player)[0];
if (n > max) {
players.clear();
Modified: trunk/src/net/sf/cherbot/EmotesManager.java
===================================================================
--- trunk/src/net/sf/cherbot/EmotesManager.java 2006-10-29 14:02:55 UTC (rev 32)
+++ trunk/src/net/sf/cherbot/EmotesManager.java 2006-10-29 14:10:21 UTC (rev 33)
@@ -220,7 +220,7 @@
*/
public EmotesManager(final CherBot cherBot) {
super(cherBot, "emotes");
- for (String pat : patternTexts) {
+ for (final String pat : patternTexts) {
patterns.add(Pattern.compile(pat));
}
}
@@ -493,7 +493,7 @@
*/
private int countLikes() {
int likes = 0;
- for (String player : attitude.keySet()) {
+ for (final String player : attitude.keySet()) {
if (attitude.get(player)[0] > 0) {
likes++;
}
@@ -507,7 +507,7 @@
*/
private int countDislikes() {
int dislikes = 0;
- for (String player : attitude.keySet()) {
+ for (final String player : attitude.keySet()) {
if (attitude.get(player)[0] < 0) {
dislikes++;
}
Modified: trunk/src/net/sf/cherbot/ExampleTester.java
===================================================================
--- trunk/src/net/sf/cherbot/ExampleTester.java 2006-10-29 14:02:55 UTC (rev 32)
+++ trunk/src/net/sf/cherbot/ExampleTester.java 2006-10-29 14:10:21 UTC (rev 33)
@@ -33,7 +33,7 @@
*/
public static TestSuite createSuite(final CherBot cherbot) {
final TestSuite suite = new ExampleTester();
- for (Manager manager : cherbot.managers()) {
+ for (final Manager manager : cherbot.managers()) {
suite.addTest(createSuite(manager));
}
return suite;
@@ -46,7 +46,7 @@
*/
public static TestSuite createSuite(final Manager manager) {
final TestSuite suite = new TestSuite(manager.getTopic());
- for (Manager.Command command : manager.commands()) {
+ for (final Manager.Command command : manager.commands()) {
suite.addTest(createSuite(command));
}
return suite;
@@ -64,7 +64,7 @@
final Class<? extends Manager.Command> clazz = command.getClass();
final Method method = clazz.getDeclaredMethod("performImpl");
if (method.isAnnotationPresent(Manager.Examples.class)) {
- for (String example : method.getAnnotation(Manager.Examples.class).value()) {
+ for (final String example : method.getAnnotation(Manager.Examples.class).value()) {
suite.addTest(new ExampleTestCase(pattern, example));
}
} else {
Modified: trunk/src/net/sf/cherbot/GreetingsManager.java
===================================================================
--- trunk/src/net/sf/cherbot/GreetingsManager.java 2006-10-29 14:02:55 UTC (rev 32)
+++ trunk/src/net/sf/cherbot/GreetingsManager.java 2006-10-29 14:10:21 UTC (rev 33)
@@ -68,7 +68,7 @@
@Examples({ "Show all greetings.", "Tell me all greetings." })
@Override public void performImpl() {
checkPermission(PERM_LIST_GREETINGS);
- for (String player : new TreeSet<String>(greetings.keySet())) {
+ for (final String player : new TreeSet<String>(greetings.keySet())) {
answer(player + ": " + greetings.get(player));
}
}
Modified: trunk/src/net/sf/cherbot/GroupManager.java
===================================================================
--- trunk/src/net/sf/cherbot/GroupManager.java 2006-10-29 14:02:55 UTC (rev 32)
+++ trunk/src/net/sf/cherbot/GroupManager.java 2006-10-29 14:10:21 UTC (rev 33)
@@ -708,7 +708,7 @@
throw new SecurityException("This group is invisible and you don't have the required permissions to list this group's allies.");
}
final SortedSet<String> gs = new TreeSet<String>();
- for (Group g : allies) {
+ for (final Group g : allies) {
if (g.allies.contains(this)) {
gs.add(g.name);
}
@@ -819,7 +819,7 @@
final SortedSet<String> ms = new TreeSet<String>(memberRankComparator);
ms.addAll(members.keySet());
State state = null;
- for (String member : ms) {
+ for (final String member : ms) {
final State newState = members.get(member).getState();
if (newState != state) {
state = newState;
@@ -840,14 +840,14 @@
throw new SecurityException("This group is invisible and you don't have the required permissions to list this group's members.");
}
final SortedSet<String> online = new TreeSet<String>(memberRankComparator);
- for (String member : new TreeSet<String>(members.keySet())) {
+ for (final String member : new TreeSet<String>(members.keySet())) {
if (manager.isLoggedIn(member)) {
online.add(member);
}
}
if (online.size() != 0) {
final StringBuilder sb = new StringBuilder("Online members of ").append(name).append(':');
- for (String member : online) {
+ for (final String member : online) {
sb.append('\n').append(members.get(member));
}
manager.answer(sb);
@@ -1378,7 +1378,7 @@
final ObjectInputStream in = new ObjectInputStream(new FileInputStream("groups.dat"));
try {
groups = (Map<String, Group>) in.readObject();
- for (Map.Entry<String, Group> entry : groups.entrySet()) {
+ for (final Map.Entry<String, Group> entry : groups.entrySet()) {
entry.getValue().manager = this;
}
} finally {
Modified: trunk/src/net/sf/cherbot/MailManager.java
===================================================================
--- trunk/src/net/sf/cherbot/MailManager.java 2006-10-29 14:02:55 UTC (rev 32)
+++ trunk/src/net/sf/cherbot/MailManager.java 2006-10-29 14:10:21 UTC (rev 33)
@@ -278,7 +278,7 @@
tell(player, "You have mail.");
}
if (player.equals(getCherBot().getUsername())) {
- for (String to : mails.keySet()) {
+ for (final String to : mails.keySet()) {
if (isLoggedIn(to)) {
tell(to, "You have mail. Use \"/tell Cherbot read mail\" to read it.");
}
@@ -296,7 +296,7 @@
if (ms == null) {
return false;
}
- for (Mail mail : ms) {
+ for (final Mail mail : ms) {
if (!mail.read) {
return true;
}
@@ -386,8 +386,8 @@
}
@Override protected void saveImpl() {
- for (String to : mails.keySet()) {
- for (Mail mail : mails.get(to)) {
+ for (final String to : mails.keySet()) {
+ for (final Mail mail : mails.get(to)) {
println(mail.from + ": " + mail.to + ": " + mail.ts + ": " + mail.msg + ": " + mail.read);
}
}
Modified: trunk/src/net/sf/cherbot/Manager.java
===================================================================
--- trunk/src/net/sf/cherbot/Manager.java 2006-10-29 14:02:55 UTC (rev 32)
+++ trunk/src/net/sf/cherbot/Manager.java 2006-10-29 14:10:21 UTC (rev 33)
@@ -310,7 +310,7 @@
*/
public void load() throws Exception {
Exception ex = null;
- for (IOModule iomodule : iomodules) {
+ for (final IOModule iomodule : iomodules) {
try {
iomodule.load();
} catch (final Exception e) {
@@ -331,7 +331,7 @@
*/
public void save() throws Exception {
Exception ex = null;
- for (IOModule iomodule : iomodules) {
+ for (final IOModule iomodule : iomodules) {
try {
iomodule.save();
} catch (final Exception e) {
@@ -1281,7 +1281,7 @@
* {@inheritDoc}
*/
@Override protected final void saveImpl() {
- for (String key : map.keySet()) {
+ for (final String key : map.keySet()) {
println(key + ": " + conv.toString(map.get(key)));
}
}
Modified: trunk/src/net/sf/cherbot/ManagerDocumenter.java
===================================================================
--- trunk/src/net/sf/cherbot/ManagerDocumenter.java 2006-10-29 14:02:55 UTC (rev 32)
+++ trunk/src/net/sf/cherbot/ManagerDocumenter.java 2006-10-29 14:10:21 UTC (rev 33)
@@ -43,7 +43,7 @@
doc = db.newDocument();
final Element root = doc.createElement("managers");
doc.appendChild(root);
- for (Manager manager : bot.managers()) {
+ for (final Manager manager : bot.managers()) {
root.appendChild(createElement(manager));
}
ls.createLSSerializer().writeToURI(doc, args[0]);
@@ -64,13 +64,13 @@
System.err.println("No description on " + clazz);
}
if (clazz.isAnnotationPresent(Manager.Features.class)) {
- for (String feature : clazz.getAnnotation(Manager.Features.class).value()) {
+ for (final String feature : clazz.getAnnotation(Manager.Features.class).value()) {
ret.appendChild(createTextElement("feature", feature));
}
} else {
System.err.println("No feature list on " + clazz);
}
- for (Manager.Command command : manager.commands()) {
+ for (final Manager.Command command : manager.commands()) {
ret.appendChild(createElement(command));
}
return ret;
@@ -93,7 +93,7 @@
System.err.println("No description on " + method);
}
if (method.isAnnotationPresent(Manager.Examples.class)) {
- for (String example : method.getAnnotation(Manager.Examples.class).value()) {
+ for (final String example : method.getAnnotation(Manager.Examples.class).value()) {
ret.appendChild(createTextElement("example", example));
}
} else {
Modified: trunk/src/net/sf/cherbot/NoobManager.java
===================================================================
--- trunk/src/net/sf/cherbot/NoobManager.java 2006-10-29 14:02:55 UTC (rev 32)
+++ trunk/src/net/sf/cherbot/NoobManager.java 2006-10-29 14:10:21 UTC (rev 33)
@@ -149,7 +149,7 @@
*/
private void listHowtos() {
final StringBuilder sb = new StringBuilder();
- for (Pattern howto : howtos.keySet()) {
+ for (final Pattern howto : howtos.keySet()) {
if (sb.length() == 0) {
sb.append("I know the following howtos:\n");
} else {
@@ -166,7 +166,7 @@
*/
private void listWhatiss() {
final StringBuilder sb = new StringBuilder();
- for (Pattern whatis : whatiss.keySet()) {
+ for (final Pattern whatis : whatiss.keySet()) {
if (sb.length() == 0) {
sb.append("I know the following whatis:\n");
} else {
@@ -183,7 +183,7 @@
*/
private void listWhereiss() {
final StringBuilder sb = new StringBuilder();
- for (Pattern whereis : whereiss.keySet()) {
+ for (final Pattern whereis : whereiss.keySet()) {
if (sb.length() == 0) {
sb.append("I know the following whereis:\n");
} else {
@@ -200,7 +200,7 @@
* @param topic topic to get howto on
*/
private void getHowto(final String topic) {
- for (Pattern pattern : howtos.keySet()) {
+ for (final Pattern pattern : howtos.keySet()) {
if (pattern.matcher(topic).matches()) {
answer(howtos.get(pattern));
return;
@@ -214,7 +214,7 @@
* @param topic topic to get whereis on
*/
private void getWhereis(final String topic) {
- for (Pattern pattern : whereiss.keySet()) {
+ for (final Pattern pattern : whereiss.keySet()) {
if (pattern.matcher(topic).matches()) {
answer(whereiss.get(pattern));
return;
@@ -237,7 +237,7 @@
* @param topic topic to get whatis on
*/
private void getWhatis(final String topic) {
- for (Pattern pattern : whatiss.keySet()) {
+ for (final Pattern pattern : whatiss.keySet()) {
if (pattern.matcher(topic).matches()) {
answer(whatiss.get(pattern));
return;
@@ -271,7 +271,7 @@
}
@Override protected void saveImpl() {
- for (Patter...
[truncated message content] |
|
From: <chr...@us...> - 2006-10-29 15:23:39
|
Revision: 34
http://svn.sourceforge.net/cherbot/?rev=34&view=rev
Author: christianhujer
Date: 2006-10-29 07:23:18 -0800 (Sun, 29 Oct 2006)
Log Message:
-----------
Reformatted code.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/CrimeManager.java
trunk/src/net/sf/cherbot/DummyManagerProxy.java
trunk/src/net/sf/cherbot/GroupManager.java
trunk/src/net/sf/cherbot/MailManager.java
Modified: trunk/src/net/sf/cherbot/CrimeManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CrimeManager.java 2006-10-29 14:10:21 UTC (rev 33)
+++ trunk/src/net/sf/cherbot/CrimeManager.java 2006-10-29 15:23:18 UTC (rev 34)
@@ -165,6 +165,7 @@
// private Set<String> criminals = new TreeSet<String>();
//
+
/**
* @param cherBot reference to CherBot.
*/
Modified: trunk/src/net/sf/cherbot/DummyManagerProxy.java
===================================================================
--- trunk/src/net/sf/cherbot/DummyManagerProxy.java 2006-10-29 14:10:21 UTC (rev 33)
+++ trunk/src/net/sf/cherbot/DummyManagerProxy.java 2006-10-29 15:23:18 UTC (rev 34)
@@ -21,7 +21,7 @@
/**
* Create a DummyManager.
- * @param cherBot CherBot to create DummyManager for
+ * @param cherBot CherBot to create DummyManager for
* @param managers Managers to register
*/
public DummyManagerProxy(final CherBot cherBot, final Manager... managers) {
Modified: trunk/src/net/sf/cherbot/GroupManager.java
===================================================================
--- trunk/src/net/sf/cherbot/GroupManager.java 2006-10-29 14:10:21 UTC (rev 33)
+++ trunk/src/net/sf/cherbot/GroupManager.java 2006-10-29 15:23:18 UTC (rev 34)
@@ -1106,7 +1106,7 @@
* Implementation for deserialization:
* Take care about newly added fields
* @param stream Stream to deserialize with
- * @throws IOException in case of I/O problems during deserialization
+ * @throws IOException in case of I/O problems during deserialization
* @throws ClassNotFoundException in case a class required for deserialization was not found
*/
private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException {
Modified: trunk/src/net/sf/cherbot/MailManager.java
===================================================================
--- trunk/src/net/sf/cherbot/MailManager.java 2006-10-29 14:10:21 UTC (rev 33)
+++ trunk/src/net/sf/cherbot/MailManager.java 2006-10-29 15:23:18 UTC (rev 34)
@@ -317,8 +317,8 @@
/**
* Gets a mail.
* @param n number of mail to get
+ * @return mail number <var>n</var> for the actor.
* @throws CherBotException if no such mail
- * @return mail number <var>n</var> for the actor.
*/
private Mail getMail(final int n) {
try {
@@ -365,8 +365,8 @@
/**
* Send mail.
* @param from Sender
- * @param to Receiver
- * @param msg Message body
+ * @param to Receiver
+ * @param msg Message body
*/
@Override public void mail(final String from, final String to, final String msg) {
new Mail(from, to, msg);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2006-10-30 09:00:55
|
Revision: 38
http://svn.sourceforge.net/cherbot/?rev=38&view=rev
Author: christianhujer
Date: 2006-10-30 01:00:29 -0800 (Mon, 30 Oct 2006)
Log Message:
-----------
Declared nullability on some classes.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/BlackListManager.java
trunk/src/net/sf/cherbot/Manager.java
Modified: trunk/src/net/sf/cherbot/BlackListManager.java
===================================================================
--- trunk/src/net/sf/cherbot/BlackListManager.java 2006-10-29 23:11:41 UTC (rev 37)
+++ trunk/src/net/sf/cherbot/BlackListManager.java 2006-10-30 09:00:29 UTC (rev 38)
@@ -8,6 +8,7 @@
import java.util.SortedSet;
import java.util.TreeSet;
+import org.jetbrains.annotations.NotNull;
/**
* Manages a black list of users that may not use Cherbot.
@@ -55,7 +56,7 @@
* Create the BlackListManager.
* @param cherbot CherBot
*/
- public BlackListManager(final CherBot cherbot) {
+ public BlackListManager(@NotNull final CherBot cherbot) {
super(cherbot, "blacklist");
}
@@ -78,7 +79,7 @@
* Puts a player to the blacklist.
* @param player Player to blacklist
*/
- private void addBlacklist(final String player) {
+ private void addBlacklist(@NotNull final String player) {
checkPermission(PERM_BLACKLIST);
if (blacklist.add(player)) {
answer("Added " + player + " to the blacklist.");
@@ -92,7 +93,7 @@
* Removes a player from the blacklist.
* @param player Player to remove
*/
- private void removeBlacklist(final String player) {
+ private void removeBlacklist(@NotNull final String player) {
checkPermission(PERM_BLACKLIST);
if (blacklist.remove(player)) {
answer("Removed " + player + " from the blacklist.");
@@ -107,7 +108,7 @@
* @param player Player to check
* @return <code>true</code> if <var>player</var> is blacklisted, otherwise <code>false</code>.
*/
- public boolean isBlacklisted(final String player) {
+ public boolean isBlacklisted(@NotNull final String player) {
return blacklist.contains(player);
}
Modified: trunk/src/net/sf/cherbot/Manager.java
===================================================================
--- trunk/src/net/sf/cherbot/Manager.java 2006-10-29 23:11:41 UTC (rev 37)
+++ trunk/src/net/sf/cherbot/Manager.java 2006-10-30 09:00:29 UTC (rev 38)
@@ -27,6 +27,8 @@
import java.util.NoSuchElementException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* Base class for managers.
@@ -109,7 +111,7 @@
* @param cherBot CherBot to create Manager for.
* @param topic Topic name to use
*/
- protected Manager(final CherBot cherBot, final String topic) {
+ protected Manager(@NotNull final CherBot cherBot, @NotNull final String topic) {
this(cherBot, topic, 0);
}
@@ -119,7 +121,7 @@
* @param topic Topic name to use
* @param delay Delay to use for notifications
*/
- protected Manager(final CherBot cherBot, final String topic, final int delay) {
+ protected Manager(@NotNull final CherBot cherBot, @NotNull final String topic, @NotNull final int delay) {
this.cherBot = cherBot;
this.topic = topic;
this.delay = delay;
@@ -138,7 +140,7 @@
* Add a command.
* @param command Command to add
*/
- private void addCommand(final Command command) {
+ private void addCommand(@NotNull final Command command) {
commands.add(command);
cherBot.addCommand(command);
}
@@ -170,7 +172,7 @@
* @param txt message to check
* @throws SmutException in case smut was found
*/
- public void checkSmut(final String txt) throws SmutException {
+ public void checkSmut(@NotNull final String txt) throws SmutException {
final Manager smutManager = cherBot.getManager("smut");
assert smutManager != this : "A Manager for \"smut\" must override Manager.checkSmut(String)!";
if (smutManager == this) {
@@ -188,7 +190,7 @@
* @return player name
* @throws NoSuchPlayerException in case CherBot doesn't know that player
*/
- protected String player(final String player) {
+ @NotNull protected String player(@NotNull final String player) {
final Manager playerManager = cherBot.getManager("players");
if (playerManager == null) {
return player;
@@ -206,7 +208,7 @@
* If the bot does not have a Manager for that topic, this method simply returns <code>null</code>.
* @return current time
*/
- protected TimeManager.Time getCurrentTime() {
+ @Nullable protected TimeManager.Time getCurrentTime() {
final Manager timeManager = cherBot.getManager("time");
if (timeManager == null) {
return null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-02-10 21:21:40
|
Revision: 41
http://svn.sourceforge.net/cherbot/?rev=41&view=rev
Author: christianhujer
Date: 2007-02-10 13:21:38 -0800 (Sat, 10 Feb 2007)
Log Message:
-----------
Changed enum constant names to match code convention.
Fixed some code convention errors.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/CherBot.java
trunk/src/net/sf/cherbot/CommType.java
Modified: trunk/src/net/sf/cherbot/CherBot.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBot.java 2006-11-25 18:29:45 UTC (rev 40)
+++ trunk/src/net/sf/cherbot/CherBot.java 2007-02-10 21:21:38 UTC (rev 41)
@@ -270,7 +270,7 @@
}
/**
- * Tell
+ * Tell.
* @param p Player name
* @param s String to tell
*/
@@ -290,8 +290,9 @@
}
/**
- * Reply
+ * Reply.
* @param s String to tell
+ * @throws IOException in case of I/O problems.
*/
public void reply(final String s) throws IOException {
final StringBuilder sb = new StringBuilder();
@@ -396,7 +397,7 @@
if (username.equals(who)) {
return;
} // avoid loop dispatch!
- if (ct == CommType.shout) {
+ if (ct == CommType.SHOUT) {
final Pattern p = Pattern.compile(username + "(?:(?:,|:)? *)(.*)");
final Matcher matcher = p.matcher(msg);
if (matcher.matches()) {
Modified: trunk/src/net/sf/cherbot/CommType.java
===================================================================
--- trunk/src/net/sf/cherbot/CommType.java 2006-11-25 18:29:45 UTC (rev 40)
+++ trunk/src/net/sf/cherbot/CommType.java 2007-02-10 21:21:38 UTC (rev 41)
@@ -19,22 +19,29 @@
public enum CommType {
/**
- * SAY
- */say("(\\S+) says: (.*)"),
+ * SAY.
+ */
+ SAY("(\\S+) says: (.*)"),
+
/**
- * SHOUT
- */shout("(\\S+) shouts: (.*)"),
+ * SHOUT.
+ */
+ SHOUT("(\\S+) shouts: (.*)"),
+
/**
- * TELL
- */tell("(\\S+) tells you: (.*)"),
+ * TELL.
+ */
+ TELL("(\\S+) tells you: (.*)"),
+
/**
- * REPLY
- */reply("(\\S+) replies you: (.*)");
+ * REPLY.
+ */
+ REPLY("(\\S+) replies you: (.*)");
/**
* All Communicationtypes.
*/
- public static final Set<CommType> all = Collections.unmodifiableSet(EnumSet.allOf(CommType.class));
+ public static final Set<CommType> ALL = Collections.unmodifiableSet(EnumSet.allOf(CommType.class));
/**
* Regex pattern to match.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-02-10 21:45:35
|
Revision: 43
http://svn.sourceforge.net/cherbot/?rev=43&view=rev
Author: christianhujer
Date: 2007-02-10 13:45:34 -0800 (Sat, 10 Feb 2007)
Log Message:
-----------
Fixed some javadoc issues.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/CherBotSecurityManager.java
trunk/src/net/sf/cherbot/Crime.java
trunk/src/net/sf/cherbot/CrimeManager.java
trunk/src/net/sf/cherbot/GroupManager.java
trunk/src/net/sf/cherbot/Manager.java
trunk/src/net/sf/cherbot/ManagerDocumenter.java
trunk/src/net/sf/cherbot/NoobManager.java
trunk/src/net/sf/cherbot/PlayerManager.java
trunk/src/net/sf/cherbot/PollManager.java
trunk/src/net/sf/cherbot/RodBabyManager.java
trunk/src/net/sf/cherbot/RodBabyWannabeManager.java
trunk/src/net/sf/cherbot/SalesManager.java
trunk/src/net/sf/cherbot/TimeManager.java
Modified: trunk/src/net/sf/cherbot/CherBotSecurityManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBotSecurityManager.java 2007-02-10 21:22:37 UTC (rev 42)
+++ trunk/src/net/sf/cherbot/CherBotSecurityManager.java 2007-02-10 21:45:34 UTC (rev 43)
@@ -166,7 +166,7 @@
}
/**
- * Revoke permission to someoneon something
+ * Revoke permission to someoneon something.
* @param player whose permissions are to be revoked
* @param permission Permissions to revoke
*/
Modified: trunk/src/net/sf/cherbot/Crime.java
===================================================================
--- trunk/src/net/sf/cherbot/Crime.java 2007-02-10 21:22:37 UTC (rev 42)
+++ trunk/src/net/sf/cherbot/Crime.java 2007-02-10 21:45:34 UTC (rev 43)
@@ -7,6 +7,7 @@
package net.sf.cherbot;
/**
+ * Manager for Crimes.
* TODO
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
Modified: trunk/src/net/sf/cherbot/CrimeManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CrimeManager.java 2007-02-10 21:22:37 UTC (rev 42)
+++ trunk/src/net/sf/cherbot/CrimeManager.java 2007-02-10 21:45:34 UTC (rev 43)
@@ -167,6 +167,7 @@
//
/**
+ * Create a new CrimeManager.
* @param cherBot reference to CherBot.
*/
public CrimeManager(final CherBot cherBot) {
Modified: trunk/src/net/sf/cherbot/GroupManager.java
===================================================================
--- trunk/src/net/sf/cherbot/GroupManager.java 2007-02-10 21:22:37 UTC (rev 42)
+++ trunk/src/net/sf/cherbot/GroupManager.java 2007-02-10 21:45:34 UTC (rev 43)
@@ -1103,6 +1103,7 @@
}
/**
+ * Deserialize a Group.
* Implementation for deserialization:
* Take care about newly added fields
* @param stream Stream to deserialize with
Modified: trunk/src/net/sf/cherbot/Manager.java
===================================================================
--- trunk/src/net/sf/cherbot/Manager.java 2007-02-10 21:22:37 UTC (rev 42)
+++ trunk/src/net/sf/cherbot/Manager.java 2007-02-10 21:45:34 UTC (rev 43)
@@ -235,7 +235,7 @@
}
/**
- * Returns the level of a player
+ * Returns the level of a player.
* @param player Player to get level of
* @return level of player or 0 if unknown
*/
@@ -1343,7 +1343,7 @@
} // @interface Description
/**
- * Annotatin to document the features of a module / Manager
+ * Annotation to document the features of a module / Manager.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Retention(RUNTIME)
Modified: trunk/src/net/sf/cherbot/ManagerDocumenter.java
===================================================================
--- trunk/src/net/sf/cherbot/ManagerDocumenter.java 2007-02-10 21:22:37 UTC (rev 42)
+++ trunk/src/net/sf/cherbot/ManagerDocumenter.java 2007-02-10 21:45:34 UTC (rev 43)
@@ -28,6 +28,7 @@
/**
* Main program.
* @param args command line arguments
+ * @throws Exception in case of errors.
*/
public static void main(final String... args) throws Exception {
final CherBot bot = new CherBot();
@@ -77,7 +78,7 @@
}
/**
- * Create a command element for a command
+ * Create a command element for a command.
* @param command Command to create element for
* @return element for Command
*/
Modified: trunk/src/net/sf/cherbot/NoobManager.java
===================================================================
--- trunk/src/net/sf/cherbot/NoobManager.java 2007-02-10 21:22:37 UTC (rev 42)
+++ trunk/src/net/sf/cherbot/NoobManager.java 2007-02-10 21:45:34 UTC (rev 43)
@@ -210,7 +210,7 @@
}
/**
- * Get the whereis on a specific topic
+ * Get the whereis on a specific topic.
* @param topic topic to get whereis on
*/
private void getWhereis(final String topic) {
@@ -233,7 +233,7 @@
}
/**
- * Get the whatis on a specific topic
+ * Get the whatis on a specific topic.
* @param topic topic to get whatis on
*/
private void getWhatis(final String topic) {
Modified: trunk/src/net/sf/cherbot/PlayerManager.java
===================================================================
--- trunk/src/net/sf/cherbot/PlayerManager.java 2007-02-10 21:22:37 UTC (rev 42)
+++ trunk/src/net/sf/cherbot/PlayerManager.java 2007-02-10 21:45:34 UTC (rev 43)
@@ -789,6 +789,7 @@
/**
* Create a LevelManager.
+ * @param cherBot CherBot instance to use.
*/
public PlayerManager(final CherBot cherBot) {
super(cherBot, "players", 2000);
Modified: trunk/src/net/sf/cherbot/PollManager.java
===================================================================
--- trunk/src/net/sf/cherbot/PollManager.java 2007-02-10 21:22:37 UTC (rev 42)
+++ trunk/src/net/sf/cherbot/PollManager.java 2007-02-10 21:45:34 UTC (rev 43)
@@ -262,7 +262,7 @@
}
/**
- * Get the minimum level for the creation of polls
+ * Get the minimum level for the creation of polls.
* @return minimum level for the creation of polls
*/
private int getMinLevel() {
@@ -554,6 +554,7 @@
/**
* Get the number of votes for a choice of a poll.
* @param choice index of to get number of votes for (1..num_choices)
+ * @return the votes for this poll.
*/
int getVotes(final int choice) {
if (choice > choices.size() || choice < 1) {
@@ -565,6 +566,7 @@
/**
* Get the number of botes for a choice of a poll.
* @param choice choice
+ * @return the votes for this choice.
*/
int getVotes(final String choice) {
return votes.get(choice)[0];
@@ -644,7 +646,7 @@
* @param out PrintWriter to write to
* @throws IOException in case of I/O problems
*/
- void writeTo(final PrintWriter out) throws EOFException, IOException {
+ void writeTo(final PrintWriter out) throws IOException {
out.println(number + ": " + getNumChoices() + ": " + state + ": " + player);
out.println(title);
out.println(description);
Modified: trunk/src/net/sf/cherbot/RodBabyManager.java
===================================================================
--- trunk/src/net/sf/cherbot/RodBabyManager.java 2007-02-10 21:22:37 UTC (rev 42)
+++ trunk/src/net/sf/cherbot/RodBabyManager.java 2007-02-10 21:45:34 UTC (rev 43)
@@ -114,6 +114,7 @@
/**
* Create a LevelManager.
+ * @param cherBot CherBot to use.
*/
public RodBabyManager(final CherBot cherBot) {
super(cherBot, "rodbabies");
Modified: trunk/src/net/sf/cherbot/RodBabyWannabeManager.java
===================================================================
--- trunk/src/net/sf/cherbot/RodBabyWannabeManager.java 2007-02-10 21:22:37 UTC (rev 42)
+++ trunk/src/net/sf/cherbot/RodBabyWannabeManager.java 2007-02-10 21:45:34 UTC (rev 43)
@@ -114,6 +114,7 @@
/**
* Create a LevelManager.
+ * @param cherBot CherBot to use.
*/
public RodBabyWannabeManager(final CherBot cherBot) {
super(cherBot, "rodbabywannabes");
Modified: trunk/src/net/sf/cherbot/SalesManager.java
===================================================================
--- trunk/src/net/sf/cherbot/SalesManager.java 2007-02-10 21:22:37 UTC (rev 42)
+++ trunk/src/net/sf/cherbot/SalesManager.java 2007-02-10 21:45:34 UTC (rev 43)
@@ -12,6 +12,7 @@
import java.util.regex.Matcher;
/**
+ * Manager for sales.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
@Manager.Description("Allows to place sales adds.")
Modified: trunk/src/net/sf/cherbot/TimeManager.java
===================================================================
--- trunk/src/net/sf/cherbot/TimeManager.java 2007-02-10 21:22:37 UTC (rev 42)
+++ trunk/src/net/sf/cherbot/TimeManager.java 2007-02-10 21:45:34 UTC (rev 43)
@@ -264,6 +264,7 @@
* Create a time by cloning another time.
* I've not implemented Cloneable because cloning normally is not required because normally instances are immuntable.
* But the one single instance used by the TimeManager is mutable, so that's the only usage of this constructor.
+ * @param o Other time for creating a clone.
*/
private Time(final Time o) {
this(o.year, o.month, o.day, o.hours, o.minutes);
@@ -339,7 +340,7 @@
* {@inheritDoc}
*/
@Override public int hashCode() {
- return (year << 24) ^ (month << 19) ^ (day << 13) ^ (hours << 7) ^ (minutes << 0);
+ return (year << 24) ^ (month << 19) ^ (day << 13) ^ (hours << 7) ^ (minutes);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-02-10 22:12:59
|
Revision: 44
http://svn.sourceforge.net/cherbot/?rev=44&view=rev
Author: christianhujer
Date: 2007-02-10 14:12:53 -0800 (Sat, 10 Feb 2007)
Log Message:
-----------
Fixed some code style issues.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/CronManager.java
trunk/src/net/sf/cherbot/Manager.java
trunk/src/net/sf/cherbot/TimeManager.java
Modified: trunk/src/net/sf/cherbot/CronManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CronManager.java 2007-02-10 21:45:34 UTC (rev 43)
+++ trunk/src/net/sf/cherbot/CronManager.java 2007-02-10 22:12:53 UTC (rev 44)
@@ -85,7 +85,7 @@
/**
* CronTask convenience base class.
*/
- public static abstract class AbstractCronTask implements CronTask {
+ public abstract static class AbstractCronTask implements CronTask {
/**
* The name for this task.
@@ -112,7 +112,7 @@
/**
* CronTask convenience base class.
*/
- public static abstract class RegularCronTask extends AbstractCronTask {
+ public abstract static class RegularCronTask extends AbstractCronTask {
/**
* The number of ticks for the task.
Modified: trunk/src/net/sf/cherbot/Manager.java
===================================================================
--- trunk/src/net/sf/cherbot/Manager.java 2007-02-10 21:45:34 UTC (rev 43)
+++ trunk/src/net/sf/cherbot/Manager.java 2007-02-10 22:12:53 UTC (rev 44)
@@ -494,7 +494,7 @@
* @return sb for convenience
* @see #split(String)
*/
- protected static final StringBuilder concat(final StringBuilder sb, final Iterable<String> it) {
+ protected static StringBuilder concat(final StringBuilder sb, final Iterable<String> it) {
final Iterator<String> iterator = it.iterator();
if (iterator.hasNext()) {
String s = iterator.next();
@@ -514,7 +514,7 @@
* @return Iterable for parts
* @see #concat(StringBuilder,Iterable)
*/
- protected static final String[] split(final String s) {
+ protected static String[] split(final String s) {
return s.split(", ?| and | or ");
}
@@ -1086,7 +1086,7 @@
* Converter used by MapIOMOdule.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
- protected static abstract class Converter<ValueType> {
+ protected abstract static class Converter<ValueType> {
/**
* String Converter that doesn't change.
@@ -1199,7 +1199,7 @@
* {@inheritDoc}
*/
@Override public En fromString(final String value) {
- return (En) Enum.<En>valueOf(cl, value);
+ return Enum.valueOf(cl, value);
}
} // class EnumConverter
Modified: trunk/src/net/sf/cherbot/TimeManager.java
===================================================================
--- trunk/src/net/sf/cherbot/TimeManager.java 2007-02-10 21:45:34 UTC (rev 43)
+++ trunk/src/net/sf/cherbot/TimeManager.java 2007-02-10 22:12:53 UTC (rev 44)
@@ -171,8 +171,7 @@
*/
@Override public void text(final String msg) {
Matcher matcher;
- if (false) {
- } else if ((matcher = regexDaytime.matcher(msg)).matches()) {
+ if ((matcher = regexDaytime.matcher(msg)).matches()) {
time.minutes = Integer.parseInt(matcher.group(1));
time.hours = Integer.parseInt(matcher.group(2));
if (matcher.group(3).equals("pm") && time.hours < 12) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-16 20:51:24
|
Revision: 61
http://svn.sourceforge.net/cherbot/?rev=61&view=rev
Author: christianhujer
Date: 2007-06-16 13:51:19 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Added package documentation. Improved javadoc comments and documentation.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/AbstractConnection.java
trunk/src/net/sf/cherbot/ClanModule.java
trunk/src/net/sf/cherbot/Module.java
Added Paths:
-----------
trunk/src/net/sf/cherbot/metaserver/package-info.java
trunk/src/net/sf/cherbot/package-info.java
Modified: trunk/src/net/sf/cherbot/AbstractConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/AbstractConnection.java 2007-06-16 20:22:54 UTC (rev 60)
+++ trunk/src/net/sf/cherbot/AbstractConnection.java 2007-06-16 20:51:19 UTC (rev 61)
@@ -6,7 +6,7 @@
package net.sf.cherbot;
-/** A AbstractConnection represents the connection to a server and has one or more channels.
+/** An AbstractConnection represents the connection to a server and has one or more channels.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public abstract class AbstractConnection {
Modified: trunk/src/net/sf/cherbot/ClanModule.java
===================================================================
--- trunk/src/net/sf/cherbot/ClanModule.java 2007-06-16 20:22:54 UTC (rev 60)
+++ trunk/src/net/sf/cherbot/ClanModule.java 2007-06-16 20:51:19 UTC (rev 61)
@@ -9,8 +9,7 @@
import org.jetbrains.annotations.NotNull;
import java.sql.Connection;
-/**
- * Created by IntelliJ IDEA.
+/** Module for Clans.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class ClanModule implements PersistentModule {
@@ -23,7 +22,8 @@
public void save(@NotNull final Connection con) {
}
- public void parseMessage(@NotNull Channel channel, @NotNull String msg) {
- //To change body of implemented methods use File | Settings | File Templates.
+ /** {@inheritDoc} */
+ public void parseMessage(@NotNull final Channel channel, @NotNull final String msg) {
}
+
} // class ClanModule
Modified: trunk/src/net/sf/cherbot/Module.java
===================================================================
--- trunk/src/net/sf/cherbot/Module.java 2007-06-16 20:22:54 UTC (rev 60)
+++ trunk/src/net/sf/cherbot/Module.java 2007-06-16 20:51:19 UTC (rev 61)
@@ -1,3 +1,9 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
package net.sf.cherbot;
import org.jetbrains.annotations.NotNull;
@@ -2,4 +8,3 @@
-/**
- * Created by IntelliJ IDEA.
+/** Interface for Modules.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
@@ -13,4 +18,5 @@
* @param msg Message to parse
*/
void parseMessage(@NotNull Channel channel, @NotNull String msg);
-}
+
+} // interface Module
Added: trunk/src/net/sf/cherbot/metaserver/package-info.java
===================================================================
--- trunk/src/net/sf/cherbot/metaserver/package-info.java (rev 0)
+++ trunk/src/net/sf/cherbot/metaserver/package-info.java 2007-06-16 20:51:19 UTC (rev 61)
@@ -0,0 +1,10 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+/** The package net.sf.cherbot.metaserver contains metaserver access.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+package net.sf.cherbot.metaserver;
Property changes on: trunk/src/net/sf/cherbot/metaserver/package-info.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/net/sf/cherbot/package-info.java
===================================================================
--- trunk/src/net/sf/cherbot/package-info.java (rev 0)
+++ trunk/src/net/sf/cherbot/package-info.java 2007-06-16 20:51:19 UTC (rev 61)
@@ -0,0 +1,10 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+/** The package net.sf.cherbot contains the main classes of CherBot.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+package net.sf.cherbot;
Property changes on: trunk/src/net/sf/cherbot/package-info.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-16 22:23:09
|
Revision: 69
http://svn.sourceforge.net/cherbot/?rev=69&view=rev
Author: christianhujer
Date: 2007-06-16 15:23:07 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Started implementation of PlayerModel as first PersistentModule implementation.
Added Paths:
-----------
trunk/src/net/sf/cherbot/Player.java
trunk/src/net/sf/cherbot/PlayerModule.java
Added: trunk/src/net/sf/cherbot/Player.java
===================================================================
--- trunk/src/net/sf/cherbot/Player.java (rev 0)
+++ trunk/src/net/sf/cherbot/Player.java 2007-06-16 22:23:07 UTC (rev 69)
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+/** Represents a single player.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class Player {
+
+ /** The id of this player. */
+ private final int id;
+
+ /** The serverId of this player. */
+ private final int serverId;
+
+ /** The name of this player. */
+ private final String name;
+
+ /** Create a Player.
+ * @param id Id of this player.
+ * @param serverId ServerId of this player.
+ * @param name Name of this player.
+ */
+ public Player(final int id, final int serverId, final String name) {
+ this.id = id;
+ this.serverId = serverId;
+ this.name = name;
+ }
+
+ /** Returns the id of this player.
+ * @return The id of this player.
+ */
+ public int getId() {
+ return id;
+ }
+
+ /** Returns the server id of this player.
+ * @return The server id of this player.
+ */
+ public int getServerId() {
+ return serverId;
+ }
+
+ /** Returns the name of this player.
+ * @return The name of this player.
+ */
+ public String getName() {
+ return name;
+ }
+
+} // class Player
Property changes on: trunk/src/net/sf/cherbot/Player.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/net/sf/cherbot/PlayerModule.java
===================================================================
--- trunk/src/net/sf/cherbot/PlayerModule.java (rev 0)
+++ trunk/src/net/sf/cherbot/PlayerModule.java 2007-06-16 22:23:07 UTC (rev 69)
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+import org.jetbrains.annotations.NotNull;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.ResultSet;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Created by IntelliJ IDEA.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class PlayerModule implements PersistentModule {
+
+ private final List<Player> players = new ArrayList<Player>();
+
+ /** {@inheritDoc} */
+ public void load(@NotNull final Connection con) throws SQLException {
+ final PreparedStatement stmt = con.prepareStatement("SELECT id, serverId, name FROM Player");
+ final ResultSet result = stmt.executeQuery();
+ while (result.next()) {
+ final int id = result.getInt(1);
+ final int serverId = result.getInt(2);
+ final String name = result.getString(3);
+ players.add(new Player(id, serverId, name));
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void save(@NotNull final Connection con) throws SQLException {
+ createTables(con);
+ final PreparedStatement lookup = con.prepareStatement("SELECT id FROM Player WHERE id = ?");
+ final PreparedStatement update = con.prepareStatement("UPDATE Player SET id = ?, serverId = ?, name = ? WHERE id = ?");
+ final PreparedStatement insert = con.prepareStatement("INSERT INTO Player (id, serverId, name) VALUES (?, ?, ?)");
+ }
+
+ /** Creates the tables if they don't exist.
+ * @param con Connection to use for creating the tables.
+ * @throws SQLException In case of persistence problems.
+ */
+ private void createTables(@NotNull final Connection con) throws SQLException {
+ try {
+ final PreparedStatement stmt = con.prepareStatement("CREATE TABLE Player (id INT, serverId INT, name VARCHAR(32)");
+ stmt.execute();
+ } catch (final SQLException ignore) {
+ System.err.println(ignore);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void parseMessage(@NotNull final Channel channel, @NotNull final String msg) {
+ }
+
+} // class PlayerModule
Property changes on: trunk/src/net/sf/cherbot/PlayerModule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-17 17:09:16
|
Revision: 76
http://svn.sourceforge.net/cherbot/?rev=76&view=rev
Author: christianhujer
Date: 2007-06-17 10:09:14 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Moved common code from DaimoninConnection and IRCConnection into their superclass AbstractConnection.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/AbstractConnection.java
trunk/src/net/sf/cherbot/DaimoninConnection.java
trunk/src/net/sf/cherbot/IRCConnection.java
Modified: trunk/src/net/sf/cherbot/AbstractConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/AbstractConnection.java 2007-06-17 14:37:59 UTC (rev 75)
+++ trunk/src/net/sf/cherbot/AbstractConnection.java 2007-06-17 17:09:14 UTC (rev 76)
@@ -6,9 +6,99 @@
package net.sf.cherbot;
+import net.sf.japi.io.args.BasicCommand;
+import net.sf.japi.io.args.Option;
+import net.sf.japi.io.args.OptionType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import java.net.Socket;
+import java.io.IOException;
+import java.io.Closeable;
+import java.io.Serializable;
+
/** An AbstractConnection represents the connection to a server and has one or more channels.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
-public abstract class AbstractConnection {
+public abstract class AbstractConnection extends BasicCommand implements Closeable, Serializable {
+ /** The host to connect to.
+ * @serial include
+ */
+ @Nullable private String host;
+
+ /** The port to connect to.
+ * @serial include
+ */
+ private int port;
+
+ /** The socket for the connection. */
+ @Nullable private transient Socket socket;
+
+ /** Sets the host of the IRC server to connect to.
+ * @param host Host of the IRC server.
+ */
+ @Option(type = OptionType.REQUIRED, value = {"host"})
+ public void setHost(@NotNull final String host) {
+ this.host = host;
+ }
+
+ /** Returns the host to connect to.
+ * @return The host to connect to.
+ */
+ @Nullable public String getHost() {
+ return host;
+ }
+
+ /** Sets the port of the IRC server to connect to.
+ * @param port Port of the IRC server.
+ */
+ @Option({"port"})
+ public void setPort(@NotNull final Integer port) {
+ this.port = port;
+ }
+
+ /** Returns the port to connect to.
+ * @return The port to connect to.
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /** Establishes the connection.
+ * @return The socket created for this connection.
+ * @throws IOException in case of connection problems.
+ */
+ @NotNull public Socket connect() throws IOException {
+ final Socket socket = new Socket(host, port);
+ setSocket(socket);
+ return socket;
+ }
+
+ /** {@inheritDoc} */
+ public void close() throws IOException {
+ try {
+ final Socket socket = this.socket;
+ if (socket != null) {
+ socket.close();
+ }
+ } finally {
+ socket = null;
+ }
+ }
+
+ /** Sets the socket for the connection.
+ * Use this method if you want to create a connection on an existing socket instead of letting this Connection automatically create its own socket.
+ * @param socket Socket for the connection.
+ */
+ public void setSocket(@NotNull final Socket socket) {
+ this.socket = socket;
+ }
+
+ /** Returns the socket for the connection.
+ * @return The socket for the connection.
+ */
+ @Nullable public Socket getSocket() {
+ return socket;
+ }
+
} // class AbstractConnection
Modified: trunk/src/net/sf/cherbot/DaimoninConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/DaimoninConnection.java 2007-06-17 14:37:59 UTC (rev 75)
+++ trunk/src/net/sf/cherbot/DaimoninConnection.java 2007-06-17 17:09:14 UTC (rev 76)
@@ -6,15 +6,14 @@
package net.sf.cherbot;
+import java.io.BufferedOutputStream;
+import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.BufferedOutputStream;
-import java.io.EOFException;
import java.net.Socket;
import java.util.List;
import net.sf.japi.io.args.ArgParser;
-import net.sf.japi.io.args.BasicCommand;
import net.sf.japi.io.args.Option;
import net.sf.japi.io.args.OptionType;
import org.jetbrains.annotations.NotNull;
@@ -23,7 +22,7 @@
/** A DaimoninConnection represents a connection to a Daimonin server.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
-public class DaimoninConnection extends BasicCommand {
+public class DaimoninConnection extends AbstractConnection {
/** Default server host. */
//@NotNull public static final String DEFAULT_DAIMONIN_HOST = "daimonin.game-server.cc";
@@ -32,21 +31,12 @@
/** Default server port. */
public static final int DEFAULT_DAIMONIN_PORT = 13327;
- /** The host to connect to. */
- @NotNull private String host = DEFAULT_DAIMONIN_HOST;
-
- /** The port to connect to. */
- private int port = DEFAULT_DAIMONIN_PORT;
-
/** The username to authenticate with. */
@NotNull private String username;
/** The password to authenticate with. */
@NotNull private String password;
- /** The Socket for communication. */
- @Nullable private Socket socket;
-
/** The PrintStream to write to. */
@Nullable private OutputStream out;
@@ -55,6 +45,8 @@
/** Creates a DaimoninConnection. */
public DaimoninConnection() {
+ setHost(DEFAULT_DAIMONIN_HOST);
+ setPort(DEFAULT_DAIMONIN_PORT);
}
/** Main program.
@@ -67,13 +59,10 @@
/** Establishes a connection.
* @throws IOException In case of connection problems.
*/
- private void connect() throws IOException {
- final Socket socket = new Socket(host, port);
- this.socket = socket;
- final OutputStream out = new BufferedOutputStream(socket.getOutputStream());
- this.out = out;
- final InputStream in = socket.getInputStream();
- this.in = in;
+ @NotNull public Socket connect() throws IOException {
+ final Socket socket = super.connect();
+ this.out = new BufferedOutputStream(socket.getOutputStream());
+ this.in = socket.getInputStream();
// read server version
readToNull();
@@ -103,6 +92,7 @@
// write 0x00 0x12 "reply LFoobuzzer49" // L not part of name
// read 0x00 0x06 0x18 "4 QP0"
// write 0x00 0x0E "reply xxxxxxxx"
+ return socket;
}
/** Reads and discards a single message.
@@ -149,17 +139,11 @@
out.flush();
}
- /** Closes a connection.
- * @throws IOException In case of connection problems.
- */
- private void disconnect() throws IOException {
+ /** {@inheritDoc} */
+ public void close() throws IOException {
try {
- final Socket socket = this.socket;
- if (socket != null) {
- socket.close();
- }
+ super.close();
} finally {
- socket = null;
in = null;
out = null;
}
@@ -169,7 +153,7 @@
public int run(@NotNull final List<String> args) throws Exception {
connect();
Thread.sleep(10000);
- disconnect();
+ close();
return 0;
}
@@ -189,20 +173,11 @@
this.password = password;
}
- /** Sets the host to connect to.
- * @param host Host to connect to
- */
+ /** {@inheritDoc} */
+ // Overridden because for Daimonin the host is optional.
@Option({"host"})
public void setHost(@NotNull final String host) {
- this.host = host;
+ super.setHost(host);
}
- /** Sets the port to connect to.
- * @param port Port to connect to
- */
- @Option({"port"})
- public void setPort(@NotNull final Integer port) {
- this.port = port;
- }
-
} // class DaimoninConnection
Modified: trunk/src/net/sf/cherbot/IRCConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-17 14:37:59 UTC (rev 75)
+++ trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-17 17:09:14 UTC (rev 76)
@@ -15,17 +15,15 @@
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import net.sf.japi.io.args.BasicCommand;
import net.sf.japi.io.args.ArgParser;
import net.sf.japi.io.args.Option;
-import net.sf.japi.io.args.OptionType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** An IRCConnection represents a connection to an IRC server.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
-public class IRCConnection extends BasicCommand {
+public class IRCConnection extends AbstractConnection {
/** The default IRC port. */
public static final int DEFAULT_IRC_PORT = 6667;
@@ -46,15 +44,6 @@
/** The password to authenticate with NickServ or <code>null</code> if no authentication is desired. */
@Nullable private String nickPassword;
- /** The IRC server host to connect to. */
- @NotNull private String host;
-
- /** The IRC server port to connect to. */
- private int port = DEFAULT_IRC_PORT;
-
- /** The Socket for communication. */
- @Nullable private Socket socket;
-
/** The PrintStream to write to. */
@Nullable private PrintWriter out;
@@ -63,6 +52,7 @@
/** Creates an IRCConnection. */
public IRCConnection() {
+ setPort(DEFAULT_IRC_PORT);
}
/** Main program.
@@ -77,9 +67,9 @@
/** Establishes a connection.
* @throws IOException In case of connection problems.
*/
- private void connect() throws IOException {
- final Socket socket = new Socket(host, port);
- this.socket = socket;
+ @Override @NotNull public Socket connect() throws IOException {
+ super.connect();
+ final Socket socket = super.connect();
final PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), "utf-8"));
this.out = out;
this.in = new BufferedReader(new InputStreamReader(socket.getInputStream(), "utf-8"));
@@ -89,19 +79,14 @@
out.println("PRIVMSG NICKSERV :IDENTIFY " + nickPassword);
}
out.flush();
+ return socket;
}
- /** Closes a connection.
- * @throws IOException In case of connection problems.
- */
- private void disconnect() throws IOException {
+ /** {@inheritDoc} */
+ @Override public void close() throws IOException {
try {
- final Socket socket = this.socket;
- if (socket != null) {
- socket.close();
- }
+ super.close();
} finally {
- socket = null;
in = null;
out = null;
}
@@ -139,7 +124,7 @@
}
return 0;
} finally {
- disconnect();
+ close();
}
}
@@ -178,20 +163,4 @@
this.nickPassword = nickPassword;
}
- /** Sets the host of the IRC server to connect to.
- * @param host Host of the IRC server.
- */
- @Option(type = OptionType.REQUIRED, value = {"host"})
- public void setHost(@NotNull final String host) {
- this.host = host;
- }
-
- /** Sets the port of the IRC server to connect to.
- * @param port Port of the IRC server.
- */
- @Option({"port"})
- public void setPort(@NotNull final Integer port) {
- this.port = port;
- }
-
} // class IRCConnection
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-17 17:35:39
|
Revision: 77
http://svn.sourceforge.net/cherbot/?rev=77&view=rev
Author: christianhujer
Date: 2007-06-17 10:35:37 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Added Channels.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/Channel.java
trunk/src/net/sf/cherbot/IRCConnection.java
Modified: trunk/src/net/sf/cherbot/Channel.java
===================================================================
--- trunk/src/net/sf/cherbot/Channel.java 2007-06-17 17:09:14 UTC (rev 76)
+++ trunk/src/net/sf/cherbot/Channel.java 2007-06-17 17:35:37 UTC (rev 77)
@@ -14,33 +14,29 @@
*/
public abstract class Channel {
- /** The types of channels. */
- public static enum Type {
-
- /** A Crossfire channel. */
- CROSSFIRE,
-
- /** A Daimonin channel. */
- DAIMONIN,
-
- /** An IRC channel. */
- IRC
- } // enum Type
-
- /** The type of this channel. */
- @NotNull private Type type;
-
- /** The server of this channel. */
- @NotNull private String server;
-
- /** The channel of this channel.
+ /** The name of this channel.
* Maybe <code>null</code> if it's the default / no channel.
*/
- @Nullable private String channel;
+ @Nullable private String channelName;
+ /** Creates a Channel.
+ * @param channelName name of this channel.
+ */
+ protected Channel(@Nullable final String channelName) {
+ this.channelName = channelName;
+ }
+
/** Sends a message to this channel.
* @param msg Message to send
*/
- public abstract void send(@NotNull final String msg);
+ public abstract void send(@NotNull String msg);
+ /** Returns the name of this channel.
+ * Maybe <code>null</code> if it's the default / no channel.
+ * @return The channel of this channel or <code>null</code> if default / no channel.
+ */
+ @Nullable public String getChannelName() {
+ return channelName;
+ }
+
} // class Channel
Modified: trunk/src/net/sf/cherbot/IRCConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-17 17:09:14 UTC (rev 76)
+++ trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-17 17:35:37 UTC (rev 77)
@@ -12,7 +12,9 @@
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sf.japi.io.args.ArgParser;
@@ -50,6 +52,9 @@
/** The BufferedReader to read from. */
@Nullable private BufferedReader in;
+ /** The channels of this connection. */
+ private Map<String, IRCChannel> channels = new HashMap<String, IRCChannel>();
+
/** Creates an IRCConnection. */
public IRCConnection() {
setPort(DEFAULT_IRC_PORT);
@@ -84,6 +89,7 @@
/** {@inheritDoc} */
@Override public void close() throws IOException {
+ channels.clear();
try {
super.close();
} finally {
@@ -128,6 +134,22 @@
}
}
+ /** Joins an IRC channel.
+ * @param channelName name of the channel to join.
+ * @return The channel that was just joined.
+ */
+ public Channel join(@NotNull final String channelName) {
+ final PrintWriter out = this.out;
+ assert out != null;
+ out.println("JOIN " + channelName);
+ IRCChannel channel = channels.get(channelName);
+ if (channels.get(channelName) == null) {
+ channel = new IRCChannel(channelName);
+ channels.put(channelName, channel);
+ }
+ return channel;
+ }
+
/** Sets the username to use for connecting to the IRC server.
* Note that this is the IRC username, not the nick.
* @param username Username to use for IRC.
@@ -163,4 +185,27 @@
this.nickPassword = nickPassword;
}
+ /** Represents a Channel on IRC.
+ * This can be used for both, real channels (whith channel names starting with '#') and direct communication channels with nicks.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+ private class IRCChannel extends Channel {
+
+ /** Creates an IRCChannel.
+ * @param channelName name of this channel.
+ */
+ IRCChannel(@NotNull final String channelName) {
+ super(channelName);
+ }
+
+ /** {@inheritDoc} */
+ public void send(@NotNull final String msg) {
+ final PrintWriter out = IRCConnection.this.out;
+ if (out != null) {
+ out.println("PRIVMSG " + getChannelName() + " :" + msg);
+ }
+ }
+
+ } // class IRCChannel
+
} // class IRCConnection
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-24 17:26:04
|
Revision: 93
http://svn.sourceforge.net/cherbot/?rev=93&view=rev
Author: christianhujer
Date: 2007-06-24 10:25:57 -0700 (Sun, 24 Jun 2007)
Log Message:
-----------
Turned Channel into an interface. The class Channel now is AbstractChannel.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/IRCConnection.java
Added Paths:
-----------
trunk/src/net/sf/cherbot/AbstractChannel.java
trunk/src/net/sf/cherbot/Channel.java
Removed Paths:
-------------
trunk/src/net/sf/cherbot/Channel.java
Copied: trunk/src/net/sf/cherbot/AbstractChannel.java (from rev 90, trunk/src/net/sf/cherbot/Channel.java)
===================================================================
--- trunk/src/net/sf/cherbot/AbstractChannel.java (rev 0)
+++ trunk/src/net/sf/cherbot/AbstractChannel.java 2007-06-24 17:25:57 UTC (rev 93)
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+import org.jetbrains.annotations.Nullable;
+
+/** Abstract base implementation of {@link Channel}.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public abstract class AbstractChannel implements Channel {
+
+ /** The name of this channel.
+ * Maybe <code>null</code> if it's the default / no channel.
+ */
+ @Nullable private String channelName;
+
+ /** Creates a Channel.
+ * @param channelName name of this channel.
+ */
+ protected AbstractChannel(@Nullable final String channelName) {
+ this.channelName = channelName;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable public String getChannelName() {
+ return channelName;
+ }
+
+} // class Channel
Property changes on: trunk/src/net/sf/cherbot/AbstractChannel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Deleted: trunk/src/net/sf/cherbot/Channel.java
===================================================================
--- trunk/src/net/sf/cherbot/Channel.java 2007-06-24 17:10:25 UTC (rev 92)
+++ trunk/src/net/sf/cherbot/Channel.java 2007-06-24 17:25:57 UTC (rev 93)
@@ -1,42 +0,0 @@
-/*
- * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
- * License: GNU General Public License v2.0 or newer.
- * See file COPYING in the root directory of this project.
- */
-
-package net.sf.cherbot;
-
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.annotations.NotNull;
-
-/** A Channel uniquely identifies a protocol (type) / server / channel combination.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public abstract class Channel {
-
- /** The name of this channel.
- * Maybe <code>null</code> if it's the default / no channel.
- */
- @Nullable private String channelName;
-
- /** Creates a Channel.
- * @param channelName name of this channel.
- */
- protected Channel(@Nullable final String channelName) {
- this.channelName = channelName;
- }
-
- /** Sends a message to this channel.
- * @param msg Message to send
- */
- public abstract void send(@NotNull String msg);
-
- /** Returns the name of this channel.
- * Maybe <code>null</code> if it's the default / no channel.
- * @return The channel of this channel or <code>null</code> if default / no channel.
- */
- @Nullable public String getChannelName() {
- return channelName;
- }
-
-} // class Channel
Added: trunk/src/net/sf/cherbot/Channel.java
===================================================================
--- trunk/src/net/sf/cherbot/Channel.java (rev 0)
+++ trunk/src/net/sf/cherbot/Channel.java 2007-06-24 17:25:57 UTC (rev 93)
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/** A Channel uniquely identifies a protocol (type) / server / channel combination.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public interface Channel {
+
+ /** Sends a message to this channel.
+ * @param msg Message to send
+ */
+ void send(@NotNull String msg);
+
+ /** Returns the name of this channel.
+ * Maybe <code>null</code> if it's the default / no channel.
+ * @return The channel of this channel or <code>null</code> if default / no channel.
+ */
+ @Nullable String getChannelName();
+
+} // interface Channel
Property changes on: trunk/src/net/sf/cherbot/Channel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Modified: trunk/src/net/sf/cherbot/IRCConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-24 17:10:25 UTC (rev 92)
+++ trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-24 17:25:57 UTC (rev 93)
@@ -210,7 +210,7 @@
* This can be used for both, real channels (whith channel names starting with '#') and direct communication channels with nicks.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
- private class IRCChannel extends Channel {
+ private class IRCChannel extends AbstractChannel {
/** Creates an IRCChannel.
* @param channelName name of this channel.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-24 19:53:38
|
Revision: 96
http://svn.sourceforge.net/cherbot/?rev=96&view=rev
Author: christianhujer
Date: 2007-06-24 12:53:33 -0700 (Sun, 24 Jun 2007)
Log Message:
-----------
Improved PlayerModule, added ServerModule (unfinished).
Modified Paths:
--------------
trunk/src/net/sf/cherbot/PlayerModule.java
Added Paths:
-----------
trunk/src/net/sf/cherbot/Server.java
trunk/src/net/sf/cherbot/ServerModule.java
Modified: trunk/src/net/sf/cherbot/PlayerModule.java
===================================================================
--- trunk/src/net/sf/cherbot/PlayerModule.java 2007-06-24 18:32:26 UTC (rev 95)
+++ trunk/src/net/sf/cherbot/PlayerModule.java 2007-06-24 19:53:33 UTC (rev 96)
@@ -14,12 +14,12 @@
import java.util.List;
import java.util.ArrayList;
-/**
- * Created by IntelliJ IDEA.
+/** Module for managing players.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class PlayerModule implements PersistentModule {
+ /** The players. */
private final List<Player> players = new ArrayList<Player>();
/** {@inheritDoc} */
@@ -32,14 +32,32 @@
final String name = result.getString(3);
players.add(new Player(id, serverId, name));
}
+ stmt.close();
}
/** {@inheritDoc} */
public void save(@NotNull final Connection con) throws SQLException {
createTables(con);
final PreparedStatement lookup = con.prepareStatement("SELECT id FROM Player WHERE id = ?");
- final PreparedStatement update = con.prepareStatement("UPDATE Player SET id = ?, serverId = ?, name = ? WHERE id = ?");
+ final PreparedStatement update = con.prepareStatement("UPDATE Player SET serverId = ?, name = ? WHERE id = ?");
final PreparedStatement insert = con.prepareStatement("INSERT INTO Player (id, serverId, name) VALUES (?, ?, ?)");
+ for (final Player player : players) {
+ lookup.setInt(1, player.getId());
+ if (lookup.executeQuery().next()) {
+ update.setInt(1, player.getServerId());
+ update.setString(2, player.getName());
+ update.setInt(3, player.getId());
+ update.executeUpdate();
+ } else {
+ insert.setInt(1, player.getId());
+ insert.setInt(2, player.getServerId());
+ insert.setString(3, player.getName());
+ insert.executeUpdate();
+ }
+ }
+ lookup.close();
+ update.close();
+ insert.close();
}
/** Creates the tables if they don't exist.
@@ -50,6 +68,7 @@
try {
final PreparedStatement stmt = con.prepareStatement("CREATE TABLE Player (id INT, serverId INT, name VARCHAR(32)");
stmt.execute();
+ stmt.close();
} catch (final SQLException ignore) {
System.err.println(ignore);
}
Added: trunk/src/net/sf/cherbot/Server.java
===================================================================
--- trunk/src/net/sf/cherbot/Server.java (rev 0)
+++ trunk/src/net/sf/cherbot/Server.java 2007-06-24 19:53:33 UTC (rev 96)
@@ -0,0 +1,74 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+import org.jetbrains.annotations.NotNull;
+
+/** A Server represents a single server instance like a certain IRC network, a certain crossfire server or a certain daimonin server.
+ * The server will be used to establish a connection.
+ * A Cherbot account with server-specific properties like username and password will be associated with the server.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ * @todo add server type and parameters
+ */
+public class Server {
+
+ /** The id of this server. */
+ private int id;
+
+ /** The host name of this server. */
+ @NotNull private String hostname;
+
+ /** The port of this server. */
+ private int port;
+
+ /** Create a Server.
+ * @param id Id of this server.
+ * @param hostname Hostname of this server.
+ * @param port Port of this server.
+ */
+ public Server(final int id, @NotNull final String hostname, final int port) {
+ this.id = id;
+ this.hostname = hostname;
+ this.port = port;
+ }
+
+ /** Returns the id of this server.
+ * @return The id of this server.
+ */
+ public int getId() {
+ return id;
+ }
+
+ /** Returns the hostname of this server.
+ * @return The hostname of this server.
+ */
+ @NotNull public String getHostname() {
+ return hostname;
+ }
+
+ /** Sets the hostname of this server.
+ * @param hostname The hostname of this serer.
+ */
+ public void setHostname(@NotNull final String hostname) {
+ this.hostname = hostname;
+ }
+
+ /** Returns the port of this server.
+ * @return The port of this server.
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /** Sets the port of this server.
+ * @param port The port of this server.
+ */
+ public void setPort(final int port) {
+ this.port = port;
+ }
+
+} // class Server
Property changes on: trunk/src/net/sf/cherbot/Server.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/net/sf/cherbot/ServerModule.java
===================================================================
--- trunk/src/net/sf/cherbot/ServerModule.java (rev 0)
+++ trunk/src/net/sf/cherbot/ServerModule.java 2007-06-24 19:53:33 UTC (rev 96)
@@ -0,0 +1,81 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+import org.jetbrains.annotations.NotNull;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.List;
+
+/** Module for managing servers.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class ServerModule implements PersistentModule {
+
+ /** The players. */
+ private final List<Server> servers = new ArrayList<Server>();
+
+ /** {@inheritDoc} */
+ public void load(@NotNull final Connection con) throws SQLException {
+ final PreparedStatement stmt = con.prepareStatement("SELECT id, serverId, name FROM Player");
+ final ResultSet result = stmt.executeQuery();
+ while (result.next()) {
+ final int id = result.getInt(1);
+ final String host = result.getString(2);
+ final int port = result.getInt(3);
+ servers.add(new Server(id, host, port));
+ }
+ stmt.close();
+ }
+
+ /** {@inheritDoc} */
+ public void save(@NotNull final Connection con) throws SQLException {
+ createTables(con);
+ final PreparedStatement lookup = con.prepareStatement("SELECT id FROM Server WHERE id = ?");
+ final PreparedStatement update = con.prepareStatement("UPDATE Server SET host = ?, port = ? WHERE id = ?");
+ final PreparedStatement insert = con.prepareStatement("INSERT INTO Server (id, host, port) VALUES (?, ?, ?)");
+ for (final Server server : servers) {
+ lookup.setInt(1, server.getId());
+ if (lookup.executeQuery().next()) {
+ update.setString(1, server.getHostname());
+ update.setInt(2, server.getPort());
+ update.setInt(3, server.getId());
+ update.executeUpdate();
+ } else {
+ insert.setInt(1, server.getId());
+ insert.setString(2, server.getHostname());
+ insert.setInt(3, server.getPort());
+ insert.executeUpdate();
+ }
+ }
+ lookup.close();
+ update.close();
+ insert.close();
+ }
+
+ /** Creates the tables if they don't exist.
+ * @param con Connection to use for creating the tables.
+ * @throws SQLException In case of persistence problems.
+ */
+ private void createTables(@NotNull final Connection con) throws SQLException {
+ try {
+ final PreparedStatement stmt = con.prepareStatement("CREATE TABLE Server (id INT, host VARCHAR(64), port INT");
+ stmt.execute();
+ stmt.close();
+ } catch (final SQLException ignore) {
+ System.err.println(ignore);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void parseMessage(@NotNull final Channel channel, @NotNull final String msg) {
+ }
+
+} // class ServerModule
Property changes on: trunk/src/net/sf/cherbot/ServerModule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-30 19:17:45
|
Revision: 109
http://svn.sourceforge.net/cherbot/?rev=109&view=rev
Author: christianhujer
Date: 2007-06-30 12:17:43 -0700 (Sat, 30 Jun 2007)
Log Message:
-----------
Extracted common code of CrossfireConnection and DaimoninConnection into a superclass.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/CrossfireConnection.java
trunk/src/net/sf/cherbot/DaimoninConnection.java
Added Paths:
-----------
trunk/src/net/sf/cherbot/AbstractCFConnection.java
Added: trunk/src/net/sf/cherbot/AbstractCFConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/AbstractCFConnection.java (rev 0)
+++ trunk/src/net/sf/cherbot/AbstractCFConnection.java 2007-06-30 19:17:43 UTC (rev 109)
@@ -0,0 +1,126 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.BufferedOutputStream;
+import java.net.Socket;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.NotNull;
+import net.sf.japi.io.args.Option;
+import net.sf.japi.io.args.OptionType;
+
+/**
+ * Common base class for Connections that use Crossfire-style protocols such as Angelion or Daimonin and of course Crossfire itself.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public abstract class AbstractCFConnection extends AbstractConnection {
+
+ /** The username to authenticate with. */
+ @NotNull protected String username;
+
+ /** The password to authenticate with. */
+ @NotNull protected String password;
+
+ /** The PrintStream to write to. */
+ @Nullable protected OutputStream out;
+
+ /** The BufferedReader to read from. */
+ @Nullable protected InputStream in;
+
+ /** Creates an AbstractCFConnection. */
+ protected AbstractCFConnection() {
+ }
+
+ /** Reads and discards a single message.
+ * @throws IOException In case of I/O problems.
+ */
+ protected void readToNull() throws IOException {
+ receivePacket();
+ }
+
+ /** Reads the next data packet.
+ * @throws IOException In case of I/O problems.
+ * @return The data of the next data packet.
+ */
+ @NotNull protected byte[] receivePacket() throws IOException {
+ final InputStream in = this.in;
+ assert in != null;
+ final int h1 = in.read();
+ final int length = h1 != -1 && (h1 & 0x80) == 0x80 ? h1 << 16 | in.read() << 8 | in.read() : h1 << 8 | in.read();
+ if (length == -1) {
+ throw new EOFException();
+ }
+ final byte[] data = new byte[length];
+ for (int read = 0; read < length;) {
+ final int bytesRead = in.read(data, read, length - read);
+ if (bytesRead == -1) {
+ throw new EOFException();
+ }
+ read += bytesRead;
+ }
+ return data;
+ }
+
+ /** Sends a simple text message.
+ * @param msg Message to send
+ * @throws IOException In case of I/O problems.
+ */
+ protected void textMsg(@NotNull final String msg) throws IOException {
+ final OutputStream out = this.out;
+ assert out != null;
+ final byte[] data = msg.getBytes("utf-8");
+ out.write(0xFF & data.length >> 8);
+ out.write(0xFF & data.length);
+ out.write(data);
+ out.flush();
+ }
+
+ /** {@inheritDoc} */
+ public void close() throws IOException {
+ try {
+ super.close();
+ } finally {
+ in = null;
+ out = null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setSocket(@NotNull final Socket socket) throws IOException {
+ super.setSocket(socket);
+ out = new BufferedOutputStream(socket.getOutputStream());
+ in = socket.getInputStream();
+ }
+
+ /** Sets the username for connecting to this CF-Style server.
+ * @param username Username for connecting to this CF-Style server.
+ */
+ @Option(type = OptionType.REQUIRED, value = {"username"})
+ public void setUsername(@NotNull final String username) {
+ this.username = username;
+ }
+
+ /** Sets the password for connecting to this CF-Style server.
+ * @param password Password for connecting to this CF-Style server.
+ */
+ @Option(type = OptionType.REQUIRED, value = {"password"})
+ public void setPassword(@NotNull final String password) {
+ this.password = password;
+ }
+
+ /** {@inheritDoc} */
+ // Overridden because for CF-Style servers the host is optional.
+ @Option({"host"})
+ public void setHost(@NotNull final String host) {
+ super.setHost(host);
+ }
+
+} // class AbstractCFConnection
Property changes on: trunk/src/net/sf/cherbot/AbstractCFConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Modified: trunk/src/net/sf/cherbot/CrossfireConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/CrossfireConnection.java 2007-06-30 18:32:48 UTC (rev 108)
+++ trunk/src/net/sf/cherbot/CrossfireConnection.java 2007-06-30 19:17:43 UTC (rev 109)
@@ -6,23 +6,16 @@
package net.sf.cherbot;
-import java.io.BufferedOutputStream;
-import java.io.EOFException;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.net.Socket;
import java.util.List;
import net.sf.japi.io.args.ArgParser;
-import net.sf.japi.io.args.Option;
-import net.sf.japi.io.args.OptionType;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
/** A CrossfireConnection represents a connection to a Crossfire server.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
-public class CrossfireConnection extends AbstractConnection {
+public class CrossfireConnection extends AbstractCFConnection {
/** Default server host. */
//@NotNull public static final String DEFAULT_CROSSFIRE_HOST = "crossfire.metalforge.net";
@@ -31,18 +24,6 @@
/** Default server port. */
public static final int DEFAULT_CROSSFIRE_PORT = 13327;
- /** The username to authenticate with. */
- @NotNull private String username;
-
- /** The password to authenticate with. */
- @NotNull private String password;
-
- /** The PrintStream to write to. */
- @Nullable private OutputStream out;
-
- /** The BufferedReader to read from. */
- @Nullable private InputStream in;
-
/** Creates a CrossfireConnection. */
public CrossfireConnection() {
setHost(DEFAULT_CROSSFIRE_HOST);
@@ -72,68 +53,7 @@
return socket;
}
- /** Reads and discards a single message.
- * @throws IOException In case of I/O problems.
- */
- private void readToNull() throws IOException {
- receivePacket();
- }
-
- /** Reads the next data packet.
- * @throws IOException In case of I/O problems.
- * @return The data of the next data packet.
- */
- private byte[] receivePacket() throws IOException {
- final InputStream in = this.in;
- assert in != null;
- final int h1 = in.read();
- final int length = h1 != -1 && (h1 & 0x80) == 0x80 ? h1 << 16 | in.read() << 8 | in.read() : h1 << 8 | in.read();
- if (length == -1) {
- throw new EOFException();
- }
- final byte[] data = new byte[length];
- for (int read = 0; read < length;) {
- final int bytesRead = in.read(data, read, length - read);
- if (bytesRead == -1) {
- throw new EOFException();
- }
- read += bytesRead;
- }
- return data;
- }
-
- /** Sends a simple text message.
- * @param msg Message to send
- * @throws IOException In case of I/O problems.
- */
- private void textMsg(@NotNull final String msg) throws IOException {
- final OutputStream out = this.out;
- assert out != null;
- final byte[] data = msg.getBytes("utf-8");
- out.write(0xFF & data.length >> 8);
- out.write(0xFF & data.length);
- out.write(data);
- out.flush();
- }
-
/** {@inheritDoc} */
- public void close() throws IOException {
- try {
- super.close();
- } finally {
- in = null;
- out = null;
- }
- }
-
- /** {@inheritDoc} */
- @Override public void setSocket(@NotNull final Socket socket) throws IOException {
- super.setSocket(socket);
- out = new BufferedOutputStream(socket.getOutputStream());
- in = socket.getInputStream();
- }
-
- /** {@inheritDoc} */
public int run(@NotNull final List<String> args) throws Exception {
connect();
for (int i = 0; i < 10000; i++) {
@@ -143,27 +63,4 @@
return 0;
}
- /** Sets the username for connecting to this Crossfire server.
- * @param username Username for connecting to this Crossfire server.
- */
- @Option(type = OptionType.REQUIRED, value = {"username"})
- public void setUsername(@NotNull final String username) {
- this.username = username;
- }
-
- /** Sets the password for connecting to this Crossfire server.
- * @param password Password for connecting to this Crossfire server.
- */
- @Option(type = OptionType.REQUIRED, value = {"password"})
- public void setPassword(@NotNull final String password) {
- this.password = password;
- }
-
- /** {@inheritDoc} */
- // Overridden because for Crossfire the host is optional.
- @Option({"host"})
- public void setHost(@NotNull final String host) {
- super.setHost(host);
- }
-
} // class CrossfireConnection
Modified: trunk/src/net/sf/cherbot/DaimoninConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/DaimoninConnection.java 2007-06-30 18:32:48 UTC (rev 108)
+++ trunk/src/net/sf/cherbot/DaimoninConnection.java 2007-06-30 19:17:43 UTC (rev 109)
@@ -6,23 +6,16 @@
package net.sf.cherbot;
-import java.io.BufferedOutputStream;
-import java.io.EOFException;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.net.Socket;
import java.util.List;
import net.sf.japi.io.args.ArgParser;
-import net.sf.japi.io.args.Option;
-import net.sf.japi.io.args.OptionType;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
/** A DaimoninConnection represents a connection to a Daimonin server.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
-public class DaimoninConnection extends AbstractConnection {
+public class DaimoninConnection extends AbstractCFConnection {
/** Default server host. */
//@NotNull public static final String DEFAULT_DAIMONIN_HOST = "daimonin.game-server.cc";
@@ -31,18 +24,6 @@
/** Default server port. */
public static final int DEFAULT_DAIMONIN_PORT = 13327;
- /** The username to authenticate with. */
- @NotNull private String username;
-
- /** The password to authenticate with. */
- @NotNull private String password;
-
- /** The PrintStream to write to. */
- @Nullable private OutputStream out;
-
- /** The BufferedReader to read from. */
- @Nullable private InputStream in;
-
/** Creates a DaimoninConnection. */
public DaimoninConnection() {
setHost(DEFAULT_DAIMONIN_HOST);
@@ -59,9 +40,6 @@
/** {@inheritDoc} */
@NotNull @Override public Socket connect() throws IOException {
final Socket socket = super.connect();
- this.out = new BufferedOutputStream(socket.getOutputStream());
- this.in = socket.getInputStream();
-
readToNull(); // "991023 991023 Daimonin Server"
textMsg("version 991023 991023 Daimonin SDL Client"); // we have to cheat or the server won't let us in.
textMsg("setup bot 1"); // We are a bot
@@ -75,61 +53,7 @@
return socket;
}
- /** Reads and discards a single message.
- * @throws IOException In case of I/O problems.
- */
- private void readToNull() throws IOException {
- receivePacket();
- }
-
- /** Reads the next data packet.
- * @throws IOException In case of I/O problems.
- * @return The data of the next data packet.
- */
- private byte[] receivePacket() throws IOException {
- final InputStream in = this.in;
- assert in != null;
- final int h1 = in.read();
- final int length = h1 != -1 && (h1 & 0x80) == 0x80 ? h1 << 16 | in.read() << 8 | in.read() : h1 << 8 | in.read();
- if (length == -1) {
- throw new EOFException();
- }
- final byte[] data = new byte[length];
- for (int read = 0; read < length;) {
- final int bytesRead = in.read(data, read, length - read);
- if (bytesRead == -1) {
- throw new EOFException();
- }
- read += bytesRead;
- }
- return data;
- }
-
- /** Sends a simple text message.
- * @param msg Message to send
- * @throws IOException In case of I/O problems.
- */
- private void textMsg(@NotNull final String msg) throws IOException {
- final OutputStream out = this.out;
- assert out != null;
- final byte[] data = msg.getBytes("utf-8");
- out.write(0xFF & data.length >> 8);
- out.write(0xFF & data.length);
- out.write(data);
- out.flush();
- }
-
/** {@inheritDoc} */
- public void close() throws IOException {
- try {
- super.close();
- } finally {
- in = null;
- out = null;
- }
- }
-
- /** {@inheritDoc} */
public int run(@NotNull final List<String> args) throws Exception {
connect();
Thread.sleep(100000);
@@ -137,27 +61,4 @@
return 0;
}
- /** Sets the username for connecting to this Daimonin server.
- * @param username Username for connecting to this Daimonin server.
- */
- @Option(type = OptionType.REQUIRED, value = {"username"})
- public void setUsername(@NotNull final String username) {
- this.username = username;
- }
-
- /** Sets the password for connecting to this Daimonin server.
- * @param password Password for connecting to this Daimonin server.
- */
- @Option(type = OptionType.REQUIRED, value = {"password"})
- public void setPassword(@NotNull final String password) {
- this.password = password;
- }
-
- /** {@inheritDoc} */
- // Overridden because for Daimonin the host is optional.
- @Option({"host"})
- public void setHost(@NotNull final String host) {
- super.setHost(host);
- }
-
} // class DaimoninConnection
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-30 20:13:00
|
Revision: 111
http://svn.sourceforge.net/cherbot/?rev=111&view=rev
Author: christianhujer
Date: 2007-06-30 13:12:40 -0700 (Sat, 30 Jun 2007)
Log Message:
-----------
Encapsulated fields.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/AbstractCFConnection.java
trunk/src/net/sf/cherbot/CrossfireConnection.java
trunk/src/net/sf/cherbot/DaimoninConnection.java
Modified: trunk/src/net/sf/cherbot/AbstractCFConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/AbstractCFConnection.java 2007-06-30 19:48:13 UTC (rev 110)
+++ trunk/src/net/sf/cherbot/AbstractCFConnection.java 2007-06-30 20:12:40 UTC (rev 111)
@@ -24,16 +24,16 @@
public abstract class AbstractCFConnection extends AbstractConnection {
/** The username to authenticate with. */
- @NotNull protected String username;
+ @NotNull private String username;
/** The password to authenticate with. */
- @NotNull protected String password;
+ @NotNull private String password;
/** The PrintStream to write to. */
- @Nullable protected OutputStream out;
+ @Nullable private OutputStream out;
/** The BufferedReader to read from. */
- @Nullable protected InputStream in;
+ @Nullable private InputStream in;
/** Creates an AbstractCFConnection. */
protected AbstractCFConnection() {
@@ -123,4 +123,19 @@
super.setHost(host);
}
+ @NotNull public String getUsername() {
+ return username;
+ }
+
+ @NotNull public String getPassword() {
+ return password;
+ }
+
+ @Nullable protected OutputStream getOut() {
+ return out;
+ }
+
+ @Nullable protected InputStream getIn() {
+ return in;
+ }
} // class AbstractCFConnection
Modified: trunk/src/net/sf/cherbot/CrossfireConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/CrossfireConnection.java 2007-06-30 19:48:13 UTC (rev 110)
+++ trunk/src/net/sf/cherbot/CrossfireConnection.java 2007-06-30 20:12:40 UTC (rev 111)
@@ -47,9 +47,9 @@
readToNull();
textMsg("addme");
readToNull();
- textMsg("reply " + username);
+ textMsg("reply " + getUsername());
readToNull();
- textMsg("reply " + password);
+ textMsg("reply " + getPassword());
return socket;
}
Modified: trunk/src/net/sf/cherbot/DaimoninConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/DaimoninConnection.java 2007-06-30 19:48:13 UTC (rev 110)
+++ trunk/src/net/sf/cherbot/DaimoninConnection.java 2007-06-30 20:12:40 UTC (rev 111)
@@ -47,9 +47,9 @@
textMsg("addme");
readToNull(); // 0x00 0x06 0x18 "4 QNO"
readToNull(); // 0x00 0x01 0x15
- textMsg("reply L" + username);
+ textMsg("reply L" + getUsername());
readToNull(); // 0x00 0x06 0x18 "4 QP0"
- textMsg("reply " + password);
+ textMsg("reply " + getPassword());
return socket;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-07-01 17:36:08
|
Revision: 112
http://svn.sourceforge.net/cherbot/?rev=112&view=rev
Author: christianhujer
Date: 2007-07-01 10:36:00 -0700 (Sun, 01 Jul 2007)
Log Message:
-----------
Moved connection related stuff into a separate package.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/ClanModule.java
trunk/src/net/sf/cherbot/EchoModule.java
trunk/src/net/sf/cherbot/Module.java
trunk/src/net/sf/cherbot/PlayerModule.java
trunk/src/net/sf/cherbot/ServerModule.java
Added Paths:
-----------
trunk/src/net/sf/cherbot/connection/
trunk/src/net/sf/cherbot/connection/AbstractCFConnection.java
trunk/src/net/sf/cherbot/connection/AbstractChannel.java
trunk/src/net/sf/cherbot/connection/AbstractConnection.java
trunk/src/net/sf/cherbot/connection/Channel.java
trunk/src/net/sf/cherbot/connection/CrossfireConnection.java
trunk/src/net/sf/cherbot/connection/DaimoninConnection.java
trunk/src/net/sf/cherbot/connection/IRCConnection.java
trunk/src/net/sf/cherbot/connection/package-info.java
Modified: trunk/src/net/sf/cherbot/ClanModule.java
===================================================================
--- trunk/src/net/sf/cherbot/ClanModule.java 2007-06-30 20:12:40 UTC (rev 111)
+++ trunk/src/net/sf/cherbot/ClanModule.java 2007-07-01 17:36:00 UTC (rev 112)
@@ -8,6 +8,7 @@
import org.jetbrains.annotations.NotNull;
import java.sql.Connection;
+import net.sf.cherbot.connection.Channel;
/** Module for Clans.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
Modified: trunk/src/net/sf/cherbot/EchoModule.java
===================================================================
--- trunk/src/net/sf/cherbot/EchoModule.java 2007-06-30 20:12:40 UTC (rev 111)
+++ trunk/src/net/sf/cherbot/EchoModule.java 2007-07-01 17:36:00 UTC (rev 112)
@@ -7,6 +7,7 @@
package net.sf.cherbot;
import org.jetbrains.annotations.NotNull;
+import net.sf.cherbot.connection.Channel;
/** Module that simply echoes a message.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
Modified: trunk/src/net/sf/cherbot/Module.java
===================================================================
--- trunk/src/net/sf/cherbot/Module.java 2007-06-30 20:12:40 UTC (rev 111)
+++ trunk/src/net/sf/cherbot/Module.java 2007-07-01 17:36:00 UTC (rev 112)
@@ -7,6 +7,7 @@
package net.sf.cherbot;
import org.jetbrains.annotations.NotNull;
+import net.sf.cherbot.connection.Channel;
/** Interface for Modules.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
Modified: trunk/src/net/sf/cherbot/PlayerModule.java
===================================================================
--- trunk/src/net/sf/cherbot/PlayerModule.java 2007-06-30 20:12:40 UTC (rev 111)
+++ trunk/src/net/sf/cherbot/PlayerModule.java 2007-07-01 17:36:00 UTC (rev 112)
@@ -13,6 +13,7 @@
import java.sql.ResultSet;
import java.util.List;
import java.util.ArrayList;
+import net.sf.cherbot.connection.Channel;
/** Module for managing players.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
Modified: trunk/src/net/sf/cherbot/ServerModule.java
===================================================================
--- trunk/src/net/sf/cherbot/ServerModule.java 2007-06-30 20:12:40 UTC (rev 111)
+++ trunk/src/net/sf/cherbot/ServerModule.java 2007-07-01 17:36:00 UTC (rev 112)
@@ -13,6 +13,7 @@
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
+import net.sf.cherbot.connection.Channel;
/** Module for managing servers.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
Copied: trunk/src/net/sf/cherbot/connection/AbstractCFConnection.java (from rev 111, trunk/src/net/sf/cherbot/AbstractCFConnection.java)
===================================================================
--- trunk/src/net/sf/cherbot/connection/AbstractCFConnection.java (rev 0)
+++ trunk/src/net/sf/cherbot/connection/AbstractCFConnection.java 2007-07-01 17:36:00 UTC (rev 112)
@@ -0,0 +1,141 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot.connection;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.BufferedOutputStream;
+import java.net.Socket;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.NotNull;
+import net.sf.japi.io.args.Option;
+import net.sf.japi.io.args.OptionType;
+
+/**
+ * Common base class for Connections that use Crossfire-style protocols such as Angelion or Daimonin and of course Crossfire itself.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public abstract class AbstractCFConnection extends AbstractConnection {
+
+ /** The username to authenticate with. */
+ @NotNull private String username;
+
+ /** The password to authenticate with. */
+ @NotNull private String password;
+
+ /** The PrintStream to write to. */
+ @Nullable private OutputStream out;
+
+ /** The BufferedReader to read from. */
+ @Nullable private InputStream in;
+
+ /** Creates an AbstractCFConnection. */
+ protected AbstractCFConnection() {
+ }
+
+ /** Reads and discards a single message.
+ * @throws IOException In case of I/O problems.
+ */
+ protected void readToNull() throws IOException {
+ receivePacket();
+ }
+
+ /** Reads the next data packet.
+ * @throws IOException In case of I/O problems.
+ * @return The data of the next data packet.
+ */
+ @NotNull protected byte[] receivePacket() throws IOException {
+ final InputStream in = this.in;
+ assert in != null;
+ final int h1 = in.read();
+ final int length = h1 != -1 && (h1 & 0x80) == 0x80 ? h1 << 16 | in.read() << 8 | in.read() : h1 << 8 | in.read();
+ if (length == -1) {
+ throw new EOFException();
+ }
+ final byte[] data = new byte[length];
+ for (int read = 0; read < length;) {
+ final int bytesRead = in.read(data, read, length - read);
+ if (bytesRead == -1) {
+ throw new EOFException();
+ }
+ read += bytesRead;
+ }
+ return data;
+ }
+
+ /** Sends a simple text message.
+ * @param msg Message to send
+ * @throws IOException In case of I/O problems.
+ */
+ protected void textMsg(@NotNull final String msg) throws IOException {
+ final OutputStream out = this.out;
+ assert out != null;
+ final byte[] data = msg.getBytes("utf-8");
+ out.write(0xFF & data.length >> 8);
+ out.write(0xFF & data.length);
+ out.write(data);
+ out.flush();
+ }
+
+ /** {@inheritDoc} */
+ public void close() throws IOException {
+ try {
+ super.close();
+ } finally {
+ in = null;
+ out = null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setSocket(@NotNull final Socket socket) throws IOException {
+ super.setSocket(socket);
+ out = new BufferedOutputStream(socket.getOutputStream());
+ in = socket.getInputStream();
+ }
+
+ /** Sets the username for connecting to this CF-Style server.
+ * @param username Username for connecting to this CF-Style server.
+ */
+ @Option(type = OptionType.REQUIRED, value = {"username"})
+ public void setUsername(@NotNull final String username) {
+ this.username = username;
+ }
+
+ /** Sets the password for connecting to this CF-Style server.
+ * @param password Password for connecting to this CF-Style server.
+ */
+ @Option(type = OptionType.REQUIRED, value = {"password"})
+ public void setPassword(@NotNull final String password) {
+ this.password = password;
+ }
+
+ /** {@inheritDoc} */
+ // Overridden because for CF-Style servers the host is optional.
+ @Option({"host"})
+ public void setHost(@NotNull final String host) {
+ super.setHost(host);
+ }
+
+ @NotNull public String getUsername() {
+ return username;
+ }
+
+ @NotNull public String getPassword() {
+ return password;
+ }
+
+ @Nullable protected OutputStream getOut() {
+ return out;
+ }
+
+ @Nullable protected InputStream getIn() {
+ return in;
+ }
+} // class AbstractCFConnection
Property changes on: trunk/src/net/sf/cherbot/connection/AbstractCFConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Copied: trunk/src/net/sf/cherbot/connection/AbstractChannel.java (from rev 108, trunk/src/net/sf/cherbot/AbstractChannel.java)
===================================================================
--- trunk/src/net/sf/cherbot/connection/AbstractChannel.java (rev 0)
+++ trunk/src/net/sf/cherbot/connection/AbstractChannel.java 2007-07-01 17:36:00 UTC (rev 112)
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot.connection;
+
+import org.jetbrains.annotations.Nullable;
+
+/** Abstract base implementation of {@link Channel}.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public abstract class AbstractChannel implements Channel {
+
+ /** The name of this channel.
+ * Maybe <code>null</code> if it's the default / no channel.
+ */
+ @Nullable private String channelName;
+
+ /** Creates a Channel.
+ * @param channelName name of this channel.
+ */
+ protected AbstractChannel(@Nullable final String channelName) {
+ this.channelName = channelName;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable public String getChannelName() {
+ return channelName;
+ }
+
+} // class Channel
Property changes on: trunk/src/net/sf/cherbot/connection/AbstractChannel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Copied: trunk/src/net/sf/cherbot/connection/AbstractConnection.java (from rev 108, trunk/src/net/sf/cherbot/AbstractConnection.java)
===================================================================
--- trunk/src/net/sf/cherbot/connection/AbstractConnection.java (rev 0)
+++ trunk/src/net/sf/cherbot/connection/AbstractConnection.java 2007-07-01 17:36:00 UTC (rev 112)
@@ -0,0 +1,126 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot.connection;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.Socket;
+import net.sf.japi.io.args.BasicCommand;
+import net.sf.japi.io.args.Option;
+import net.sf.japi.io.args.OptionType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/** An AbstractConnection represents the connection to a server and has one or more channels.
+ * Connections are implemented as command bean.
+ * That means:
+ * <ul>
+ * <li>
+ * An object does not reflect an established connection but has a state.
+ * The connection state can be established or not established.
+ * </li>
+ * <li>
+ * For testing, trying or standalone usage it is possible to "run" a connection as a standalone java program from the command line.
+ * </li>
+ * </ul>
+ * To query whether the connection is open, get the Socket of the connection and check the socket.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public abstract class AbstractConnection extends BasicCommand implements Closeable, Serializable {
+
+ /** The host to connect to.
+ * @serial include
+ */
+ @Nullable private String host;
+
+ /** The port to connect to.
+ * @serial include
+ */
+ private int port;
+
+ /** The socket for the connection. */
+ @Nullable private transient Socket socket;
+
+ /** Sets the host of the IRC server to connect to.
+ * @param host Host of the IRC server.
+ */
+ @Option(type = OptionType.REQUIRED, value = {"host"})
+ public void setHost(@NotNull final String host) {
+ this.host = host;
+ }
+
+ /** Returns the host to connect to.
+ * @return The host to connect to.
+ */
+ @Nullable public String getHost() {
+ return host;
+ }
+
+ /** Sets the port of the IRC server to connect to.
+ * @param port Port of the IRC server.
+ */
+ @Option({"port"})
+ public void setPort(@NotNull final Integer port) {
+ this.port = port;
+ }
+
+ /** Returns the port to connect to.
+ * @return The port to connect to.
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /** Establishes this connection.
+ * Implementations of this method must invoke {@link #setSocket(Socket)}.
+ * @return The socket created for this connection.
+ * @throws IOException in case of connection problems.
+ */
+ @NotNull public Socket connect() throws IOException {
+ final Socket socket = new Socket(host, port);
+ setSocket(socket);
+ return socket;
+ }
+
+ /** {@inheritDoc} */
+ public void close() throws IOException {
+ try {
+ final Socket socket = this.socket;
+ if (socket != null) {
+ socket.close();
+ }
+ } finally {
+ socket = null;
+ }
+ }
+
+ /** Returns whether this connection is established.
+ * @return <code>true</code> if this connection is established, otherwise <code>false</code>.
+ * @see Socket#isConnected()
+ */
+ public boolean isConnected() {
+ return socket != null && socket.isConnected();
+ }
+
+ /** Sets the socket for the connection.
+ * Use this method if you want to create a connection on an existing socket instead of letting this Connection automatically create its own socket.
+ * @param socket Socket for the connection.
+ * @throws IOException In case of I/O problems when setting the socket. This is useful for overriding methods which may be interested in using the socket when it's being set.
+ */
+ public void setSocket(@NotNull final Socket socket) throws IOException {
+ this.socket = socket;
+ }
+
+ /** Returns the socket for the connection.
+ * @return The socket for the connection.
+ */
+ @Nullable public Socket getSocket() {
+ return socket;
+ }
+
+} // class AbstractConnection
Property changes on: trunk/src/net/sf/cherbot/connection/AbstractConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Copied: trunk/src/net/sf/cherbot/connection/Channel.java (from rev 108, trunk/src/net/sf/cherbot/Channel.java)
===================================================================
--- trunk/src/net/sf/cherbot/connection/Channel.java (rev 0)
+++ trunk/src/net/sf/cherbot/connection/Channel.java 2007-07-01 17:36:00 UTC (rev 112)
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot.connection;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/** A Channel uniquely identifies a protocol (type) / server / channel combination.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public interface Channel {
+
+ /** Sends a message to this channel.
+ * @param msg Message to send
+ */
+ void send(@NotNull String msg);
+
+ /** Returns the name of this channel.
+ * Maybe <code>null</code> if it's the default / no channel.
+ * @return The channel of this channel or <code>null</code> if default / no channel.
+ */
+ @Nullable String getChannelName();
+
+} // interface Channel
Property changes on: trunk/src/net/sf/cherbot/connection/Channel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Copied: trunk/src/net/sf/cherbot/connection/CrossfireConnection.java (from rev 111, trunk/src/net/sf/cherbot/CrossfireConnection.java)
===================================================================
--- trunk/src/net/sf/cherbot/connection/CrossfireConnection.java (rev 0)
+++ trunk/src/net/sf/cherbot/connection/CrossfireConnection.java 2007-07-01 17:36:00 UTC (rev 112)
@@ -0,0 +1,66 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot.connection;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.util.List;
+import net.sf.japi.io.args.ArgParser;
+import org.jetbrains.annotations.NotNull;
+
+/** A CrossfireConnection represents a connection to a Crossfire server.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class CrossfireConnection extends AbstractCFConnection {
+
+ /** Default server host. */
+ //@NotNull public static final String DEFAULT_CROSSFIRE_HOST = "crossfire.metalforge.net";
+ @NotNull public static final String DEFAULT_CROSSFIRE_HOST = "127.0.0.1";
+
+ /** Default server port. */
+ public static final int DEFAULT_CROSSFIRE_PORT = 13327;
+
+ /** Creates a CrossfireConnection. */
+ public CrossfireConnection() {
+ setHost(DEFAULT_CROSSFIRE_HOST);
+ setPort(DEFAULT_CROSSFIRE_PORT);
+ }
+
+ /** Main program.
+ * @param args Command line arguments.
+ */
+ public static void main(final String... args) {
+ ArgParser.simpleParseAndRun(new CrossfireConnection(), args);
+ }
+
+ /** {@inheritDoc} */
+ @NotNull @Override public Socket connect() throws IOException {
+ final Socket socket = super.connect();
+ readToNull();
+ textMsg("version 1023 1023 CherBot");
+ textMsg("setup bot 1");
+ readToNull();
+ readToNull();
+ textMsg("addme");
+ readToNull();
+ textMsg("reply " + getUsername());
+ readToNull();
+ textMsg("reply " + getPassword());
+ return socket;
+ }
+
+ /** {@inheritDoc} */
+ public int run(@NotNull final List<String> args) throws Exception {
+ connect();
+ for (int i = 0; i < 10000; i++) {
+ readToNull();
+ }
+ close();
+ return 0;
+ }
+
+} // class CrossfireConnection
Property changes on: trunk/src/net/sf/cherbot/connection/CrossfireConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Copied: trunk/src/net/sf/cherbot/connection/DaimoninConnection.java (from rev 111, trunk/src/net/sf/cherbot/DaimoninConnection.java)
===================================================================
--- trunk/src/net/sf/cherbot/connection/DaimoninConnection.java (rev 0)
+++ trunk/src/net/sf/cherbot/connection/DaimoninConnection.java 2007-07-01 17:36:00 UTC (rev 112)
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot.connection;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.util.List;
+import net.sf.japi.io.args.ArgParser;
+import org.jetbrains.annotations.NotNull;
+
+/** A DaimoninConnection represents a connection to a Daimonin server.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class DaimoninConnection extends AbstractCFConnection {
+
+ /** Default server host. */
+ //@NotNull public static final String DEFAULT_DAIMONIN_HOST = "daimonin.game-server.cc";
+ @NotNull public static final String DEFAULT_DAIMONIN_HOST = "127.0.0.1";
+
+ /** Default server port. */
+ public static final int DEFAULT_DAIMONIN_PORT = 13327;
+
+ /** Creates a DaimoninConnection. */
+ public DaimoninConnection() {
+ setHost(DEFAULT_DAIMONIN_HOST);
+ setPort(DEFAULT_DAIMONIN_PORT);
+ }
+
+ /** Main program.
+ * @param args Command line arguments.
+ */
+ public static void main(final String... args) {
+ ArgParser.simpleParseAndRun(new DaimoninConnection(), args);
+ }
+
+ /** {@inheritDoc} */
+ @NotNull @Override public Socket connect() throws IOException {
+ final Socket socket = super.connect();
+ readToNull(); // "991023 991023 Daimonin Server"
+ textMsg("version 991023 991023 Daimonin SDL Client"); // we have to cheat or the server won't let us in.
+ textMsg("setup bot 1"); // We are a bot
+ readToNull(); // "0x17 bot FALSE"
+ textMsg("addme");
+ readToNull(); // 0x00 0x06 0x18 "4 QNO"
+ readToNull(); // 0x00 0x01 0x15
+ textMsg("reply L" + getUsername());
+ readToNull(); // 0x00 0x06 0x18 "4 QP0"
+ textMsg("reply " + getPassword());
+ return socket;
+ }
+
+ /** {@inheritDoc} */
+ public int run(@NotNull final List<String> args) throws Exception {
+ connect();
+ Thread.sleep(100000);
+ close();
+ return 0;
+ }
+
+} // class DaimoninConnection
Property changes on: trunk/src/net/sf/cherbot/connection/DaimoninConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Copied: trunk/src/net/sf/cherbot/connection/IRCConnection.java (from rev 110, trunk/src/net/sf/cherbot/IRCConnection.java)
===================================================================
--- trunk/src/net/sf/cherbot/connection/IRCConnection.java (rev 0)
+++ trunk/src/net/sf/cherbot/connection/IRCConnection.java 2007-07-01 17:36:00 UTC (rev 112)
@@ -0,0 +1,270 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot.connection;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.net.Socket;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import net.sf.cherbot.redel.PatternDelegator;
+import net.sf.cherbot.redel.Patterns;
+import net.sf.japi.io.args.ArgParser;
+import net.sf.japi.io.args.Option;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/** An IRCConnection represents a connection to an IRC server.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ * @see <a href="ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt">RFC 2812: Internet Relay Chat: Client Protocol</a>
+ */
+public class IRCConnection extends AbstractConnection {
+
+ /** The default IRC port. */
+ public static final int DEFAULT_IRC_PORT = 6667;
+
+ /** The username to use for IRC authentication.
+ * This is the IRC username, not the IRC nick.
+ */
+ @NotNull private String username = "cherbot";
+
+ /** The realname to use for IRC authentication.
+ * This is the realname, not the IRC nick.
+ */
+ @NotNull private String realname = "CherBot";
+
+ /** The nickname to use for IRC. */
+ @NotNull private String nickname = "CherBot";
+
+ /** The password to authenticate with NickServ or <code>null</code> if no authentication is desired. */
+ @Nullable private String nickPassword;
+
+ /** The PrintStream to write to. */
+ @Nullable private PrintWriter out;
+
+ /** The BufferedReader to read from. */
+ @Nullable private BufferedReader in;
+
+ /** The channels of this connection. */
+ private Map<String, IRCChannel> channels = new HashMap<String, IRCChannel>();
+
+ /** Creates an IRCConnection. */
+ public IRCConnection() {
+ setPort(DEFAULT_IRC_PORT);
+ }
+
+ /** Main program.
+ * For testing purposes.
+ * @param args Command line arguments
+ * @throws IOException In case of I/O problems.
+ */
+ public static void main(final String... args) throws IOException {
+ ArgParser.simpleParseAndRun(new IRCConnection(), args);
+ }
+
+ /** {@inheritDoc} */
+ @Override @NotNull public Socket connect() throws IOException {
+ final Socket socket = super.connect();
+ final PrintWriter out = this.out;
+ assert this.out != null;
+ out.println("USER " + username + " 0 * :" + realname);
+ out.println("NICK " + nickname);
+ if (nickPassword != null) {
+ out.println("PRIVMSG NICKSERV :IDENTIFY " + nickPassword);
+ }
+ out.flush();
+ return socket;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() throws IOException {
+ channels.clear();
+ try {
+ super.close();
+ } finally {
+ in = null;
+ out = null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void setSocket(@NotNull final Socket socket) throws IOException {
+ super.setSocket(socket);
+ out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), "utf-8"));
+ in = new BufferedReader(new InputStreamReader(socket.getInputStream(), "utf-8"));
+ }
+
+ /** {@inheritDoc} */
+ public int run(@NotNull final List<String> args) throws Exception {
+ connect();
+ try {
+ final PrintWriter out = this.out;
+ assert out != null;
+ final BufferedReader in = this.in;
+ assert in != null;
+ for (final String channelName : args) {
+ join(channelName);
+ }
+ final PatternDelegator delegator = new PatternDelegator(this);
+ for (String line; (line = in.readLine()) != null;) {
+ System.out.print("> ");
+ System.out.println(line);
+ delegator.process(line);
+ }
+ return 0;
+ } finally {
+ close();
+ }
+ }
+
+ /** Processes an INVITE irc message.
+ * @param actor Actor of this JOIN.
+ * @param actorIdentity Identity of the actor.
+ * @param target Target of the invitation.
+ * @param channel Channel to join.
+ */
+ @Patterns({"^:([^!]+)!([^ ]+) INVITE ([^ ]+) :(.*)$"})
+ public void processINVITE(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String target, @NotNull final String channel) {
+ System.err.println("Received invitation to " + target + " at " + channel + " by " + actor + " (" + actorIdentity + ")");
+ join(channel);
+ }
+
+ /** Processes a JOIN irc message.
+ * @param actor Actor of this JOIN.
+ * @param actorIdentity Identity of the actor.
+ * @param channel Channel to join.
+ */
+ @Patterns({"^:([^!]+)!([^ ]+) JOIN :(.*)$"})
+ public void processJOIN(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String channel) {
+ System.err.println("Joined channel " + channel);
+ // Nothing to do for a JOIN.
+ }
+
+ /** Process a MODE irc message.
+ * @param actor Actor of this MODE.
+ * @param actorIdentity Identity of the actor.
+ * @param channel Channel of the mode change.
+ * @param change Mode change.
+ * @param target Target of the mode change.
+ */
+ @Patterns({"^:([^!]+)!([^ ]+) MODE ([^ ]+) ([^ ]+) (.*?) ?$"})
+ public void processMODE(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String channel, @NotNull final String change, @NotNull final String target) {
+ System.err.println("Mode change at " + channel + ": " + change + " on " + target + " by " + actor + " (" + actorIdentity + ")");
+ // Nothing to do for a MODE.
+ }
+
+ /** Processes a PING irc message.
+ * @param server Server that requests a PONG.
+ */
+ @Patterns({"^PING :(.*)$"})
+ public void processPING(@NotNull final String server) {
+ final PrintWriter out = this.out;
+ if (out != null) {
+ out.println("PONG " + server);
+ out.flush();
+ }
+ }
+
+ /** Processes a PRIVMSG irc message.
+ * @param actor Actor of this message.
+ * @param actorIdentity Identity of the actor.
+ * @param channelName Name of the channel.
+ * @param message Message text.
+ */
+ @Patterns({"^:([^!]+)!([^ ]+) PRIVMSG ([^ ]+) :(.*)$"})
+ public void processPRIVMSG(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String channelName, @NotNull final String message) {
+ Channel channel = channels.get(channelName);
+ if (channel == null) {
+ // TODO: Create channel on demand.
+ } else {
+ // channel.send(message); // echo
+ }
+ System.out.println(channel);
+ }
+
+ /** Joins an IRC channel.
+ * @param rawChannelName name of the channel to join.
+ * @return The channel that was just joined.
+ */
+ public Channel join(@NotNull final String rawChannelName) {
+ final String channelName = rawChannelName.toLowerCase();
+ final PrintWriter out = this.out;
+ assert out != null;
+ out.println("JOIN " + channelName);
+ out.flush();
+ IRCChannel channel = channels.get(channelName);
+ if (channels.get(channelName) == null) {
+ ch...
[truncated message content] |
|
From: <chr...@us...> - 2007-07-01 17:36:40
|
Revision: 113
http://svn.sourceforge.net/cherbot/?rev=113&view=rev
Author: christianhujer
Date: 2007-07-01 10:36:38 -0700 (Sun, 01 Jul 2007)
Log Message:
-----------
Moved connection related stuff into a separate package.
Removed Paths:
-------------
trunk/src/net/sf/cherbot/AbstractCFConnection.java
trunk/src/net/sf/cherbot/AbstractChannel.java
trunk/src/net/sf/cherbot/AbstractConnection.java
trunk/src/net/sf/cherbot/Channel.java
trunk/src/net/sf/cherbot/CrossfireConnection.java
trunk/src/net/sf/cherbot/DaimoninConnection.java
trunk/src/net/sf/cherbot/IRCConnection.java
Deleted: trunk/src/net/sf/cherbot/AbstractCFConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/AbstractCFConnection.java 2007-07-01 17:36:00 UTC (rev 112)
+++ trunk/src/net/sf/cherbot/AbstractCFConnection.java 2007-07-01 17:36:38 UTC (rev 113)
@@ -1,141 +0,0 @@
-/*
- * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
- * License: GNU General Public License v2.0 or newer.
- * See file COPYING in the root directory of this project.
- */
-
-package net.sf.cherbot;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.BufferedOutputStream;
-import java.net.Socket;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.annotations.NotNull;
-import net.sf.japi.io.args.Option;
-import net.sf.japi.io.args.OptionType;
-
-/**
- * Common base class for Connections that use Crossfire-style protocols such as Angelion or Daimonin and of course Crossfire itself.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public abstract class AbstractCFConnection extends AbstractConnection {
-
- /** The username to authenticate with. */
- @NotNull private String username;
-
- /** The password to authenticate with. */
- @NotNull private String password;
-
- /** The PrintStream to write to. */
- @Nullable private OutputStream out;
-
- /** The BufferedReader to read from. */
- @Nullable private InputStream in;
-
- /** Creates an AbstractCFConnection. */
- protected AbstractCFConnection() {
- }
-
- /** Reads and discards a single message.
- * @throws IOException In case of I/O problems.
- */
- protected void readToNull() throws IOException {
- receivePacket();
- }
-
- /** Reads the next data packet.
- * @throws IOException In case of I/O problems.
- * @return The data of the next data packet.
- */
- @NotNull protected byte[] receivePacket() throws IOException {
- final InputStream in = this.in;
- assert in != null;
- final int h1 = in.read();
- final int length = h1 != -1 && (h1 & 0x80) == 0x80 ? h1 << 16 | in.read() << 8 | in.read() : h1 << 8 | in.read();
- if (length == -1) {
- throw new EOFException();
- }
- final byte[] data = new byte[length];
- for (int read = 0; read < length;) {
- final int bytesRead = in.read(data, read, length - read);
- if (bytesRead == -1) {
- throw new EOFException();
- }
- read += bytesRead;
- }
- return data;
- }
-
- /** Sends a simple text message.
- * @param msg Message to send
- * @throws IOException In case of I/O problems.
- */
- protected void textMsg(@NotNull final String msg) throws IOException {
- final OutputStream out = this.out;
- assert out != null;
- final byte[] data = msg.getBytes("utf-8");
- out.write(0xFF & data.length >> 8);
- out.write(0xFF & data.length);
- out.write(data);
- out.flush();
- }
-
- /** {@inheritDoc} */
- public void close() throws IOException {
- try {
- super.close();
- } finally {
- in = null;
- out = null;
- }
- }
-
- /** {@inheritDoc} */
- @Override public void setSocket(@NotNull final Socket socket) throws IOException {
- super.setSocket(socket);
- out = new BufferedOutputStream(socket.getOutputStream());
- in = socket.getInputStream();
- }
-
- /** Sets the username for connecting to this CF-Style server.
- * @param username Username for connecting to this CF-Style server.
- */
- @Option(type = OptionType.REQUIRED, value = {"username"})
- public void setUsername(@NotNull final String username) {
- this.username = username;
- }
-
- /** Sets the password for connecting to this CF-Style server.
- * @param password Password for connecting to this CF-Style server.
- */
- @Option(type = OptionType.REQUIRED, value = {"password"})
- public void setPassword(@NotNull final String password) {
- this.password = password;
- }
-
- /** {@inheritDoc} */
- // Overridden because for CF-Style servers the host is optional.
- @Option({"host"})
- public void setHost(@NotNull final String host) {
- super.setHost(host);
- }
-
- @NotNull public String getUsername() {
- return username;
- }
-
- @NotNull public String getPassword() {
- return password;
- }
-
- @Nullable protected OutputStream getOut() {
- return out;
- }
-
- @Nullable protected InputStream getIn() {
- return in;
- }
-} // class AbstractCFConnection
Deleted: trunk/src/net/sf/cherbot/AbstractChannel.java
===================================================================
--- trunk/src/net/sf/cherbot/AbstractChannel.java 2007-07-01 17:36:00 UTC (rev 112)
+++ trunk/src/net/sf/cherbot/AbstractChannel.java 2007-07-01 17:36:38 UTC (rev 113)
@@ -1,33 +0,0 @@
-/*
- * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
- * License: GNU General Public License v2.0 or newer.
- * See file COPYING in the root directory of this project.
- */
-
-package net.sf.cherbot;
-
-import org.jetbrains.annotations.Nullable;
-
-/** Abstract base implementation of {@link Channel}.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public abstract class AbstractChannel implements Channel {
-
- /** The name of this channel.
- * Maybe <code>null</code> if it's the default / no channel.
- */
- @Nullable private String channelName;
-
- /** Creates a Channel.
- * @param channelName name of this channel.
- */
- protected AbstractChannel(@Nullable final String channelName) {
- this.channelName = channelName;
- }
-
- /** {@inheritDoc} */
- @Nullable public String getChannelName() {
- return channelName;
- }
-
-} // class Channel
Deleted: trunk/src/net/sf/cherbot/AbstractConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/AbstractConnection.java 2007-07-01 17:36:00 UTC (rev 112)
+++ trunk/src/net/sf/cherbot/AbstractConnection.java 2007-07-01 17:36:38 UTC (rev 113)
@@ -1,126 +0,0 @@
-/*
- * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
- * License: GNU General Public License v2.0 or newer.
- * See file COPYING in the root directory of this project.
- */
-
-package net.sf.cherbot;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.Serializable;
-import java.net.Socket;
-import net.sf.japi.io.args.BasicCommand;
-import net.sf.japi.io.args.Option;
-import net.sf.japi.io.args.OptionType;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/** An AbstractConnection represents the connection to a server and has one or more channels.
- * Connections are implemented as command bean.
- * That means:
- * <ul>
- * <li>
- * An object does not reflect an established connection but has a state.
- * The connection state can be established or not established.
- * </li>
- * <li>
- * For testing, trying or standalone usage it is possible to "run" a connection as a standalone java program from the command line.
- * </li>
- * </ul>
- * To query whether the connection is open, get the Socket of the connection and check the socket.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public abstract class AbstractConnection extends BasicCommand implements Closeable, Serializable {
-
- /** The host to connect to.
- * @serial include
- */
- @Nullable private String host;
-
- /** The port to connect to.
- * @serial include
- */
- private int port;
-
- /** The socket for the connection. */
- @Nullable private transient Socket socket;
-
- /** Sets the host of the IRC server to connect to.
- * @param host Host of the IRC server.
- */
- @Option(type = OptionType.REQUIRED, value = {"host"})
- public void setHost(@NotNull final String host) {
- this.host = host;
- }
-
- /** Returns the host to connect to.
- * @return The host to connect to.
- */
- @Nullable public String getHost() {
- return host;
- }
-
- /** Sets the port of the IRC server to connect to.
- * @param port Port of the IRC server.
- */
- @Option({"port"})
- public void setPort(@NotNull final Integer port) {
- this.port = port;
- }
-
- /** Returns the port to connect to.
- * @return The port to connect to.
- */
- public int getPort() {
- return port;
- }
-
- /** Establishes this connection.
- * Implementations of this method must invoke {@link #setSocket(Socket)}.
- * @return The socket created for this connection.
- * @throws IOException in case of connection problems.
- */
- @NotNull public Socket connect() throws IOException {
- final Socket socket = new Socket(host, port);
- setSocket(socket);
- return socket;
- }
-
- /** {@inheritDoc} */
- public void close() throws IOException {
- try {
- final Socket socket = this.socket;
- if (socket != null) {
- socket.close();
- }
- } finally {
- socket = null;
- }
- }
-
- /** Returns whether this connection is established.
- * @return <code>true</code> if this connection is established, otherwise <code>false</code>.
- * @see Socket#isConnected()
- */
- public boolean isConnected() {
- return socket != null && socket.isConnected();
- }
-
- /** Sets the socket for the connection.
- * Use this method if you want to create a connection on an existing socket instead of letting this Connection automatically create its own socket.
- * @param socket Socket for the connection.
- * @throws IOException In case of I/O problems when setting the socket. This is useful for overriding methods which may be interested in using the socket when it's being set.
- */
- public void setSocket(@NotNull final Socket socket) throws IOException {
- this.socket = socket;
- }
-
- /** Returns the socket for the connection.
- * @return The socket for the connection.
- */
- @Nullable public Socket getSocket() {
- return socket;
- }
-
-} // class AbstractConnection
Deleted: trunk/src/net/sf/cherbot/Channel.java
===================================================================
--- trunk/src/net/sf/cherbot/Channel.java 2007-07-01 17:36:00 UTC (rev 112)
+++ trunk/src/net/sf/cherbot/Channel.java 2007-07-01 17:36:38 UTC (rev 113)
@@ -1,28 +0,0 @@
-/*
- * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
- * License: GNU General Public License v2.0 or newer.
- * See file COPYING in the root directory of this project.
- */
-
-package net.sf.cherbot;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/** A Channel uniquely identifies a protocol (type) / server / channel combination.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public interface Channel {
-
- /** Sends a message to this channel.
- * @param msg Message to send
- */
- void send(@NotNull String msg);
-
- /** Returns the name of this channel.
- * Maybe <code>null</code> if it's the default / no channel.
- * @return The channel of this channel or <code>null</code> if default / no channel.
- */
- @Nullable String getChannelName();
-
-} // interface Channel
Deleted: trunk/src/net/sf/cherbot/CrossfireConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/CrossfireConnection.java 2007-07-01 17:36:00 UTC (rev 112)
+++ trunk/src/net/sf/cherbot/CrossfireConnection.java 2007-07-01 17:36:38 UTC (rev 113)
@@ -1,66 +0,0 @@
-/*
- * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
- * License: GNU General Public License v2.0 or newer.
- * See file COPYING in the root directory of this project.
- */
-
-package net.sf.cherbot;
-
-import java.io.IOException;
-import java.net.Socket;
-import java.util.List;
-import net.sf.japi.io.args.ArgParser;
-import org.jetbrains.annotations.NotNull;
-
-/** A CrossfireConnection represents a connection to a Crossfire server.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public class CrossfireConnection extends AbstractCFConnection {
-
- /** Default server host. */
- //@NotNull public static final String DEFAULT_CROSSFIRE_HOST = "crossfire.metalforge.net";
- @NotNull public static final String DEFAULT_CROSSFIRE_HOST = "127.0.0.1";
-
- /** Default server port. */
- public static final int DEFAULT_CROSSFIRE_PORT = 13327;
-
- /** Creates a CrossfireConnection. */
- public CrossfireConnection() {
- setHost(DEFAULT_CROSSFIRE_HOST);
- setPort(DEFAULT_CROSSFIRE_PORT);
- }
-
- /** Main program.
- * @param args Command line arguments.
- */
- public static void main(final String... args) {
- ArgParser.simpleParseAndRun(new CrossfireConnection(), args);
- }
-
- /** {@inheritDoc} */
- @NotNull @Override public Socket connect() throws IOException {
- final Socket socket = super.connect();
- readToNull();
- textMsg("version 1023 1023 CherBot");
- textMsg("setup bot 1");
- readToNull();
- readToNull();
- textMsg("addme");
- readToNull();
- textMsg("reply " + getUsername());
- readToNull();
- textMsg("reply " + getPassword());
- return socket;
- }
-
- /** {@inheritDoc} */
- public int run(@NotNull final List<String> args) throws Exception {
- connect();
- for (int i = 0; i < 10000; i++) {
- readToNull();
- }
- close();
- return 0;
- }
-
-} // class CrossfireConnection
Deleted: trunk/src/net/sf/cherbot/DaimoninConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/DaimoninConnection.java 2007-07-01 17:36:00 UTC (rev 112)
+++ trunk/src/net/sf/cherbot/DaimoninConnection.java 2007-07-01 17:36:38 UTC (rev 113)
@@ -1,64 +0,0 @@
-/*
- * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
- * License: GNU General Public License v2.0 or newer.
- * See file COPYING in the root directory of this project.
- */
-
-package net.sf.cherbot;
-
-import java.io.IOException;
-import java.net.Socket;
-import java.util.List;
-import net.sf.japi.io.args.ArgParser;
-import org.jetbrains.annotations.NotNull;
-
-/** A DaimoninConnection represents a connection to a Daimonin server.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public class DaimoninConnection extends AbstractCFConnection {
-
- /** Default server host. */
- //@NotNull public static final String DEFAULT_DAIMONIN_HOST = "daimonin.game-server.cc";
- @NotNull public static final String DEFAULT_DAIMONIN_HOST = "127.0.0.1";
-
- /** Default server port. */
- public static final int DEFAULT_DAIMONIN_PORT = 13327;
-
- /** Creates a DaimoninConnection. */
- public DaimoninConnection() {
- setHost(DEFAULT_DAIMONIN_HOST);
- setPort(DEFAULT_DAIMONIN_PORT);
- }
-
- /** Main program.
- * @param args Command line arguments.
- */
- public static void main(final String... args) {
- ArgParser.simpleParseAndRun(new DaimoninConnection(), args);
- }
-
- /** {@inheritDoc} */
- @NotNull @Override public Socket connect() throws IOException {
- final Socket socket = super.connect();
- readToNull(); // "991023 991023 Daimonin Server"
- textMsg("version 991023 991023 Daimonin SDL Client"); // we have to cheat or the server won't let us in.
- textMsg("setup bot 1"); // We are a bot
- readToNull(); // "0x17 bot FALSE"
- textMsg("addme");
- readToNull(); // 0x00 0x06 0x18 "4 QNO"
- readToNull(); // 0x00 0x01 0x15
- textMsg("reply L" + getUsername());
- readToNull(); // 0x00 0x06 0x18 "4 QP0"
- textMsg("reply " + getPassword());
- return socket;
- }
-
- /** {@inheritDoc} */
- public int run(@NotNull final List<String> args) throws Exception {
- connect();
- Thread.sleep(100000);
- close();
- return 0;
- }
-
-} // class DaimoninConnection
Deleted: trunk/src/net/sf/cherbot/IRCConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/IRCConnection.java 2007-07-01 17:36:00 UTC (rev 112)
+++ trunk/src/net/sf/cherbot/IRCConnection.java 2007-07-01 17:36:38 UTC (rev 113)
@@ -1,270 +0,0 @@
-/*
- * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
- * License: GNU General Public License v2.0 or newer.
- * See file COPYING in the root directory of this project.
- */
-
-package net.sf.cherbot;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.net.Socket;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import net.sf.cherbot.redel.PatternDelegator;
-import net.sf.cherbot.redel.Patterns;
-import net.sf.japi.io.args.ArgParser;
-import net.sf.japi.io.args.Option;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/** An IRCConnection represents a connection to an IRC server.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- * @see <a href="ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt">RFC 2812: Internet Relay Chat: Client Protocol</a>
- */
-public class IRCConnection extends AbstractConnection {
-
- /** The default IRC port. */
- public static final int DEFAULT_IRC_PORT = 6667;
-
- /** The username to use for IRC authentication.
- * This is the IRC username, not the IRC nick.
- */
- @NotNull private String username = "cherbot";
-
- /** The realname to use for IRC authentication.
- * This is the realname, not the IRC nick.
- */
- @NotNull private String realname = "CherBot";
-
- /** The nickname to use for IRC. */
- @NotNull private String nickname = "CherBot";
-
- /** The password to authenticate with NickServ or <code>null</code> if no authentication is desired. */
- @Nullable private String nickPassword;
-
- /** The PrintStream to write to. */
- @Nullable private PrintWriter out;
-
- /** The BufferedReader to read from. */
- @Nullable private BufferedReader in;
-
- /** The channels of this connection. */
- private Map<String, IRCChannel> channels = new HashMap<String, IRCChannel>();
-
- /** Creates an IRCConnection. */
- public IRCConnection() {
- setPort(DEFAULT_IRC_PORT);
- }
-
- /** Main program.
- * For testing purposes.
- * @param args Command line arguments
- * @throws IOException In case of I/O problems.
- */
- public static void main(final String... args) throws IOException {
- ArgParser.simpleParseAndRun(new IRCConnection(), args);
- }
-
- /** {@inheritDoc} */
- @Override @NotNull public Socket connect() throws IOException {
- final Socket socket = super.connect();
- final PrintWriter out = this.out;
- assert this.out != null;
- out.println("USER " + username + " 0 * :" + realname);
- out.println("NICK " + nickname);
- if (nickPassword != null) {
- out.println("PRIVMSG NICKSERV :IDENTIFY " + nickPassword);
- }
- out.flush();
- return socket;
- }
-
- /** {@inheritDoc} */
- @Override public void close() throws IOException {
- channels.clear();
- try {
- super.close();
- } finally {
- in = null;
- out = null;
- }
- }
-
- /** {@inheritDoc} */
- @Override public void setSocket(@NotNull final Socket socket) throws IOException {
- super.setSocket(socket);
- out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), "utf-8"));
- in = new BufferedReader(new InputStreamReader(socket.getInputStream(), "utf-8"));
- }
-
- /** {@inheritDoc} */
- public int run(@NotNull final List<String> args) throws Exception {
- connect();
- try {
- final PrintWriter out = this.out;
- assert out != null;
- final BufferedReader in = this.in;
- assert in != null;
- for (final String channelName : args) {
- join(channelName);
- }
- final PatternDelegator delegator = new PatternDelegator(this);
- for (String line; (line = in.readLine()) != null;) {
- System.out.print("> ");
- System.out.println(line);
- delegator.process(line);
- }
- return 0;
- } finally {
- close();
- }
- }
-
- /** Processes an INVITE irc message.
- * @param actor Actor of this JOIN.
- * @param actorIdentity Identity of the actor.
- * @param target Target of the invitation.
- * @param channel Channel to join.
- */
- @Patterns({"^:([^!]+)!([^ ]+) INVITE ([^ ]+) :(.*)$"})
- public void processINVITE(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String target, @NotNull final String channel) {
- System.err.println("Received invitation to " + target + " at " + channel + " by " + actor + " (" + actorIdentity + ")");
- join(channel);
- }
-
- /** Processes a JOIN irc message.
- * @param actor Actor of this JOIN.
- * @param actorIdentity Identity of the actor.
- * @param channel Channel to join.
- */
- @Patterns({"^:([^!]+)!([^ ]+) JOIN :(.*)$"})
- public void processJOIN(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String channel) {
- System.err.println("Joined channel " + channel);
- // Nothing to do for a JOIN.
- }
-
- /** Process a MODE irc message.
- * @param actor Actor of this MODE.
- * @param actorIdentity Identity of the actor.
- * @param channel Channel of the mode change.
- * @param change Mode change.
- * @param target Target of the mode change.
- */
- @Patterns({"^:([^!]+)!([^ ]+) MODE ([^ ]+) ([^ ]+) (.*?) ?$"})
- public void processMODE(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String channel, @NotNull final String change, @NotNull final String target) {
- System.err.println("Mode change at " + channel + ": " + change + " on " + target + " by " + actor + " (" + actorIdentity + ")");
- // Nothing to do for a MODE.
- }
-
- /** Processes a PING irc message.
- * @param server Server that requests a PONG.
- */
- @Patterns({"^PING :(.*)$"})
- public void processPING(@NotNull final String server) {
- final PrintWriter out = this.out;
- if (out != null) {
- out.println("PONG " + server);
- out.flush();
- }
- }
-
- /** Processes a PRIVMSG irc message.
- * @param actor Actor of this message.
- * @param actorIdentity Identity of the actor.
- * @param channelName Name of the channel.
- * @param message Message text.
- */
- @Patterns({"^:([^!]+)!([^ ]+) PRIVMSG ([^ ]+) :(.*)$"})
- public void processPRIVMSG(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String channelName, @NotNull final String message) {
- Channel channel = channels.get(channelName);
- if (channel == null) {
- // TODO: Create channel on demand.
- } else {
- // channel.send(message); // echo
- }
- System.out.println(channel);
- }
-
- /** Joins an IRC channel.
- * @param rawChannelName name of the channel to join.
- * @return The channel that was just joined.
- */
- public Channel join(@NotNull final String rawChannelName) {
- final String channelName = rawChannelName.toLowerCase();
- final PrintWriter out = this.out;
- assert out != null;
- out.println("JOIN " + channelName);
- out.flush();
- IRCChannel channel = channels.get(channelName);
- if (channels.get(channelName) == null) {
- channel = new IRCChannel(channelName);
- channels.put(channelName, channel);
- }
- return channel;
- }
-
- /** Sets the username to use for connecting to the IRC server.
- * Note that this is the IRC username, not the nick.
- * @param username Username to use for IRC.
- */
- @Option({"username"})
- public void setUsername(@NotNull final String username) {
- this.username = username;
- }
-
- /** Sets the realname to use for connecting to the IRC server.
- * Note that this is the IRC realname, not the nick.
- * @param realname Realname to use for IRC.
- */
- @Option({"realname"})
- public void setRealname(@NotNull final String realname) {
- this.realname = realname;
- }
-
- /** Sets the nickname to use for connecting to the IRC server.
- * @param nickname Nickname to use for IRC.
- */
- @Option({"nickname"})
- public void setNickname(@NotNull final String nickname) {
- this.nickname = nickname;
- }
-
- /** Sets the password to use for authentication with NickServ.
- * Setting it to <code>null</code> means to not authenticate with NickServ.
- * @param nickPassword Password to use for authentication with NickServ.
- */
- @Option({"nickPassword"})
- public void setNickPassword(@Nullable final String nickPassword) {
- this.nickPassword = nickPassword;
- }
-
- /** Represents a Channel on IRC.
- * This can be used for both, real channels (whith channel names starting with '#') and direct communication channels with nicks.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
- private class IRCChannel extends AbstractChannel {
-
- /** Creates an IRCChannel.
- * @param channelName name of this channel.
- */
- IRCChannel(@NotNull final String channelName) {
- super(channelName);
- }
-
- /** {@inheritDoc} */
- public void send(@NotNull final String msg) {
- final PrintWriter out = IRCConnection.this.out;
- if (out != null) {
- out.println("PRIVMSG " + getChannelName() + " :" + msg);
- out.flush();
- }
- }
-
- } // class IRCChannel
-
-} // class IRCConnection
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-07-07 12:07:48
|
Revision: 116
http://svn.sourceforge.net/cherbot/?rev=116&view=rev
Author: christianhujer
Date: 2007-07-07 05:07:45 -0700 (Sat, 07 Jul 2007)
Log Message:
-----------
Implemented rudimentary configurator. Servers can now be added or listed.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/Configurator.java
trunk/src/net/sf/cherbot/Server.java
trunk/src/net/sf/cherbot/ServerModule.java
Modified: trunk/src/net/sf/cherbot/Configurator.java
===================================================================
--- trunk/src/net/sf/cherbot/Configurator.java 2007-07-07 12:07:08 UTC (rev 115)
+++ trunk/src/net/sf/cherbot/Configurator.java 2007-07-07 12:07:45 UTC (rev 116)
@@ -6,18 +6,105 @@
package net.sf.cherbot;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.List;
+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;
-import java.util.List;
-/** The Configurator creates or modifies the initial server database for CherBot.
+/** The Configurator creates or modifies the server database for CherBot.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class Configurator extends BasicCommand {
+ /** The default database URL. */
+ @NotNull private static final String DEFAULT_DATABASE_URL = "jdbc:derby:cherbotdb;create=true";
+
+ /** The database URL. */
+ @NotNull private String databaseURL = DEFAULT_DATABASE_URL;
+
+ /** The JDBC connection for data persistence. */
+ @NotNull private Connection connection;
+
+ /** The server module. */
+ @NotNull private ServerModule serverModule = new ServerModule();
+
+ /** The command mode. */
+ @NotNull private CommandMode commandMode = CommandMode.LIST;
+
+ /** Main program.
+ * @param args Command line arguments (try --help)
+ */
+ public static void main(@NotNull final String... args) {
+ ArgParser.simpleParseAndRun(new Configurator(), args);
+ }
+
/** {@inheritDoc} */
public int run(@NotNull final List<String> args) throws Exception {
+ initConnection();
+ serverModule.load(connection);
+ switch (commandMode) {
+ case LIST:
+ for (final Server server : serverModule.getServers()) {
+ System.out.println(server);
+ }
+ break;
+ case ADD:
+ final Server server = new Server(0, args.get(0), Integer.parseInt(args.get(1)), args.get(2));
+ serverModule.add(server);
+ serverModule.save(connection);
+ System.out.println("Successfully added " + server);
+ break;
+ }
return 0;
}
+ /** Initializes the connection.
+ * @throws SQLException in case of SQL problems.
+ */
+ private void initConnection() throws SQLException {
+ synchronized (this) {
+ if (connection == null) {
+ connection = DriverManager.getConnection(databaseURL);
+ }
+ }
+ }
+
+ /** Lists the current server database. */
+ @Option({"l", "list"})
+ public void list() {
+ commandMode = CommandMode.LIST;
+ }
+
+ /** Adds the specified server spec. */
+ @Option({"a", "add"})
+ public void add() {
+ commandMode = CommandMode.ADD;
+ }
+
+ /** 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;
+ }
+
+ /** Enumeration of supported command modes.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+ private enum CommandMode {
+ ADD, LIST
+ }
+
} // class Configurator
Modified: trunk/src/net/sf/cherbot/Server.java
===================================================================
--- trunk/src/net/sf/cherbot/Server.java 2007-07-07 12:07:08 UTC (rev 115)
+++ trunk/src/net/sf/cherbot/Server.java 2007-07-07 12:07:45 UTC (rev 116)
@@ -25,15 +25,20 @@
/** The port of this server. */
private int port;
+ /** The protocol of this server. */
+ @NotNull private String protocol;
+
/** Create a Server.
* @param id Id of this server.
* @param hostname Hostname of this server.
* @param port Port of this server.
+ * @param protocol Protocol of this server.
*/
- public Server(final int id, @NotNull final String hostname, final int port) {
+ public Server(final int id, @NotNull final String hostname, final int port, @NotNull final String protocol) {
this.id = id;
this.hostname = hostname;
this.port = port;
+ this.protocol = protocol;
}
/** Returns the id of this server.
@@ -71,4 +76,23 @@
this.port = port;
}
+ /** Returns the protocol of this server.
+ * @return The protocol of this server.
+ */
+ @NotNull public String getProtocol() {
+ return protocol;
+ }
+
+ /** Sets the protocol of this server.
+ * @param protocol The protocol of this server.
+ */
+ public void setProtocol(@NotNull final String protocol) {
+ this.protocol = protocol;
+ }
+
+ /** {@inheritDoc} */
+ @NotNull @Override public String toString() {
+ return protocol + "://" + hostname + ":" + port + "/";
+ }
+
} // class Server
Modified: trunk/src/net/sf/cherbot/ServerModule.java
===================================================================
--- trunk/src/net/sf/cherbot/ServerModule.java 2007-07-07 12:07:08 UTC (rev 115)
+++ trunk/src/net/sf/cherbot/ServerModule.java 2007-07-07 12:07:45 UTC (rev 116)
@@ -13,6 +13,7 @@
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
+import java.util.Collections;
import net.sf.cherbot.connection.Channel;
/** Module for managing servers.
@@ -25,13 +26,15 @@
/** {@inheritDoc} */
public void load(@NotNull final Connection con) throws SQLException {
- final PreparedStatement stmt = con.prepareStatement("SELECT id, serverId, name FROM Player");
+ createTables(con);
+ final PreparedStatement stmt = con.prepareStatement("SELECT id, host, port, protocol FROM Server");
final ResultSet result = stmt.executeQuery();
while (result.next()) {
final int id = result.getInt(1);
final String host = result.getString(2);
final int port = result.getInt(3);
- servers.add(new Server(id, host, port));
+ final String protocol = result.getString(4);
+ servers.add(new Server(id, host, port, protocol));
}
stmt.close();
}
@@ -40,21 +43,21 @@
public void save(@NotNull final Connection con) throws SQLException {
createTables(con);
final PreparedStatement lookup = con.prepareStatement("SELECT id FROM Server WHERE id = ?");
- final PreparedStatement update = con.prepareStatement("UPDATE Server SET host = ?, port = ? WHERE id = ?");
- final PreparedStatement insert = con.prepareStatement("INSERT INTO Server (id, host, port) VALUES (?, ?, ?)");
+ final PreparedStatement update = con.prepareStatement("UPDATE Server SET host = ?, port = ?, protocol = ? WHERE id = ?");
+ final PreparedStatement insert = con.prepareStatement("INSERT INTO Server (host, port, protocol) VALUES (?, ?, ?)");
for (final Server server : servers) {
lookup.setInt(1, server.getId());
+ final PreparedStatement stmt;
if (lookup.executeQuery().next()) {
- update.setString(1, server.getHostname());
- update.setInt(2, server.getPort());
- update.setInt(3, server.getId());
- update.executeUpdate();
+ stmt = update;
+ update.setInt(4, server.getId());
} else {
- insert.setInt(1, server.getId());
- insert.setString(2, server.getHostname());
- insert.setInt(3, server.getPort());
- insert.executeUpdate();
+ stmt = insert;
}
+ stmt.setString(1, server.getHostname());
+ stmt.setInt(2, server.getPort());
+ stmt.setString(3, server.getProtocol());
+ stmt.executeUpdate();
}
lookup.close();
update.close();
@@ -67,11 +70,11 @@
*/
private void createTables(@NotNull final Connection con) throws SQLException {
try {
- final PreparedStatement stmt = con.prepareStatement("CREATE TABLE Server (id INT, host VARCHAR(64), port INT");
+ final PreparedStatement stmt = con.prepareStatement("CREATE TABLE Server (id INT NOT NULL GENERATED ALWAYS AS IDENTITY, host VARCHAR(64), port INT, protocol VARCHAR(64))");
stmt.execute();
stmt.close();
} catch (final SQLException ignore) {
- System.err.println(ignore);
+ // System.err.println(ignore);
}
}
@@ -79,4 +82,18 @@
public void parseMessage(@NotNull final Channel channel, @NotNull final String msg) {
}
+ /** Returns a list of servers.
+ * @return a list of servers
+ */
+ public List<Server> getServers() {
+ return Collections.unmodifiableList(servers);
+ }
+
+ /** Adds a server.
+ * @param server Server to add.
+ */
+ public void add(@NotNull final Server server) {
+ servers.add(server);
+ }
+
} // class ServerModule
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-07-07 12:38:56
|
Revision: 117
http://svn.sourceforge.net/cherbot/?rev=117&view=rev
Author: christianhujer
Date: 2007-07-07 05:38:54 -0700 (Sat, 07 Jul 2007)
Log Message:
-----------
Added automatic setting of id in case of new records.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/Server.java
trunk/src/net/sf/cherbot/ServerModule.java
Modified: trunk/src/net/sf/cherbot/Server.java
===================================================================
--- trunk/src/net/sf/cherbot/Server.java 2007-07-07 12:07:45 UTC (rev 116)
+++ trunk/src/net/sf/cherbot/Server.java 2007-07-07 12:38:54 UTC (rev 117)
@@ -41,6 +41,13 @@
this.protocol = protocol;
}
+ /** Sets the id of this server.
+ * @param id The id of this server.
+ */
+ public void setId(final int id) {
+ this.id = id;
+ }
+
/** Returns the id of this server.
* @return The id of this server.
*/
@@ -92,7 +99,7 @@
/** {@inheritDoc} */
@NotNull @Override public String toString() {
- return protocol + "://" + hostname + ":" + port + "/";
+ return protocol + "://" + hostname + ":" + port + "/ " + id;
}
} // class Server
Modified: trunk/src/net/sf/cherbot/ServerModule.java
===================================================================
--- trunk/src/net/sf/cherbot/ServerModule.java 2007-07-07 12:07:45 UTC (rev 116)
+++ trunk/src/net/sf/cherbot/ServerModule.java 2007-07-07 12:38:54 UTC (rev 117)
@@ -45,19 +45,28 @@
final PreparedStatement lookup = con.prepareStatement("SELECT id FROM Server WHERE id = ?");
final PreparedStatement update = con.prepareStatement("UPDATE Server SET host = ?, port = ?, protocol = ? WHERE id = ?");
final PreparedStatement insert = con.prepareStatement("INSERT INTO Server (host, port, protocol) VALUES (?, ?, ?)");
+ final PreparedStatement getId = con.prepareStatement("VALUES IDENTITY_VAL_LOCAL()");
for (final Server server : servers) {
+ final boolean newRecord;
lookup.setInt(1, server.getId());
final PreparedStatement stmt;
- if (lookup.executeQuery().next()) {
+ newRecord = !lookup.executeQuery().next();
+ if (newRecord) {
+ stmt = insert;
+ } else {
stmt = update;
update.setInt(4, server.getId());
- } else {
- stmt = insert;
}
stmt.setString(1, server.getHostname());
stmt.setInt(2, server.getPort());
stmt.setString(3, server.getProtocol());
stmt.executeUpdate();
+ if (newRecord) {
+ final ResultSet rs = getId.executeQuery();
+ rs.next();
+ server.setId(rs.getInt(1));
+ rs.close();
+ }
}
lookup.close();
update.close();
@@ -85,7 +94,7 @@
/** Returns a list of servers.
* @return a list of servers
*/
- public List<Server> getServers() {
+ @NotNull public List<Server> getServers() {
return Collections.unmodifiableList(servers);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|