mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-08 19:51:05 +00:00
Added config option to disable economy logging
This commit is contained in:
parent
397304c748
commit
a8f589c1b7
@ -113,6 +113,9 @@ public class Config {
|
||||
/** Whether the debug log file should be created **/
|
||||
public boolean enable_debug_log;
|
||||
|
||||
/** Whether buys and sells should be logged in the database **/
|
||||
public boolean enable_ecomomy_log;
|
||||
|
||||
/** Whether WorldGuard integration should be enabled **/
|
||||
public boolean enable_worldguard_integration;
|
||||
|
||||
@ -365,6 +368,7 @@ public class Config {
|
||||
enable_quality_mode = plugin.getConfig().getBoolean("enable-quality-mode");
|
||||
enable_hologram_interaction = plugin.getConfig().getBoolean("enable-hologram-interaction");
|
||||
enable_debug_log = plugin.getConfig().getBoolean("enable-debug-log");
|
||||
enable_ecomomy_log = plugin.getConfig().getBoolean("enable-economy-log");
|
||||
enable_worldguard_integration = plugin.getConfig().getBoolean("enable-worldguard-integration");
|
||||
enable_towny_integration = plugin.getConfig().getBoolean("enable-towny-integration");
|
||||
enable_authme_integration = plugin.getConfig().getBoolean("enable-authme-integration");
|
||||
|
@ -368,38 +368,42 @@ public abstract class Database {
|
||||
* @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<Void> callback) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PreparedStatement ps = null;
|
||||
if (plugin.getShopChestConfig().enable_ecomomy_log) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PreparedStatement ps = null;
|
||||
|
||||
try {
|
||||
ps = connection.prepareStatement("INSERT INTO shop_log (timestamp,executor,product,vendor,world,x,y,z,price,type) VALUES(?,?,?,?,?,?,?,?,?,?)");
|
||||
try {
|
||||
ps = connection.prepareStatement("INSERT INTO shop_log (timestamp,executor,product,vendor,world,x,y,z,price,type) VALUES(?,?,?,?,?,?,?,?,?,?)");
|
||||
|
||||
ps.setString(1, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()));
|
||||
ps.setString(2, executor.getUniqueId().toString() + " (" + executor.getName() + ")");
|
||||
ps.setString(3, product.getAmount() + " x " + LanguageUtils.getItemName(product));
|
||||
ps.setString(4, vendor.getUniqueId().toString() + " (" + vendor.getName() + ")" + (shopType == ShopType.ADMIN ? " (ADMIN)" : ""));
|
||||
ps.setString(5, location.getWorld().getName());
|
||||
ps.setInt(6, location.getBlockX());
|
||||
ps.setInt(7, location.getBlockY());
|
||||
ps.setInt(8, location.getBlockZ());
|
||||
ps.setDouble(9, price);
|
||||
ps.setString(10, type.toString());
|
||||
ps.executeUpdate();
|
||||
ps.setString(1, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()));
|
||||
ps.setString(2, executor.getUniqueId().toString() + " (" + executor.getName() + ")");
|
||||
ps.setString(3, product.getAmount() + " x " + LanguageUtils.getItemName(product));
|
||||
ps.setString(4, vendor.getUniqueId().toString() + " (" + vendor.getName() + ")" + (shopType == ShopType.ADMIN ? " (ADMIN)" : ""));
|
||||
ps.setString(5, location.getWorld().getName());
|
||||
ps.setInt(6, location.getBlockX());
|
||||
ps.setInt(7, location.getBlockY());
|
||||
ps.setInt(8, location.getBlockZ());
|
||||
ps.setDouble(9, price);
|
||||
ps.setString(10, type.toString());
|
||||
ps.executeUpdate();
|
||||
|
||||
if (callback != null) callback.callSyncResult(null);
|
||||
plugin.debug("Logged economy transaction to database");
|
||||
} catch (final SQLException ex) {
|
||||
if (callback != null) callback.callSyncError(ex);
|
||||
plugin.getLogger().severe("Failed to access database");
|
||||
plugin.debug("Failed to log economy transaction to database");
|
||||
plugin.debug(ex);
|
||||
} finally {
|
||||
close(ps, null);
|
||||
if (callback != null) callback.callSyncResult(null);
|
||||
plugin.debug("Logged economy transaction to database");
|
||||
} catch (final SQLException ex) {
|
||||
if (callback != null) callback.callSyncError(ex);
|
||||
plugin.getLogger().severe("Failed to access database");
|
||||
plugin.debug("Failed to log economy transaction to database");
|
||||
plugin.debug(ex);
|
||||
} finally {
|
||||
close(ps, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
}.runTaskAsynchronously(plugin);
|
||||
} else {
|
||||
if (callback != null) callback.callSyncResult(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,9 @@ shop-info-item: "STICK"
|
||||
# are the vendor or have permission.
|
||||
enable-hologram-interaction: true
|
||||
|
||||
# Set whether buys and sells should be logged in the database.
|
||||
enable-economy-log: false
|
||||
|
||||
# Set whether a debug log file should be created.
|
||||
# The file may get large! Please enable this setting when reporting bugs.
|
||||
enable-debug-log: false
|
||||
|
Loading…
Reference in New Issue
Block a user