use onLoad to load all ports before plugins uses the database loads

This commit is contained in:
mohammed jasem alaajel 2022-02-04 16:13:26 +04:00
parent 968d5ff97f
commit 12ca999802

View File

@ -76,7 +76,7 @@ public class AppleTunneler extends JavaPlugin {
} }
@Override @Override
public void onEnable() { public void onLoad() {
this.saveDefaultConfig(); this.saveDefaultConfig();
try { try {
loadIds(); loadIds();
@ -89,9 +89,12 @@ public class AppleTunneler extends JavaPlugin {
} catch (JSchException e) { } catch (JSchException e) {
connectionFailedLog(e); connectionFailedLog(e);
} }
}
@Override
public void onEnable() {
new BukkitRunnable() { new BukkitRunnable() {
private boolean isConnecting = false; private boolean isConnecting = false;
@Override @Override
public void run() { public void run() {
if (isConnecting) { if (isConnecting) {
@ -108,9 +111,16 @@ public class AppleTunneler extends JavaPlugin {
} }
} }
}.runTaskTimerAsynchronously(this, 0, 20); }.runTaskTimerAsynchronously(this, 0, 20);
getLogger().info("reconnecting task was registered successfully");
} }
/*
Currently there is no onDisable because plugin might disable itself before another
which might causes disconnections and data never saved
*/
private int getPort() { private int getPort() {
return this.getConfig().getInt("port"); return this.getConfig().getInt("port");
} }
@ -122,5 +132,4 @@ public class AppleTunneler extends JavaPlugin {
private String getHost() { private String getHost() {
return this.getConfig().getString("host"); return this.getConfig().getString("host");
} }
} }