Exemplo n.º 1
0
 /// <summary>
 /// Deletes a player with the given name from the underlying data store.
 /// </summary>
 /// <param name="name">The name of the player to delete.</param>
 /// <exception cref="PlayerIOException">Thrown when the manager cannot delete the player.</exception>
 public void DeletePlayer(string name)
 {
     try {
         new PlayerFile(_playerPath, name).Delete();
     }
     catch (Exception ex) {
         PlayerIOException pex = new PlayerIOException("Could not save player", ex);
         pex.Data["PlayerName"] = name;
         throw pex;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Saves a <see cref="Player"/> object's data back to the given player's file.
 /// </summary>
 /// <param name="name">The name of the player to write back to.</param>
 /// <param name="player">The <see cref="Player"/> object containing data to write back.</param>
 /// <exception cref="PlayerIOException">Thrown when the manager cannot write out the player.</exception>
 public void SetPlayer(string name, Player player)
 {
     try {
         SetPlayerTree(name, new NbtTree(player.BuildTree() as TagNodeCompound));
     }
     catch (Exception ex) {
         PlayerIOException pex = new PlayerIOException("Could not save player", ex);
         pex.Data["PlayerName"] = name;
         throw pex;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Deletes a player with the given name from the underlying data store.
 /// </summary>
 /// <param name="name">The name of the player to delete.</param>
 /// <exception cref="PlayerIOException">Thrown when the manager cannot delete the player.</exception>
 public void DeletePlayer(string name)
 {
     try {
         new PlayerFile(_playerPath, name).Delete();
     }
     catch (Exception ex) {
         PlayerIOException pex = new PlayerIOException("Could not save player", ex);
         pex.Data["PlayerName"] = name;
         throw pex;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Gets a <see cref="Player"/> object for the given player.
        /// </summary>
        /// <param name="name">The name of the player to fetch.</param>
        /// <returns>A <see cref="Player"/> object for the given player, or null if the player could not be found.</returns>
        /// <exception cref="PlayerIOException">Thrown when the manager cannot read in a player that should exist.</exception>
        public Player GetPlayer(string name)
        {
            if (!PlayerExists(name)) {
                return null;
            }

            try {
                return new Player().LoadTreeSafe(GetPlayerTree(name).Root);
            }
            catch (Exception ex) {
                PlayerIOException pex = new PlayerIOException("Could not load player", ex);
                pex.Data["PlayerName"] = name;
                throw pex;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets a <see cref="Player"/> object for the given player.
        /// </summary>
        /// <param name="name">The name of the player to fetch.</param>
        /// <returns>A <see cref="Player"/> object for the given player, or null if the player could not be found.</returns>
        /// <exception cref="PlayerIOException">Thrown when the manager cannot read in a player that should exist.</exception>
        public Player GetPlayer(string name)
        {
            if (!PlayerExists(name))
            {
                return(null);
            }

            try {
                return(new Player().LoadTreeSafe(GetPlayerTree(name).Root));
            }
            catch (Exception ex) {
                PlayerIOException pex = new PlayerIOException("Could not load player", ex);
                pex.Data["PlayerName"] = name;
                throw pex;
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Saves a <see cref="Player"/> object's data back to the given player's file.
 /// </summary>
 /// <param name="name">The name of the player to write back to.</param>
 /// <param name="player">The <see cref="Player"/> object containing data to write back.</param>
 /// <exception cref="PlayerIOException">Thrown when the manager cannot write out the player.</exception>
 public void SetPlayer(string name, Player player)
 {
     try {
         SetPlayerTree(name, new NbtTree(player.BuildTree() as TagNodeCompound));
     }
     catch (Exception ex) {
         PlayerIOException pex = new PlayerIOException("Could not save player", ex);
         pex.Data["PlayerName"] = name;
         throw pex;
     }
 }