mirror of
https://github.com/funkemunky/AntiVPN.git
synced 2026-06-17 17:10:38 +00:00
CIDR Support setup and implemeneted for adding/removing via command, and checking updates for CIDR implemented. Also fixed problem with SHA-algor not being present
This commit is contained in:
@@ -4,9 +4,7 @@ import dev.brighten.antivpn.AntiVPN;
|
||||
import dev.brighten.antivpn.bukkit.command.BukkitCommand;
|
||||
import dev.brighten.antivpn.command.Command;
|
||||
import dev.brighten.antivpn.database.VPNDatabase;
|
||||
import dev.brighten.antivpn.database.local.H2VPN;
|
||||
import dev.brighten.antivpn.database.mongo.MongoVPN;
|
||||
import dev.brighten.antivpn.database.sql.MySqlVPN;
|
||||
import dev.brighten.antivpn.database.sqllite.LiteDatabase;
|
||||
import lombok.Getter;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
@@ -118,14 +116,8 @@ public class BukkitPlugin extends JavaPlugin {
|
||||
private String getDatabaseType() {
|
||||
VPNDatabase database = AntiVPN.getInstance().getDatabase();
|
||||
|
||||
if(database instanceof H2VPN) {
|
||||
return "H2";
|
||||
} else if(database instanceof MySqlVPN) {
|
||||
return "MySQL";
|
||||
} else if(database instanceof MongoVPN) {
|
||||
return "MongoDB";
|
||||
} else {
|
||||
return "No-Database";
|
||||
}
|
||||
if(database instanceof LiteDatabase) {
|
||||
return "SQLLite";
|
||||
} return "No-Database";
|
||||
}
|
||||
}
|
||||
|
||||
+1
-6
@@ -26,18 +26,13 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.6.0</version>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<!-- Replace this with your package! -->
|
||||
<shadedPattern>dev.brighten.antivpn.bungee.org.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.yaml.snakeyaml</pattern>
|
||||
<shadedPattern>dev.brighten.antivpn.shaded.org.yaml.snakeyaml</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
|
||||
@@ -4,9 +4,7 @@ import dev.brighten.antivpn.AntiVPN;
|
||||
import dev.brighten.antivpn.bungee.command.BungeeCommand;
|
||||
import dev.brighten.antivpn.command.Command;
|
||||
import dev.brighten.antivpn.database.VPNDatabase;
|
||||
import dev.brighten.antivpn.database.local.H2VPN;
|
||||
import dev.brighten.antivpn.database.mongo.MongoVPN;
|
||||
import dev.brighten.antivpn.database.sql.MySqlVPN;
|
||||
import dev.brighten.antivpn.database.sqllite.LiteDatabase;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import org.bstats.bungeecord.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
@@ -51,14 +49,8 @@ public class BungeePlugin extends Plugin {
|
||||
private String getDatabaseType() {
|
||||
VPNDatabase database = AntiVPN.getInstance().getDatabase();
|
||||
|
||||
if(database instanceof H2VPN) {
|
||||
return "H2";
|
||||
} else if(database instanceof MySqlVPN) {
|
||||
return "MySQL";
|
||||
} else if(database instanceof MongoVPN) {
|
||||
return "MongoDB";
|
||||
} else {
|
||||
return "No-Database";
|
||||
}
|
||||
if(database instanceof LiteDatabase) {
|
||||
return "SQLLite";
|
||||
} return "No-Database";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,11 +132,6 @@
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.48.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>2.2.220</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -163,13 +158,6 @@
|
||||
<version>3.1.8</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>3.12.14</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
|
||||
@@ -30,21 +30,8 @@ import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter(AccessLevel.PRIVATE)
|
||||
@MavenLibrary(groupId = "com.h2database", artifactId ="h2", version = "2.2.220", relocations = {
|
||||
@Relocate(from ="org" + ".\\h2", to ="dev.brighten.antivpn.shaded.org.h2")})
|
||||
@MavenLibrary(groupId = "org.mongodb", artifactId = "mongo-java-driver", version = "3.12.14", relocations = {
|
||||
@Relocate(from = "com." + "\\mongodb", to = "dev.brighten.antivpn.shaded.com.mongodb"),
|
||||
@Relocate(from = "org" + "\\.bson", to = "dev.brighten.antivpn.shaded.org.bson")
|
||||
})
|
||||
@MavenLibrary(
|
||||
groupId = "com.mysql",
|
||||
artifactId = "mysql-connector-j",
|
||||
version = "9.1.0",
|
||||
relocations = {
|
||||
@Relocate(from = "com.my\\" + "sql.cj", to = "dev.brighten.antivpn.shaded.com.mysql.cj"),
|
||||
@Relocate(from = "com.my\\" + "sql.jdbc", to = "dev.brighten.antivpn.shaded.com.mysql.jdbc")
|
||||
}
|
||||
)
|
||||
@MavenLibrary(groupId = "org\\.sqlite", artifactId ="sqlite-jdbc", version = "3.48.0.0", relocations = {
|
||||
@Relocate(from ="org" + ".\\sqlite", to ="dev.brighten.antivpn.shaded.org.sqlite")})
|
||||
@MavenLibrary(groupId = "com.\\github\\.ben-manes\\.caffeine", artifactId = "caffeine", version = "3.1.8",
|
||||
relocations = {
|
||||
@Relocate(from = "com\\.github\\.benmanes\\.caffeine", to = "dev.brighten.antivpn.shaded.com.github.benmanes.caffeine"),
|
||||
@@ -142,21 +129,7 @@ public class AntiVPN {
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (database instanceof H2VPN) {
|
||||
database.shutdown();
|
||||
|
||||
// Try to deregister driver
|
||||
try {
|
||||
java.sql.Driver driver = java.sql.DriverManager.getDriver("jdbc:h2:");
|
||||
if (driver != null) {
|
||||
java.sql.DriverManager.deregisterDriver(driver);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Log but don't throw
|
||||
executor.log("Failed to deregister H2 driver: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
VPNExecutor.threadExecutor.shutdown();
|
||||
executor.shutdown();
|
||||
if(database != null) database.shutdown();
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public abstract class APIPlayer {
|
||||
//Is exempt
|
||||
|| (uuid != null && AntiVPN.getInstance().getExecutor().isWhitelisted(uuid))
|
||||
//Or has a name that starts with a certain prefix. This is for Bedrock exempting.
|
||||
|| AntiVPN.getInstance().getExecutor().isWhitelisted(ip.getHostAddress())
|
||||
|| AntiVPN.getInstance().getExecutor().isWhitelisted(ip.getHostAddress() + "/32")
|
||||
|| AntiVPN.getInstance().getVpnConfig().getPrefixWhitelists().stream()
|
||||
.anyMatch(name::startsWith)) return new CheckResult(null, ResultType.WHITELISTED);
|
||||
|
||||
@@ -74,7 +74,7 @@ public abstract class APIPlayer {
|
||||
&& !((uuid != null && AntiVPN.getInstance().getExecutor()
|
||||
.isWhitelisted(uuid))
|
||||
//Or has a name that starts with a certain prefix. This is for Bedrock exempting.
|
||||
|| AntiVPN.getInstance().getExecutor().isWhitelisted(ip.getHostAddress()))
|
||||
|| AntiVPN.getInstance().getExecutor().isWhitelisted(ip.getHostAddress() + "/32"))
|
||||
// This bit of code will decide whether or not to kick the player
|
||||
// If it contains the code and it is set to whitelist, it will not kick
|
||||
// as they are equal and vise versa. However, if the contains does not match
|
||||
|
||||
@@ -4,8 +4,10 @@ import dev.brighten.antivpn.AntiVPN;
|
||||
import dev.brighten.antivpn.api.APIPlayer;
|
||||
import dev.brighten.antivpn.command.Command;
|
||||
import dev.brighten.antivpn.command.CommandExecutor;
|
||||
import dev.brighten.antivpn.utils.CIDRUtils;
|
||||
import dev.brighten.antivpn.utils.MiscUtils;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -62,50 +64,75 @@ public class AllowlistCommand extends Command {
|
||||
if(!databaseEnabled) executor.sendMessage("&cThe database is currently not setup, " +
|
||||
"so any changes here will disappear after a restart.");
|
||||
|
||||
CIDRUtils cidrUtils;
|
||||
|
||||
try {
|
||||
cidrUtils = new CIDRUtils(args[1]);
|
||||
} catch(IllegalArgumentException | UnknownHostException e) {
|
||||
cidrUtils = null;
|
||||
}
|
||||
|
||||
if(cidrUtils != null) {
|
||||
if(!databaseEnabled) {
|
||||
return switch (args[0].toLowerCase()) {
|
||||
case "add", "insert" -> {
|
||||
AntiVPN.getInstance().getExecutor().getWhitelistedIps().add(cidrUtils.getCidr());
|
||||
yield String.format("&aAdded &6%s &ato exemption allowlist.", cidrUtils.getCidr());
|
||||
}
|
||||
case "remove", "delete" -> {
|
||||
AntiVPN.getInstance().getExecutor().getWhitelistedIps().remove(cidrUtils.getCidr());
|
||||
yield String.format("&cRemoved &%s &cfrom the exemption allowlist.", cidrUtils.getCidr());
|
||||
}
|
||||
default -> "&c\"" + args[0] + "\" is not a valid argument";
|
||||
};
|
||||
} else return switch (args[0].toLowerCase()) {
|
||||
case "add", "insert" -> {
|
||||
AntiVPN.getInstance().getExecutor().getWhitelistedIps().add(cidrUtils.getCidr());
|
||||
AntiVPN.getInstance().getDatabase().addWhitelist(cidrUtils.getCidr());
|
||||
yield String.format("&aAdded &6%s &ato exemption allowlist.", cidrUtils.getCidr());
|
||||
}
|
||||
case "remove", "delete" -> {
|
||||
AntiVPN.getInstance().getExecutor().getWhitelistedIps().remove(cidrUtils.getCidr());
|
||||
AntiVPN.getInstance().getDatabase().removeWhitelist(cidrUtils.getCidr());
|
||||
yield String.format("&cRemoved &6%s &cfrom the exemption allowlist.", cidrUtils.getCidr());
|
||||
}
|
||||
default -> "&c\"" + args[0] + "\" is not a valid argument";
|
||||
};
|
||||
}
|
||||
if(MiscUtils.isIpv4(args[1])) {
|
||||
if(!databaseEnabled) {
|
||||
switch(args[0].toLowerCase()) {
|
||||
case "add":
|
||||
case "insert": {
|
||||
AntiVPN.getInstance().getExecutor().getWhitelistedIps().add(args[1]);
|
||||
AntiVPN.getInstance().getDatabase().removeWhitelist(args[1]);
|
||||
return String.format("&aAdded &6%s &ato the exemption allowlist.", args[1]);
|
||||
return switch(args[0].toLowerCase()) {
|
||||
case "add", "insert" -> {
|
||||
AntiVPN.getInstance().getExecutor().getWhitelistedIps().add(args[1] + "/32");
|
||||
AntiVPN.getInstance().getDatabase().addWhitelist(args[1] + "/32");
|
||||
yield String.format("&aAdded &6%s &ato the exemption allowlist.", args[1] + "/32");
|
||||
}
|
||||
case "remove":
|
||||
case "delete": {
|
||||
AntiVPN.getInstance().getExecutor().getWhitelistedIps().remove(args[1]);
|
||||
AntiVPN.getInstance().getDatabase().removeWhitelist(args[1]);
|
||||
return String.format("&cRemoved &6%s &cfrom the exemption allowlist.", args[1]);
|
||||
case "remove", "delete" -> {
|
||||
AntiVPN.getInstance().getExecutor().getWhitelistedIps().remove(args[1] + "/32");
|
||||
AntiVPN.getInstance().getDatabase().removeWhitelist(args[1] + "/32");
|
||||
yield String.format("&cRemoved &6%s &cfrom the exemption allowlist.", args[1] + "/32");
|
||||
}
|
||||
default: {
|
||||
return "&c\"" + args[0] + "\" is not a valid argument";
|
||||
default -> "&c\"" + args[0] + "\" is not a valid argument";
|
||||
};
|
||||
} else return switch (args[0].toLowerCase()) {
|
||||
case "add", "insert" -> {
|
||||
AntiVPN.getInstance().getDatabase().addWhitelist(args[1] + "/32");
|
||||
yield String.format("&aAdded &6%s &a to the exemption allowlist.", args[1] + "/32");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch(args[0].toLowerCase()) {
|
||||
case "add":
|
||||
case "insert": {
|
||||
AntiVPN.getInstance().getDatabase().addWhitelist(args[1]);
|
||||
return String.format("&aAdded &6%s &a to the exemption allowlist.", args[1]);
|
||||
case "remove", "delete" -> {
|
||||
AntiVPN.getInstance().getDatabase().removeWhitelist(args[1] + "/32");
|
||||
yield String.format("&cRemoved &6%s &c from the exemption allowlist.", args[1] + "/32");
|
||||
}
|
||||
case "remove":
|
||||
case "delete": {
|
||||
AntiVPN.getInstance().getDatabase().removeWhitelist(args[1]);
|
||||
return String.format("&cRemoved &6%s &c from the exemption allowlist.", args[1]);
|
||||
}
|
||||
default: {
|
||||
return "&c\"" + args[0] + "\" is not a valid argument";
|
||||
}
|
||||
}
|
||||
}
|
||||
default -> "&c\"" + args[0] + "\" is not a valid argument";
|
||||
};
|
||||
} else {
|
||||
UUID uuid = null;
|
||||
UUID uuid;
|
||||
try {
|
||||
uuid = UUID.fromString(args[1]);
|
||||
} catch(IllegalArgumentException e) {
|
||||
Optional<APIPlayer> player = AntiVPN.getInstance().getPlayerExecutor().getPlayer(args[1]);
|
||||
|
||||
if(!player.isPresent()) {
|
||||
if(player.isEmpty()) {
|
||||
return "&cThe player \"" + args[1] + "\" is not online, so please provide a UUID.";
|
||||
}
|
||||
|
||||
@@ -113,54 +140,44 @@ public class AllowlistCommand extends Command {
|
||||
}
|
||||
|
||||
if(!databaseEnabled) {
|
||||
switch(args[0].toLowerCase()) {
|
||||
case "add": {
|
||||
return switch (args[0].toLowerCase()) {
|
||||
case "add" -> {
|
||||
AntiVPN.getInstance().getExecutor().getWhitelisted().add(uuid);
|
||||
return String.format("&aAdded &6%s &auuid to the exemption allowlist.", uuid.toString());
|
||||
yield String.format("&aAdded &6%s &auuid to the exemption allowlist.", uuid.toString());
|
||||
}
|
||||
case "remove":
|
||||
case "delete": {
|
||||
case "remove", "delete" -> {
|
||||
AntiVPN.getInstance().getExecutor().getWhitelisted().remove(uuid);
|
||||
return String.format("&cRemoved &6%s &cuuid from the exemption allowlist.", uuid.toString());
|
||||
yield String.format("&cRemoved &6%s &cuuid from the exemption allowlist.", uuid.toString());
|
||||
}
|
||||
default: {
|
||||
return "&c\"" + args[0] + "\" is not a valid argument";
|
||||
}
|
||||
}
|
||||
default -> "&c\"" + args[0] + "\" is not a valid argument";
|
||||
};
|
||||
} else {
|
||||
switch(args[0].toLowerCase()) {
|
||||
case "add": {
|
||||
return switch (args[0].toLowerCase()) {
|
||||
case "add" -> {
|
||||
AntiVPN.getInstance().getDatabase().addWhitelist(uuid);
|
||||
return String.format("&aAdded &6%s &auuid to the exemption allowlist.", uuid.toString());
|
||||
yield String.format("&aAdded &6%s &auuid to the exemption allowlist.", uuid.toString());
|
||||
}
|
||||
case "remove":
|
||||
case "delete": {
|
||||
case "remove", "delete" -> {
|
||||
AntiVPN.getInstance().getDatabase().removeWhitelist(uuid);
|
||||
return String.format("&cRemoved &6%s &cuuid from the exemption allowlist.", uuid.toString());
|
||||
yield String.format("&cRemoved &6%s &cuuid from the exemption allowlist.", uuid.toString());
|
||||
}
|
||||
default: {
|
||||
return "&c\"" + args[0] + "\" is not a valid argument";
|
||||
}
|
||||
}
|
||||
default -> "&c\"" + args[0] + "\" is not a valid argument";
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandExecutor executor, String alias, String[] args) {
|
||||
switch(args.length) {
|
||||
case 1: {
|
||||
return Arrays.stream(secondArgs)
|
||||
.filter(narg -> narg.toLowerCase().startsWith(args[0].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
case 2: {
|
||||
return AntiVPN.getInstance().getPlayerExecutor().getOnlinePlayers().stream()
|
||||
.map(APIPlayer::getName)
|
||||
.filter(name -> name.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
return switch (args.length) {
|
||||
case 1 -> Arrays.stream(secondArgs)
|
||||
.filter(narg -> narg.toLowerCase().startsWith(args[0].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
case 2 -> AntiVPN.getInstance().getPlayerExecutor().getOnlinePlayers().stream()
|
||||
.map(APIPlayer::getName)
|
||||
.filter(name -> name.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
default -> Collections.emptyList();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PlanCommand extends Command {
|
||||
|
||||
@Override
|
||||
public String execute(CommandExecutor executor, String[] args) {
|
||||
VPNExecutor.threadExecutor.execute(() -> {
|
||||
AntiVPN.getInstance().getExecutor().getThreadExecutor().execute(() -> {
|
||||
QueryResponse result;
|
||||
try {
|
||||
if(AntiVPN.getInstance().getVpnConfig().getLicense().isEmpty()) {
|
||||
|
||||
@@ -179,15 +179,16 @@ public class LiteDatabase implements VPNDatabase {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
String url = "jdbc:sqlite:./plugins/AntiVPN/database.db";
|
||||
String url = "jdbc:sqlite:" + AntiVPN.getInstance().getPluginFolder().toPath() + "/database.db";
|
||||
|
||||
try {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
Connection connection = DriverManager.getConnection(url);
|
||||
Statement statement = connection.createStatement();
|
||||
statement.execute("CREATE TABLE IF NOT EXISTS vpn_responses (ip TEXT, response TEXT)");
|
||||
statement.execute("CREATE TABLE IF NOT EXISTS whitelist (uuid TEXT, NUMBER minimum, NUMBER maximum)");
|
||||
statement.execute("CREATE TABLE IF NOT EXISTS whitelist (uuid TEXT, minimum NUMERIC, maximum NUMERIC)");
|
||||
statement.execute("CREATE TABLE IF NOT EXISTS alerts (uuid TEXT)");
|
||||
statement.execute("CREATE TABLE IF NOT EXISTS version (PRIMARY KEY(version) NUMBER, updated STATE)");
|
||||
statement.execute("CREATE TABLE IF NOT EXISTS version (version INTEGER PRIMARY KEY, updated BOOLEAN)");
|
||||
|
||||
this.connection = connection;
|
||||
|
||||
@@ -204,7 +205,7 @@ public class LiteDatabase implements VPNDatabase {
|
||||
AntiVPN.getInstance().getExecutor().logException(e);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
AntiVPN.getInstance().getExecutor().logException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class StringUtil {
|
||||
|
||||
public static String getHash(String input) {
|
||||
try {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-128");
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA1");
|
||||
byte[] hash = digest.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
StringBuilder hexString = new StringBuilder(2 * hash.length);
|
||||
for (byte b : hash) {
|
||||
|
||||
+3
-18
@@ -42,26 +42,11 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>3.12.14</version>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.48.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>9.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>2.2.220</version>
|
||||
<scope>compile</scope>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -92,37 +92,37 @@ public class VelocityListener extends VPNExecutor {
|
||||
.replace("%city%",
|
||||
result.getCity())));
|
||||
|
||||
if(deniedOnLogin) return;
|
||||
if (deniedOnLogin) return;
|
||||
|
||||
//In case the user wants to run their own commands instead of using the
|
||||
// built in kicking
|
||||
|
||||
if(AntiVPN.getInstance().getVpnConfig().kickPlayersOnDetect()) {
|
||||
if (AntiVPN.getInstance().getVpnConfig().kickPlayersOnDetect()) {
|
||||
switch (checkResult.resultType()) {
|
||||
case DENIED_PROXY -> VelocityPlugin.INSTANCE.getServer().getScheduler()
|
||||
.buildTask(VelocityPlugin.INSTANCE, () ->
|
||||
event.getPlayer().disconnect(LegacyComponentSerializer.builder()
|
||||
.character('&')
|
||||
.build().deserialize(AntiVPN.getInstance().getVpnConfig()
|
||||
.getKickString()
|
||||
.replace("%player%", event.getPlayer().getUsername())
|
||||
.replace("%country%", result.getCountryName())
|
||||
.replace("%code%", result.getCountryCode()))))
|
||||
.delay(1, TimeUnit.SECONDS).schedule();
|
||||
.buildTask(VelocityPlugin.INSTANCE, () ->
|
||||
event.getPlayer().disconnect(LegacyComponentSerializer.builder()
|
||||
.character('&')
|
||||
.build().deserialize(AntiVPN.getInstance().getVpnConfig()
|
||||
.getKickString()
|
||||
.replace("%player%", event.getPlayer().getUsername())
|
||||
.replace("%country%", result.getCountryName())
|
||||
.replace("%code%", result.getCountryCode()))))
|
||||
.delay(1, TimeUnit.SECONDS).schedule();
|
||||
case DENIED_COUNTRY -> VelocityPlugin.INSTANCE.getServer().getScheduler()
|
||||
.buildTask(VelocityPlugin.INSTANCE, () ->
|
||||
event.getPlayer().disconnect(LegacyComponentSerializer.builder()
|
||||
.character('&')
|
||||
.build().deserialize(AntiVPN.getInstance().getVpnConfig()
|
||||
.countryVanillaKickReason()
|
||||
.replace("%player%", event.getPlayer().getUsername())
|
||||
.replace("%country%", result.getCountryName())
|
||||
.replace("%code%", result.getCountryCode()))))
|
||||
.delay(1, TimeUnit.SECONDS).schedule();
|
||||
.buildTask(VelocityPlugin.INSTANCE, () ->
|
||||
event.getPlayer().disconnect(LegacyComponentSerializer.builder()
|
||||
.character('&')
|
||||
.build().deserialize(AntiVPN.getInstance().getVpnConfig()
|
||||
.countryVanillaKickReason()
|
||||
.replace("%player%", event.getPlayer().getUsername())
|
||||
.replace("%country%", result.getCountryName())
|
||||
.replace("%code%", result.getCountryCode()))))
|
||||
.delay(1, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
}
|
||||
|
||||
if(!AntiVPN.getInstance().getVpnConfig().runCommands()) return;
|
||||
if (!AntiVPN.getInstance().getVpnConfig().runCommands()) return;
|
||||
|
||||
switch (checkResult.resultType()) {
|
||||
case DENIED_PROXY -> {
|
||||
@@ -162,13 +162,10 @@ public class VelocityListener extends VPNExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
if (cacheResetTask != null) {
|
||||
cacheResetTask.cancel();
|
||||
cacheResetTask = null;
|
||||
}
|
||||
VelocityPlugin.INSTANCE.getServer().getEventManager().unregisterListener(VelocityPlugin.INSTANCE, this);
|
||||
super.shutdown();
|
||||
}
|
||||
|
||||
@@ -10,9 +10,7 @@ import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import dev.brighten.antivpn.AntiVPN;
|
||||
import dev.brighten.antivpn.command.Command;
|
||||
import dev.brighten.antivpn.database.VPNDatabase;
|
||||
import dev.brighten.antivpn.database.local.H2VPN;
|
||||
import dev.brighten.antivpn.database.mongo.MongoVPN;
|
||||
import dev.brighten.antivpn.database.sql.MySqlVPN;
|
||||
import dev.brighten.antivpn.database.sqllite.LiteDatabase;
|
||||
import dev.brighten.antivpn.velocity.command.VelocityCommand;
|
||||
import lombok.Getter;
|
||||
import org.bstats.charts.SimplePie;
|
||||
@@ -88,14 +86,8 @@ public class VelocityPlugin {
|
||||
private String getDatabaseType() {
|
||||
VPNDatabase database = AntiVPN.getInstance().getDatabase();
|
||||
|
||||
if(database instanceof H2VPN) {
|
||||
return "H2";
|
||||
} else if(database instanceof MySqlVPN) {
|
||||
return "MySQL";
|
||||
} else if(database instanceof MongoVPN) {
|
||||
return "MongoDB";
|
||||
} else {
|
||||
return "No-Database";
|
||||
}
|
||||
if(database instanceof LiteDatabase) {
|
||||
return "SQLLite";
|
||||
} return "No-Database";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user