|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.player.PlayerManager
This class implements an extremely simple persistence mechanism. It acts as a sort of player database, using the filesystem to store "player files". Player files have identical syntax to game archetypes - they're stored as a list of properties.
The PlayerManager class is reponsible for creating new players, as well as retrieving and saving existing players. Eventually it may serve as a gateway to a real database.
Nested Class Summary | |
static interface |
PlayerManager.OfflineProperties
Constants for return values from setOfflineProperties |
Field Summary | |
static int |
MAX_CHARACTERS
|
static int |
MAX_PLAYER_NAME_LENGTH
|
static int |
MIN_PLAYER_NAME_LENGTH
|
Constructor Summary | |
PlayerManager()
|
Method Summary | |
static Player |
createGuestPlayer()
Creates a new guest player for a guest visitor. |
static java.util.List |
getAltsForPlayer(java.lang.String email)
Returns a list of the names of all the players associated with a given email address. |
static java.lang.Object[] |
getOfflineProperties(java.lang.String player,
java.lang.String[] names)
Returns a list of properties from an offline player. |
static java.lang.String |
getPathToPlayer(java.lang.String name)
Returns the absolute path to the player file, given the name of the player. |
static Player |
loadPlayer(java.lang.String name)
Loads saved player data into a Player object. |
static boolean |
playerExists(java.lang.String name)
Returns true if the specified player file exists. |
static java.lang.String |
readPlayerFile(Player p)
Returns the contents of the player's save-file as a string. |
static boolean |
savePlayer(Player p)
Saves the specified player. |
static void |
saveVisitor(java.lang.String name,
java.lang.String domain,
java.lang.String contents)
Saves a visitor from another server. |
static void |
setAsynchronousSaves()
Turns saves back to async-mode, using a thread pool. |
static void |
setFileCache(boolean cache)
Turns disk-file caching on and off. |
static int |
setOfflineProperties(java.lang.String player,
java.lang.String[] propnames,
java.lang.Object[] props)
Sets properties on an offline player. |
static void |
setSynchronousSaves()
Tells the PlayerManager to save players on the current thread, rather than using a thread pool. |
static void |
throwExceptions(boolean x)
Wizards: Don't call this under pain of death. |
static java.lang.String |
toXML(Player p)
Returns serialized XML for a player. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int MIN_PLAYER_NAME_LENGTH
public static final int MAX_PLAYER_NAME_LENGTH
public static final int MAX_CHARACTERS
Constructor Detail |
public PlayerManager()
Method Detail |
public static java.lang.String getPathToPlayer(java.lang.String name)
name
- the player name. case doesn't matter.
public static boolean playerExists(java.lang.String name)
name
- the name of the player to check onpublic static Player loadPlayer(java.lang.String name) throws java.lang.Exception
name
- the name of the saved player to load
any
- Exception with a detail message for the client
java.lang.Exception
public static boolean savePlayer(Player p)
public static java.lang.String readPlayerFile(Player p) throws java.io.IOException
p
- the name of the player whose save-file is wanted
java.io.IOException
public static void saveVisitor(java.lang.String name, java.lang.String domain, java.lang.String contents) throws java.lang.Exception
name
- the name of the playerdomain
- the domain/machine name of the player's home servercontents
- the contents of the player's save file
any
- Exception if the directory for that server
couldn't be created, or any of the arguments are invalid,
or anything else went wrong.
java.lang.Exception
public static Player createGuestPlayer() throws java.lang.Exception
java.lang.Exception
public static java.lang.String toXML(Player p) throws java.lang.Exception
p
- the player to serialize
any
- Exception if we couldn't do it
for some reason (error message in the exception).
java.lang.Exception
public static void setSynchronousSaves()
public static void setAsynchronousSaves()
public static void setFileCache(boolean cache)
cache
- true to write the player file into the filesystem
after saving them into the database, false to just write the
database. By default, the file cache is on, and the
backfill tool passes false for this parameter to turn it off.public static int setOfflineProperties(java.lang.String player, java.lang.String[] propnames, java.lang.Object[] props)
For boolean properties, the value should be a java.lang.Boolean.
For int properties, the value should be a java.lang.Integer.
For long properties, the value should be a java.lang.Long.
For double properties, the value should be a java.lang.Double.
player
- the name of the player to modifypropnames
- an array of property nams you'll be modifyingprops
- an array of props corresponding to the property names
java.lang.IllegalArgumentException
- if any of the params
are null, or if the array lengths aren't the same, or if
any of the array values are null.public static java.lang.Object[] getOfflineProperties(java.lang.String player, java.lang.String[] names)
player
- the player to querynames
- an array of property names to look up
java.lang.IllegalArgumentException
- if any param is nullpublic static java.util.List getAltsForPlayer(java.lang.String email)
email
- the email to look up
public static void throwExceptions(boolean x)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |