Debugging velocity

This commit is contained in:
funkemunky
2022-03-30 09:47:40 -04:00
parent 0db8b93a7c
commit 0fccd9e296
2 changed files with 13 additions and 3 deletions
@@ -48,9 +48,9 @@ public class VPNConfig {
Collections.singletonList("kick %player% VPNs are not allowed on our server!"), "commands.execute",
AntiVPN.getInstance()),
defCountryKickCommands = new ConfigDefault<>(Collections.singletonList(
"&cSorry, but our server does not allow connections from\n&f%name%"),
"countries.kickMessage", AntiVPN.getInstance()),
defCountrylist = new ConfigDefault<>(new ArrayList<>(), " countries.list",
"kick %player% &cSorry, but our server does not allow connections from\\n&f%country%"),
"countries.commands", AntiVPN.getInstance()),
defCountrylist = new ConfigDefault<>(new ArrayList<>(), "countries.list",
AntiVPN.getInstance());
private String license, kickMessage, databaseType, databaseName, mongoURL, username, password, ip, alertMsg;
@@ -4,6 +4,7 @@ import com.velocitypowered.api.event.connection.LoginEvent;
import com.velocitypowered.api.scheduler.ScheduledTask;
import dev.brighten.antivpn.AntiVPN;
import dev.brighten.antivpn.api.APIPlayer;
import dev.brighten.antivpn.api.VPNConfig;
import dev.brighten.antivpn.api.VPNExecutor;
import dev.brighten.antivpn.velocity.util.StringUtils;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
@@ -73,6 +74,14 @@ public class VelocityListener extends VPNExecutor {
AntiVPN.getInstance().detections++;
}
for (String s : AntiVPN.getInstance().getVpnConfig().countryList()) {
VelocityPlugin.INSTANCE.getLogger().info(s);
}
System.out.println("Code: '" + result.getCountryCode() + "'");
System.out.println("Contains: " + AntiVPN.getInstance().getVpnConfig().countryList()
.contains(result.getCountryCode()) + ", "
+ AntiVPN.getInstance().getVpnConfig().whitelistCountries());
// If the countryList() size is zero, no need to check.
if(AntiVPN.getInstance().getVpnConfig().countryList().size() > 0
// This bit of code will decide whether or not to kick the player
@@ -88,6 +97,7 @@ public class VelocityListener extends VPNExecutor {
cmd.replace("%player%", event.getPlayer().getUsername())
.replace("%country%", result.getCountryName())
.replace("%code%", result.getCountryCode()));
System.out.println(formattedCommand);
VelocityPlugin.INSTANCE.getServer().getCommandManager()
.executeAsync(VelocityPlugin.INSTANCE.getServer()
.getConsoleCommandSource(),