Skip to content

Commit

Permalink
Add config option to run an auto cleanup on startup, fixes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Phoenix616 committed Oct 11, 2016
1 parent 576d9f5 commit 9008c7a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
14 changes: 13 additions & 1 deletion src/main/java/com/wfector/notifier/ChestShopNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ public void onEnable() {
saveDefaultConfig();
updateConfiguration(null);

if (getConfig().getBoolean("clean-on-startup.enabled") && getConfig().getString("clean-on-startup.command", null) != null) {
new BukkitRunnable() {
@Override
public void run() {
getLogger().log(Level.INFO, "Automatich database cleaning on startup is enabled!");
String parameters = getConfig().getString("clean-on-startup.parameters").trim();
getLogger().log(Level.INFO, "Parameters: " + parameters);
getServer().dispatchCommand(getServer().getConsoleSender(), "csn cleandatabase " + parameters);
}
}.runTaskLater(this, 200);
}

getServer().getPluginManager().registerEvents(this, this);
}

Expand Down Expand Up @@ -139,7 +151,7 @@ public String getMessage(String string) {
@EventHandler
public void onPlayerJoinEvent(PlayerJoinEvent e) {
if(!joinNotificationEnabled) {
debug("Join notifications are " + joinNotificationEnabled + ", skipping...");
debug("Join notifications are disabled, skipping...");
return;
}

Expand Down
9 changes: 6 additions & 3 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Chest Shop Notifier
# Config file for 1.1.2
# August 19 2014
# Config file for 1.2

logging:
admin-shop: true
Expand All @@ -21,7 +20,11 @@ database:
dbname: 'database1'
username: 'dbadmin'
password: '123456'


clean-on-startup:
enabled: false
parameters: "--older-than 30 --all"

messages:
sales: "&c ** You made &f{sales} sales&c since you last checked."
history-cmd: "&c ** To see them, type &f/csn history&c."
Expand Down

0 comments on commit 9008c7a

Please sign in to comment.