Interface CharacterProvider
public interface CharacterProvider
This interface controls the storage of character related documents. The
basic concept is that each character can have attachments of a specific
and
invalid reference
format
.
Examples for those attachments may be portrait image (type CHARACTER, format IMAGE)
serialized character data (type CHARACTER, format RULESPECIFIC) or a
background story (type BACKGROUND, format PDF).invalid reference
type
All the attachments are collected in a CharacterHandle.
CharacterHandles itself belong to a
and
have a invalid reference
de.rpgframework.core.PlayerRoleplayingSystem assigned.
// Get the player that represents yourself
Player myself = RPGFrameworkLoader.getInstance().getPlayerService().getMyself();
// Obtain an instance of the character provider ...
CharacterProvider charProv = RPGFrameworkLoader.getInstance().getCharacterProvider();
// Obtain an instance of the character provider ...
for (CharacterHandle handle : charProv.getCharacters(myself)) {
// ... do something
}
-
Method Summary
Modifier and TypeMethodDescriptionaddAttachment(CharacterHandle handle, Attachment.Type type, Attachment.Format format, String filename, byte[] data) Adding an attachment to a character.createCharacter(String charName, de.rpgframework.core.RoleplayingSystem ruleSystem) Create a new CharacterHandle as a container for attachments for the local user.voiddeleteAttachment(CharacterHandle handle, Attachment attach) Remove an attachment from a character.voiddeleteCharacter(CharacterHandle handle) Delete a character and all his attachments,getCharacter(String charName, de.rpgframework.core.RoleplayingSystem ruleSystem) Return an eventually existing character - or null if it doesn't exist yet.getFirstAttachment(CharacterHandle handle, Attachment.Type type, Attachment.Format format) Get a specific attachment with datagetMyCharacters(de.rpgframework.core.RoleplayingSystem ruleSystem) Get all characters of a given player belonging to a specific roleplaying system.voidbooleanlistAttachments(CharacterHandle handle) Get a list of attachments without loading the datavoidmodifyAttachment(CharacterHandle handle, Attachment attach) Write modifications made to this attachment to storage.voidrenameCharacter(CharacterHandle handle, String newName) Rename a character and all his attachments,voidsetListener(CharacterProviderListener callback)
-
Method Details
-
setListener
-
getCharacter
CharacterHandle getCharacter(String charName, de.rpgframework.core.RoleplayingSystem ruleSystem) throws IOException Return an eventually existing character - or null if it doesn't exist yet.- Parameters:
charName- Name of the characterruleSystem- The roleplaying system of the character- Returns:
- The created handle
- Throws:
IOException- Error executing operation - e.g. on directory creation or missing internet connection
-
createCharacter
CharacterHandle createCharacter(String charName, de.rpgframework.core.RoleplayingSystem ruleSystem) throws IOException Create a new CharacterHandle as a container for attachments for the local user.- Parameters:
charName- Name of the characterruleSystem- The roleplaying system of the character- Returns:
- The created handle
- Throws:
IOException- Error executing operation - e.g. on directory creation or missing internet connection
-
listAttachments
Get a list of attachments without loading the data- Parameters:
handle-- Returns:
- Throws:
IOException
-
getFirstAttachment
Attachment getFirstAttachment(CharacterHandle handle, Attachment.Type type, Attachment.Format format) throws IOException Get a specific attachment with data- Throws:
IOException
-
addAttachment
Attachment addAttachment(CharacterHandle handle, Attachment.Type type, Attachment.Format format, String filename, byte[] data) throws IOException Adding an attachment to a character. Though the primary focus of this method is adding attachments only to characters of the local player, it may also be used for characters of other players as well. If this works is implementation dependant. How many instances (per format) of attachments are allowed, depends on the type: CHARACTER and BACKGROUND may only exist once, while REPORT may exist multiple times.- Parameters:
handle- Character to modifytype- What us described in this attachmentformat- What kind of data is itfilename- A proposed file name. May be null. May be ignored by the implementationdata- Binary data of the attachment- Returns:
- The created attachment
- Throws:
IOException- Error executing operation
-
modifyAttachment
Write modifications made to this attachment to storage.- Parameters:
handle- Character to modifyattach- Attachment that has been modified- Throws:
IOException
-
deleteAttachment
Remove an attachment from a character.- Parameters:
handle- Character to modifyattach- Attachment to remove- Throws:
IOException
-
deleteCharacter
Delete a character and all his attachments,- Parameters:
handle- Character to remove- Throws:
IOException
-
renameCharacter
Rename a character and all his attachments,- Parameters:
handle- Character to remove- Throws:
IOException
-
getMyCharacters
- Throws:
IOException
-
getMyCharacters
List<CharacterHandle> getMyCharacters(de.rpgframework.core.RoleplayingSystem ruleSystem) throws IOException Get all characters of a given player belonging to a specific roleplaying system.- Parameters:
ruleSystem- Roleplaying system to get characters for.player- Player to get characters from- Returns:
- A list of characters in no granted order.
- Throws:
IOException
-
isSynchronizeSupported
boolean isSynchronizeSupported() -
initiateCharacterSynchronization
void initiateCharacterSynchronization()
-