mirror of
https://github.com/funkemunky/AntiVPN.git
synced 2026-06-02 01:52:16 +00:00
Fixing whitelist bug and alertsState bug
- Whitelisted players would not actually return as whitelisted from the database because of use the getFetchSize parameter, which was not used as it was intended. - The same reasoning as above is why the alertsState would not function.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package dev.brighten.antivpn.api;
|
||||
|
||||
import dev.brighten.antivpn.AntiVPN;
|
||||
import dev.brighten.antivpn.message.VpnString;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@@ -19,13 +20,6 @@ public abstract class APIPlayer {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
this.ip = ip;
|
||||
|
||||
AntiVPN.getInstance().getDatabase().alertsState(uuid, enabled -> {
|
||||
if(enabled) {
|
||||
alertsEnabled = enabled; //This can be within the if statement. It's not dirty, it lowers field writes.
|
||||
sendMessage("");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public abstract void sendMessage(String message);
|
||||
@@ -36,6 +30,9 @@ public abstract class APIPlayer {
|
||||
|
||||
public void setAlertsEnabled(boolean alertsEnabled) {
|
||||
this.alertsEnabled = alertsEnabled;
|
||||
}
|
||||
|
||||
public void updateAlertsState() {
|
||||
//Updating into database so its synced across servers and saved on logout.
|
||||
AntiVPN.getInstance().getDatabase().updateAlertsState(uuid, alertsEnabled);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ public class AlertsCommand extends Command {
|
||||
APIPlayer player = pgetter.get();
|
||||
|
||||
player.setAlertsEnabled(!player.isAlertsEnabled());
|
||||
player.updateAlertsState();
|
||||
|
||||
return AntiVPN.getInstance().getMessageHandler().getString("command-alerts-toggled")
|
||||
.getFormattedMessage(new VpnString.Var<>("state", player.isAlertsEnabled()));
|
||||
|
||||
@@ -98,7 +98,7 @@ public class MySqlVPN implements VPNDatabase {
|
||||
ResultSet set = Query.prepare("select uuid from `whitelisted` where `uuid` = ? limit 1").append(uuid.toString())
|
||||
.executeQuery();
|
||||
|
||||
return set != null && set.getFetchSize() > 0 && set.next() && set.getString("uuid") != null;
|
||||
return set != null && set.next() && set.getString("uuid") != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,11 +153,11 @@ public class MySqlVPN implements VPNDatabase {
|
||||
if(MySQL.isClosed()) return;
|
||||
|
||||
VPNExecutor.threadExecutor.execute(() -> {
|
||||
ResultSet set = Query.prepare("select * from `alerts` where `uuid` = ?")
|
||||
ResultSet set = Query.prepare("select * from `alerts` where `uuid` = ? limit 1")
|
||||
.append(uuid.toString()).executeQuery();
|
||||
|
||||
try {
|
||||
result.accept(set.next());
|
||||
result.accept(set != null && set.next() && set.getString("uuid") != null);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
result.accept(false);
|
||||
|
||||
Reference in New Issue
Block a user