mirror of
https://github.com/AppleDash/SaneEconomy.git
synced 2024-11-29 21:43:28 +01:00
Make database reload on player join.
This commit is contained in:
parent
8c8c171d3a
commit
a144667971
@ -22,7 +22,7 @@ public class EconomyStorageBackendFlatfile extends EconomyStorageBackendCaching
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadDatabase() {
|
||||
public synchronized void reloadDatabase() {
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class EconomyStorageBackendMySQL extends EconomyStorageBackendCaching {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadDatabase() {
|
||||
public synchronized void reloadDatabase() {
|
||||
createTables();
|
||||
try (Connection conn = dbConn.openConnection()) {
|
||||
PreparedStatement ps = conn.prepareStatement("SELECT * FROM `saneeconomy_balances`");
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
/**
|
||||
@ -42,4 +43,9 @@ public class JoinQuitListener implements Listener {
|
||||
MessageUtils.sendMessage(player, "An update is available! The currently-installed version is %s, but the newest available is %s. Please go to %s to update!", plugin.getDescription().getVersion(), plugin.getVersionChecker().getNewestVersion(), GithubVersionChecker.DOWNLOAD_URL);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLogin(AsyncPlayerPreLoginEvent evt) {
|
||||
plugin.getEconomyManager().getBackend().reloadDatabase(); // TODO: If servers start to lag when lots of people join, this is why.
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user