Fixed javadoc for methods with a callback as parameter

Also, the getShops() method now always gets all shops from the
database instead of returning the existing one
This commit is contained in:
Eric 2017-03-21 13:38:17 +01:00
parent dd7a82b49e
commit b6a233f2b4
2 changed files with 23 additions and 15 deletions

View File

@ -40,6 +40,7 @@ public abstract class Database {
/**
* (Re-)Connects to the the database and initializes it. <br>
* Creates the table (if doesn't exist) and tests the connection
* @param callback Callback that - if succeeded - returns the amount of shops that were found (as {@code int})
*/
public void connect(final Callback callback) {
new BukkitRunnable() {
@ -157,6 +158,7 @@ public abstract class Database {
* Remove a shop from the database
*
* @param shop Shop to remove
* @param callback Callback that - if succeeded - returns {@code null}
*/
public void removeShop(final Shop shop, final Callback callback) {
new BukkitRunnable() {
@ -183,7 +185,7 @@ public abstract class Database {
/**
* @param id ID of the shop
* @return Whether a shop with the given ID exists
* @param callback Callback that - if succeeded - returns whether a shop with the given ID exists (as {@code boolean})
*/
public void isShop(final int id, final Callback callback) {
new BukkitRunnable() {
@ -218,6 +220,7 @@ public abstract class Database {
/**
* Get all shops from the database
* @param callback Callback that - if succeeded - returns an array of all shops (as {@code Shop[]})
*/
public void getShops(final Callback callback) {
new BukkitRunnable() {
@ -254,11 +257,6 @@ public abstract class Database {
Location location = new Location(world, x, y, z);
Shop shop = plugin.getShopUtils().getShop(location);
if (shop != null) {
plugin.debug("Shop already exists, returning existing one (#" + id + ").");
if (callback != null) callback.callSyncResult(shop);
} else {
plugin.debug("Initializing new shop... (#" + id + ")");
OfflinePlayer vendor = Bukkit.getOfflinePlayer(UUID.fromString(rs.getString("vendor")));
@ -269,7 +267,6 @@ public abstract class Database {
shops.add(new Shop(id, plugin, vendor, product, location, buyPrice, sellPrice, shopType));
}
}
if (callback != null) callback.callSyncResult(shops.toArray(new Shop[shops.size()]));
} catch (SQLException ex) {
@ -289,6 +286,7 @@ public abstract class Database {
/**
* Adds a shop to the database
* @param shop Shop to add
* @param callback Callback that - if succeeded - returns the ID the shop was given (as {@code int})
*/
public void addShop(final Shop shop, final Callback callback) {
new BukkitRunnable() {
@ -341,6 +339,7 @@ public abstract class Database {
* @param location Location of the shop
* @param price Price (buyprice or sellprice, depends on {@code type})
* @param type Whether the player bought or sold something
* @param callback Callback that - if succeeded - returns {@code null}
*/
public void logEconomy(final Player executor, final ItemStack product, final OfflinePlayer vendor, final ShopType shopType, final Location location, final double price, final ShopBuySellEvent.Type type, final Callback callback) {
new BukkitRunnable() {
@ -381,6 +380,7 @@ public abstract class Database {
* Get the revenue a player got while he was offline
* @param player Player whose revenue to get
* @param logoutTime Time in milliseconds when he logged out the last time
* @param callback Callback that - if succeeded - returns the revenue the player made while offline (as {@code double})
*/
public void getRevenue(final Player player, final long logoutTime, final Callback callback) {
new BukkitRunnable() {
@ -438,6 +438,7 @@ public abstract class Database {
* Log a logout to the database
* @param player Player who logged out
* @param timestamp Time in milliseconds when the player logged out
* @param callback Callback that - if succeeded - returns {@code null}
*/
public void logLogout(final Player player, final long timestamp, final Callback callback) {
new BukkitRunnable() {
@ -469,6 +470,7 @@ public abstract class Database {
/**
* Get the last logout of a player
* @param player Player who logged out
* @param callback Callback that - if succeeded - returns the time in milliseconds the player logged out (as {@code long})
*/
public void getLastLogout(final Player player, final Callback callback) {
new BukkitRunnable() {

View File

@ -94,6 +94,7 @@ public class ShopUtils {
* Remove a shop
* @param shop Shop to remove
* @param removeFromDatabase Whether the shop should also be removed from the database
* @param useCurrentThread Whether the current thread should be used instead of a new async task
*/
public void removeShop(Shop shop, boolean removeFromDatabase, boolean useCurrentThread) {
plugin.debug("Removing shop (#" + shop.getID() + ")");
@ -118,6 +119,11 @@ public class ShopUtils {
plugin.getShopDatabase().removeShop(shop, null);
}
/**
* Remove a shop
* @param shop Shop to remove
* @param removeFromDatabase Whether the shop should also be removed from the database
*/
public void removeShop(Shop shop, boolean removeFromDatabase) {
removeShop(shop, removeFromDatabase, false);
}
@ -191,7 +197,7 @@ public class ShopUtils {
* Reload the shops
* @param reloadConfig Whether the configuration should also be reloaded
* @param showConsoleMessages Whether messages about the language file should be shown in the console
* @return Amount of shops, which were reloaded
* @param callback Callback that - if succeeded - returns the amount of shops that were reloaded (as {@code int})
*/
public void reloadShops(boolean reloadConfig, boolean showConsoleMessages, final Callback callback) {
plugin.debug("Reloading shops...");