SaneEconomy: Only log database transactions if debug=true (in newer SaneLib)

This commit is contained in:
AppleDash 2017-07-12 20:06:14 -04:00
parent c3f84698ce
commit f54a43437d
7 changed files with 38 additions and 17 deletions

View File

@ -6,10 +6,10 @@
<parent>
<groupId>org.appledash</groupId>
<artifactId>SaneEconomy</artifactId>
<version>0.12.3-SNAPSHOT</version>
<version>0.12.4-SNAPSHOT</version>
</parent>
<artifactId>SaneEconomyCore</artifactId>
<version>0.12.3-SNAPSHOT</version>
<version>0.12.4-SNAPSHOT</version>
<dependencies>
<dependency>

View File

@ -75,11 +75,15 @@ public class SaneEconomy extends SanePlugin implements ISaneEconomy {
vaultHook.unhook();
}
if (economyManager != null) {
getLogger().info("Flushing database...");
economyManager.getBackend().waitUntilFlushed();
this.flushEconomyManager();
}
if (economyManager.getBackend() instanceof EconomyStorageBackendMySQL) {
private void flushEconomyManager() {
if (this.economyManager != null) {
this.getLogger().info("Flushing database...");
this.economyManager.getBackend().waitUntilFlushed();
if (this.economyManager.getBackend() instanceof EconomyStorageBackendMySQL) {
((EconomyStorageBackendMySQL) economyManager.getBackend()).closeConnections();
if (!((EconomyStorageBackendMySQL) economyManager.getBackend()).getConnection().getConnection().isFinished()) {
this.getLogger().warning("SaneDatabase didn't terminate all threads, something weird is going on?");
@ -88,7 +92,7 @@ public class SaneEconomy extends SanePlugin implements ISaneEconomy {
}
}
private boolean loadConfig() {
public boolean loadConfig() {
File configFile = new File(getDataFolder(), "config.yml");
if (configFile.exists() && getConfig().getBoolean("debug", false)) {
@ -99,9 +103,13 @@ public class SaneEconomy extends SanePlugin implements ISaneEconomy {
getConfig().set("debug", true);
saveConfig();
} else {
saveDefaultConfig();
reloadConfig();
if (!configFile.exists()) {
this.saveDefaultConfig();
}
this.reloadConfig();
}
this.flushEconomyManager(); // If we're reloading the configuration, we flush the old economy manager first
SaneEconomyConfiguration config = new SaneEconomyConfiguration(this);

View File

@ -26,7 +26,9 @@ public class SaneEcoCommand extends SaneCommand {
@Override
public String[] getUsage() {
return new String[] {
"/<command> reload-database"
"/<command> reload - Reload everything.",
"/<command> reload-database - Reload the database.",
"/<command> reload-config - Reload the configuration."
};
}
@ -42,6 +44,15 @@ public class SaneEcoCommand extends SaneCommand {
this.saneEconomy.getMessenger().sendMessage(sender, "Reloading database...");
saneEconomy.getEconomyManager().getBackend().reloadDatabase();
this.saneEconomy.getMessenger().sendMessage(sender, "Database reloaded.");
} else if (subCommand.equalsIgnoreCase("reload-config")) {
this.saneEconomy.getMessenger().sendMessage(sender, "Reloading configuration...");
this.saneEconomy.loadConfig();
this.saneEconomy.getMessenger().sendMessage(sender, "Configuration reloaded.");
} else if (subCommand.equalsIgnoreCase("reload")) {
this.saneEconomy.getMessenger().sendMessage(sender, "Reloading configuration and database...");
this.saneEconomy.loadConfig();
this.saneEconomy.getEconomyManager().getBackend().reloadDatabase();
this.saneEconomy.getMessenger().sendMessage(sender, "Configuration and database reloaded.");
} else {
throw new InvalidUsageException();
}

View File

@ -5,18 +5,18 @@
<parent>
<artifactId>SaneEconomy</artifactId>
<groupId>org.appledash</groupId>
<version>0.12.3-SNAPSHOT</version>
<version>0.12.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>SaneEconomyMobKills</artifactId>
<version>0.1.2-SNAPSHOT</version>
<version>0.1.3-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.appledash</groupId>
<artifactId>SaneEconomyCore</artifactId>
<version>0.12.3-SNAPSHOT</version>
<version>0.12.4-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>SaneEconomy</artifactId>
<groupId>org.appledash</groupId>
<version>0.12.3-SNAPSHOT</version>
<version>0.12.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -16,7 +16,7 @@
<dependency>
<groupId>org.appledash</groupId>
<artifactId>SaneEconomyCore</artifactId>
<version>0.12.3-SNAPSHOT</version>
<version>0.12.4-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@ -1,2 +1,4 @@
admin-shop-trigger: '[Shop]'
admin-shop-title: '&8[&6Shop&8]&r'
chat:
prefix: '&b[&9Shops&b]&r '

View File

@ -6,7 +6,7 @@
<groupId>org.appledash</groupId>
<artifactId>SaneEconomy</artifactId>
<version>0.12.3-SNAPSHOT</version>
<version>0.12.4-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
@ -46,7 +46,7 @@
<dependency>
<groupId>org.appledash</groupId>
<artifactId>sanelib</artifactId>
<version>0.3.1-SNAPSHOT</version>
<version>0.3.2-SNAPSHOT</version>
</dependency>
</dependencies>
</project>