Fix disconnection issues. Push 1.3.3.7
This commit is contained in:
parent
e3cfc79055
commit
6a4feca615
4 changed files with 46 additions and 4 deletions
|
@ -3,7 +3,7 @@
|
|||
org.gradle.jvmargs=-Xmx8G
|
||||
org.gradle.daemon=false
|
||||
|
||||
my_version=1.3.3.6
|
||||
my_version=1.3.3.7
|
||||
|
||||
mc_version=1.19.2
|
||||
forge_version=43.1.32
|
||||
|
|
|
@ -79,7 +79,7 @@ public class OTEMod
|
|||
public static Map<String,Profile> PROFILES = new HashMap<String,Profile>();
|
||||
public static List<TeleportContainer> TeleportRegistry = new ArrayList<>();
|
||||
public static MinecraftServer THE_SERVER;
|
||||
private static boolean ALIVE;
|
||||
public static boolean ALIVE;
|
||||
|
||||
public static boolean DEVELOPER=false;
|
||||
private static Thread MasterThread;
|
||||
|
|
|
@ -12,7 +12,7 @@ public class Database {
|
|||
private Connection connection;
|
||||
|
||||
|
||||
public Database (OTEMod instance) throws DatabaseConnectionException
|
||||
public Database (OTEMod instance) throws DatabaseConnectionException, SQLException
|
||||
{
|
||||
mod=instance;
|
||||
try{
|
||||
|
@ -20,6 +20,48 @@ public class Database {
|
|||
}catch(Exception e){
|
||||
throw new DatabaseConnectionException(e.getMessage());
|
||||
}
|
||||
|
||||
Thread tx = new Thread(new Runnable(){
|
||||
public void run()
|
||||
{
|
||||
while(true){
|
||||
|
||||
// Watch the connection for disconnections
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(!OTEMod.ALIVE)return;// Exit now. We are being torn down/server is going down
|
||||
try {
|
||||
if(!OTEMod.DB.isConnected())
|
||||
{
|
||||
OTEMod.LOGGER.info("/!\\ Lost connection to data provider. Reconnecting...");
|
||||
// Refresh
|
||||
try {
|
||||
OTEMod.DB.connect();
|
||||
|
||||
if(OTEMod.DB.isConnected())
|
||||
{
|
||||
OTEMod.LOGGER.info("/!\\ Reconnected!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(isConnected()){
|
||||
tx.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void connect() throws Exception
|
||||
|
|
|
@ -19,7 +19,7 @@ modId="otemod" #mandatory
|
|||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
|
||||
# see the associated build.gradle script for how to populate this completely automatically during a build
|
||||
version="1.3.3.6" #mandatory
|
||||
version="1.3.3.7" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="OTEMod Resources" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
|
||||
|
|
Reference in a new issue