summaryrefslogtreecommitdiffstats
path: root/Essentials/src/net/ess3/api/IEconomy.java
blob: 2e26bd45456bb64bd330f288ef34f012a653694c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package net.ess3.api;


public interface IEconomy extends IReload
{
	/**
	 * Used to get the balance of a user
	 *
	 * @param name the name of the user
	 * @return the balance
	 * @throws UserDoesNotExistException thrown if the user does not exist
	 */
	double getMoney(String name) throws UserDoesNotExistException;

	/**
	 * Used to set the balance of a user
	 *
	 * @param name the name of the user
	 * @param balance the amount to set the balance to
	 * @throws UserDoesNotExistException thrown if the user does not exist
	 * @throws NoLoanPermittedException **TODO: this needs to be removed, due to changes in eco handling**
	 */
	void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException;

	/**
	 * Used to reset the balance of a user to the starting balance (as defined in the config)
	 *
	 * @param name the name of the user
	 * @throws UserDoesNotExistException
	 * @throws NoLoanPermittedException **TODO: this needs to be removed, due to changes in eco handling**
	 */
	void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException;

	/**
	 * Used to format the balance as a string
	 *
	 * @param amount the balance to format
	 * @return the formatted string
	 */
	String format(double amount);

	/**
	 * Used to check if a user exists. A user exists if they have played on the server and have not had their user data deleted.
	 *
	 * @param name the name of the user to check
	 * @return true if the user exists, false if not
	 */
	boolean playerExists(String name);

	/**
	 * Used to check if the given user is a NPC. An example of a NPC would be a town or faction, which has a balance, but is not a player.
	 *
	 * @param name the name of the user to check
	 * @return true if the user is a NPC, false if not
	 * @throws UserDoesNotExistException thrown if the user does not exist
	 */
	boolean isNPC(String name) throws UserDoesNotExistException;

	/**
	 * Used to create a new NPC.
	 *
	 * @param name the name to give the new NPC
	 * @return true if the NPC was successfully created, false if not (should never happen)
	 */
	boolean createNPC(String name);

	/**
	 * Used to remove a NPC with the given name
	 *
	 * @param name the name of the NPC to remove
	 * @throws UserDoesNotExistException thrown if the NPC does not exist
	 */
	void removeNPC(String name) throws UserDoesNotExistException;
}