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
public void onEnable() {
public void onLoad() {
this.saveDefaultConfig();
try {
loadIds();
@ -89,9 +89,12 @@ public class AppleTunneler extends JavaPlugin {
} catch (JSchException e) {
connectionFailedLog(e);
}
}
@Override
public void onEnable() {
new BukkitRunnable() {
private boolean isConnecting = false;
@Override
public void run() {
if (isConnecting) {
@ -108,9 +111,16 @@ public class AppleTunneler extends JavaPlugin {
}
}
}.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() {
return this.getConfig().getInt("port");
}
@ -122,5 +132,4 @@ public class AppleTunneler extends JavaPlugin {
private String getHost() {
return this.getConfig().getString("host");
}
}