mirror of
https://github.com/funkemunky/AntiVPN.git
synced 2026-06-13 23:20:46 +00:00
bugfix/velocity-kick (#56)
* Updating velocity API * Added exception logging and fixed NullPointerException with antivpn plan command in velocity from tab-complete being null. Replaced MySQL with MariaDB driver * Added exception logging and fixed NullPointerException with antivpn plan command in velocity from tab-complete being null. Replaced MySQL with MariaDB driver. * Added exception logging and fixed NullPointerException with antivpn plan command in velocity from tab-complete being null. Replaced MySQL with MariaDB driver. * Fixing kick reason * Corrected MySQL ssl errors and fixed visual bug with velocity users kicking * Reverted to mysql driver --------- Co-authored-by: Dawson <dawson@funkemunky.cc>
This commit is contained in:
@@ -38,6 +38,12 @@ public abstract class VPNExecutor {
|
||||
|
||||
public abstract void log(String log, Object... objects);
|
||||
|
||||
public abstract void logException(String message, Exception ex);
|
||||
|
||||
public void logException(Exception ex) {
|
||||
logException("An exception occurred: " + ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
public boolean isWhitelisted(UUID uuid) {
|
||||
if(AntiVPN.getInstance().getVpnConfig().isDatabaseEnabled()) {
|
||||
return AntiVPN.getInstance().getDatabase().isWhitelisted(uuid);
|
||||
|
||||
@@ -10,6 +10,7 @@ import dev.brighten.antivpn.web.FunkemunkyAPI;
|
||||
import dev.brighten.antivpn.web.objects.QueryResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PlanCommand extends Command {
|
||||
@@ -53,7 +54,7 @@ public class PlanCommand extends Command {
|
||||
VPNExecutor.threadExecutor.execute(() -> {
|
||||
QueryResponse result;
|
||||
try {
|
||||
if(AntiVPN.getInstance().getVpnConfig().getLicense().equals("")) {
|
||||
if(AntiVPN.getInstance().getVpnConfig().getLicense().isEmpty()) {
|
||||
result = FunkemunkyAPI.getQueryResponse();
|
||||
} else {
|
||||
result = FunkemunkyAPI.getQueryResponse(AntiVPN.getInstance().getVpnConfig().getLicense());
|
||||
@@ -81,11 +82,11 @@ public class PlanCommand extends Command {
|
||||
result.getQueries(), queryMax);
|
||||
executor.sendMessage(StringUtil.line("&8"));
|
||||
} catch(JSONException e) {
|
||||
e.printStackTrace();
|
||||
AntiVPN.getInstance().getExecutor().logException(e);
|
||||
executor.sendMessage("&cThere was a JSONException thrown while looking up your query " +
|
||||
"information. Check console for more details.");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
AntiVPN.getInstance().getExecutor().logException(e);
|
||||
executor.sendMessage("&cThere was a IOException thrown while looking up your query " +
|
||||
"information. Check console for more details.");
|
||||
}
|
||||
@@ -95,6 +96,6 @@ public class PlanCommand extends Command {
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandExecutor executor, String alias, String[] args) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.brighten.antivpn.database.sql.utils;
|
||||
|
||||
import com.mysql.cj.jdbc.Driver;
|
||||
import dev.brighten.antivpn.AntiVPN;
|
||||
import org.h2.jdbc.JdbcConnection;
|
||||
|
||||
@@ -15,11 +16,7 @@ public class MySQL {
|
||||
public static void init() {
|
||||
try {
|
||||
if (conn == null || conn.isClosed()) {
|
||||
try {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
}
|
||||
DriverManager.registerDriver(new Driver());
|
||||
conn = DriverManager.getConnection("jdbc:mysql://" + AntiVPN.getInstance().getVpnConfig().getIp()
|
||||
+ ":" + AntiVPN.getInstance().getVpnConfig().getPort()
|
||||
+ "/?useSSL=true&autoReconnect=true",
|
||||
@@ -33,12 +30,10 @@ public class MySQL {
|
||||
AntiVPN.getInstance().getExecutor().log("Connection to MySQL has been established.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
AntiVPN.getInstance().getExecutor().log("Failed to load mysql: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
AntiVPN.getInstance().getExecutor().logException("Failed to load mysql: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean attemptedTwice = false;
|
||||
public static void initH2() {
|
||||
File dataFolder = new File(AntiVPN.getInstance().getPluginFolder(), "databases");
|
||||
File databaseFile = new File(dataFolder, "database");
|
||||
@@ -51,17 +46,15 @@ public class MySQL {
|
||||
Query.use(conn);
|
||||
AntiVPN.getInstance().getExecutor().log("Connection to H2 has been established.");
|
||||
} catch (SQLException ex) {
|
||||
AntiVPN.getInstance().getExecutor().log("H2 exception on initialize");
|
||||
ex.printStackTrace();
|
||||
AntiVPN.getInstance().getExecutor().logException("H2 exception on initialize: " + ex.getMessage(), ex);
|
||||
}
|
||||
attemptedTwice = true;
|
||||
}
|
||||
|
||||
public static void use() {
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
AntiVPN.getInstance().getExecutor().logException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,9 +66,8 @@ public class MySQL {
|
||||
} else conn.close();
|
||||
conn = null;
|
||||
}
|
||||
attemptedTwice = false;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
AntiVPN.getInstance().getExecutor().logException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +78,7 @@ public class MySQL {
|
||||
try {
|
||||
return conn.isClosed();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
AntiVPN.getInstance().getExecutor().logException(e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user