mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 08:36:45 +01:00
Work by Zreed
This commit is contained in:
parent
a3066803d0
commit
b2015d68d1
5
pom.xml
5
pom.xml
@ -76,6 +76,7 @@
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.turt2live.metrics:MetricsExtension</include>
|
||||
<include>commons-logging:commons-logging</include>
|
||||
<include>net.snaq:dbpool</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
@ -84,6 +85,10 @@
|
||||
<pattern>com.turt2live.metrics</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.metrics.mcstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.apache.commons.logging</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.commons.logging</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.snaq</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.dbpool</shadedPattern>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,39 +0,0 @@
|
||||
package com.gmail.nossr50.runnables.database;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.database.SQLDatabaseManager;
|
||||
|
||||
/**
|
||||
* This task is in charge of sending a MySQL ping over the MySQL connection
|
||||
* every hour to prevent the connection from timing out and losing players'
|
||||
* data when they join.
|
||||
* <p/>
|
||||
* A WeakReference is used to keep the database instance, because
|
||||
* {@link com.gmail.nossr50.commands.database.ConvertDatabaseCommand database
|
||||
* conversion} may create a SQLDatabaseManager that will be thrown out. If a
|
||||
* normal reference was used, the conversion would cause a combined data and
|
||||
* resource leak through this task.
|
||||
*/
|
||||
public class SQLDatabaseKeepaliveTask extends BukkitRunnable {
|
||||
WeakReference<SQLDatabaseManager> databaseInstance;
|
||||
|
||||
public SQLDatabaseKeepaliveTask(SQLDatabaseManager dbman) {
|
||||
databaseInstance = new WeakReference<SQLDatabaseManager>(dbman);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
SQLDatabaseManager dbman = databaseInstance.get();
|
||||
if (dbman != null) {
|
||||
dbman.checkConnected();
|
||||
}
|
||||
else {
|
||||
// This happens when the database was started for a conversion,
|
||||
// or discarded by its creator for any other reason. If this code
|
||||
// was not present, we would leak the connection resources.
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package com.gmail.nossr50.runnables.database;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.database.SQLDatabaseManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class SQLReconnectTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
if (((SQLDatabaseManager) mcMMO.getDatabaseManager()).checkConnected()) {
|
||||
UserManager.saveAll(); // Save all profiles
|
||||
UserManager.clearAll(); // Clear the profiles
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
UserManager.addUser(player); // Add in new profiles, forcing them to 'load' again from MySQL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user