Skip to content

Commit b629cde

Browse files
Fix bug and bump version
1 parent 7e376c5 commit b629cde

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>parallelmc</groupId>
88
<artifactId>parallelutils</artifactId>
9-
<version>0.1</version>
9+
<version>0.1.1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Parallelutils</name>

src/main/java/parallelmc/parallelutils/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public class Constants {
44

5-
public static final Version VERSION = new Version(0, 1, 0);
5+
public static final Version VERSION = new Version(0, 1, 1);
66
public static final String PLUGIN_NAME = "ParallelUtils";
77
public static final String DEFAULT_WORLD = "world";
88
}

src/main/java/parallelmc/parallelutils/Parallelutils.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public final class Parallelutils extends JavaPlugin {
3939

4040
public static Connection dbConn;
4141

42+
private String jdbc;
43+
private String username = "";
44+
private String password = "";
45+
4246
private static boolean finishedSetup = false;
4347

4448
@Override
@@ -82,7 +86,7 @@ public void onEnable() {
8286
Bukkit.getLogger().setLevel(LOG_LEVEL);
8387

8488
// Either get the database connection URL from the config or construct it from the config
85-
String jdbc, address, database, username = "", password = "";
89+
String address, database;
8690
jdbc = config.getString("sql.jdbc");
8791

8892
if (jdbc == null || jdbc.trim().equals("")) {
@@ -191,6 +195,24 @@ public void onDisable() {
191195
dbConn.commit();
192196
} catch (SQLException e) {
193197
e.printStackTrace();
198+
log(Level.WARNING, "Trying again...");
199+
200+
// Try reconnecting
201+
try {
202+
if (!dbConn.isClosed()) {
203+
dbConn.close();
204+
}
205+
openDatabaseConnection(jdbc, username, password);
206+
207+
Statement removeStatement = dbConn.createStatement();
208+
removeStatement.execute("TRUNCATE TABLE WorldMobs");
209+
removeStatement.execute("TRUNCATE TABLE Spawners");
210+
dbConn.commit();
211+
212+
} catch (SQLException | ClassNotFoundException ex) {
213+
ex.printStackTrace();
214+
log(Level.WARNING, "Failed Twice. Something is broken!!!");
215+
}
194216
}
195217

196218
log(Level.INFO, "Cleared tables");

0 commit comments

Comments
 (0)