mirror of
https://github.com/funkemunky/AntiVPN.git
synced 2026-05-31 09:31:54 +00:00
Adding commands on vpn detect on login
This commit is contained in:
@@ -2,14 +2,17 @@ package dev.brighten.antivpn.bukkit;
|
||||
|
||||
import dev.brighten.antivpn.api.VPNConfig;
|
||||
import dev.brighten.antivpn.bukkit.util.ConfigDefault;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BukkitConfig implements VPNConfig {
|
||||
private final ConfigDefault<String> licenseDefault = new ConfigDefault<>("",
|
||||
"license", BukkitPlugin.pluginInstance), kickStringDefault =
|
||||
new ConfigDefault<>("Proxies are not allowed on our server",
|
||||
new ConfigDefault<>("Proxies are not allowed on our server",
|
||||
"kickMessage", BukkitPlugin.pluginInstance),
|
||||
defaultDatabaseType = new ConfigDefault<>("MySQL",
|
||||
"database.type", BukkitPlugin.pluginInstance),
|
||||
@@ -25,16 +28,19 @@ public class BukkitConfig implements VPNConfig {
|
||||
private final ConfigDefault<Boolean> cacheResultsDefault = new ConfigDefault<>(true,
|
||||
"cachedResults", BukkitPlugin.pluginInstance),
|
||||
defaultDatabaseEnabled = new ConfigDefault<>(false, "database.enabled",
|
||||
BukkitPlugin.pluginInstance);
|
||||
BukkitPlugin.pluginInstance), defaultCommandsEnable
|
||||
= new ConfigDefault<>(false, "commands.enabled", BukkitPlugin.pluginInstance);
|
||||
private final ConfigDefault<Integer>
|
||||
defaultPort = new ConfigDefault<>(-1, "database.port", BukkitPlugin.pluginInstance);
|
||||
private final ConfigDefault<List<String>> prefixWhitelistsDefault = new ConfigDefault<>(new ArrayList<>(),
|
||||
"prefixWhitelists", BukkitPlugin.pluginInstance);
|
||||
"prefixWhitelists", BukkitPlugin.pluginInstance), defaultCommands = new ConfigDefault<>(
|
||||
Collections.singletonList("kick %player% VPNs are not allowed on our server!"), "commands.execute",
|
||||
BukkitPlugin.pluginInstance);
|
||||
|
||||
private String license, kickMessage, databaseType, databaseName, username, password, ip;
|
||||
private List<String> prefixWhitelists;
|
||||
private List<String> prefixWhitelists, commands;
|
||||
private int port;
|
||||
private boolean cacheResults, databaseEnabled;
|
||||
private boolean cacheResults, databaseEnabled, commandsEnabled;
|
||||
|
||||
@Override
|
||||
public String getLicense() {
|
||||
@@ -51,6 +57,16 @@ public class BukkitConfig implements VPNConfig {
|
||||
return kickMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean runCommands() {
|
||||
return commandsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> commands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPrefixWhitelists() {
|
||||
return prefixWhitelists;
|
||||
@@ -115,5 +131,7 @@ public class BukkitConfig implements VPNConfig {
|
||||
password = defaultPassword.get();
|
||||
ip = defaultIp.get();
|
||||
port = defaultPort.get();
|
||||
commandsEnabled = defaultCommandsEnable.get();
|
||||
commands = defaultCommands.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,12 @@ public class BukkitListener extends VPNExecutor implements Listener {
|
||||
.anyMatch(prefix -> player.getName().startsWith(prefix)))
|
||||
player.kickPlayer(ChatColor.translateAlternateColorCodes('&',
|
||||
AntiVPN.getInstance().getConfig().getKickString()));
|
||||
|
||||
for (String command : AntiVPN.getInstance().getConfig().commands()) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
command.replace("%player%", event.getName())));
|
||||
}
|
||||
System.out.println(player.getPlayer().getName()
|
||||
+ " joined on a VPN/Proxy (" + result.getMethod() + ")");
|
||||
}
|
||||
|
||||
@@ -4,9 +4,10 @@ import dev.brighten.antivpn.api.VPNConfig;
|
||||
import dev.brighten.antivpn.bungee.util.ConfigDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BungeeConfig implements VPNConfig { ;
|
||||
public class BungeeConfig implements VPNConfig {
|
||||
private final ConfigDefault<String> licenseDefault = new ConfigDefault<>("",
|
||||
"license", BungeePlugin.pluginInstance), kickStringDefault =
|
||||
new ConfigDefault<>("Proxies are not allowed on our server",
|
||||
@@ -25,16 +26,19 @@ public class BungeeConfig implements VPNConfig { ;
|
||||
private final ConfigDefault<Boolean> cacheResultsDefault = new ConfigDefault<>(true,
|
||||
"cachedResults", BungeePlugin.pluginInstance),
|
||||
defaultDatabaseEnabled = new ConfigDefault<>(false, "database.enabled",
|
||||
BungeePlugin.pluginInstance);
|
||||
BungeePlugin.pluginInstance), defaultCommandsEnable
|
||||
= new ConfigDefault<>(false, "commands.enabled", BungeePlugin.pluginInstance);
|
||||
private final ConfigDefault<Integer>
|
||||
defaultPort = new ConfigDefault<>(-1, "database.port", BungeePlugin.pluginInstance);
|
||||
private final ConfigDefault<List<String>> prefixWhitelistsDefault = new ConfigDefault<>(new ArrayList<>(),
|
||||
"prefixWhitelists", BungeePlugin.pluginInstance);
|
||||
"prefixWhitelists", BungeePlugin.pluginInstance), defaultCommands = new ConfigDefault<>(
|
||||
Collections.singletonList("kick %player% VPNs are not allowed on our server!"), "commands.execute",
|
||||
BungeePlugin.pluginInstance);
|
||||
|
||||
private String license, kickMessage, databaseType, databaseName, username, password, ip;
|
||||
private List<String> prefixWhitelists;
|
||||
private List<String> prefixWhitelists, commands;
|
||||
private int port;
|
||||
private boolean cacheResults, databaseEnabled;
|
||||
private boolean cacheResults, databaseEnabled, commandsEnabled;
|
||||
|
||||
@Override
|
||||
public String getLicense() {
|
||||
@@ -51,6 +55,16 @@ public class BungeeConfig implements VPNConfig { ;
|
||||
return kickMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean runCommands() {
|
||||
return commandsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> commands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPrefixWhitelists() {
|
||||
return prefixWhitelists;
|
||||
@@ -115,5 +129,7 @@ public class BungeeConfig implements VPNConfig { ;
|
||||
password = defaultPassword.get();
|
||||
ip = defaultIp.get();
|
||||
port = defaultPort.get();
|
||||
commandsEnabled = defaultCommandsEnable.get();
|
||||
commands = defaultCommands.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.event.TabCompleteEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
@@ -56,6 +55,15 @@ public class BungeeListener extends VPNExecutor implements Listener {
|
||||
AntiVPN.getInstance().getConfig().getKickString())));
|
||||
System.out.println(event.getPlayer().getName()
|
||||
+ " joined on a VPN/Proxy (" + result.getMethod() + ")");
|
||||
|
||||
if(AntiVPN.getInstance().getConfig().runCommands()) {
|
||||
for (String command : AntiVPN.getInstance().getConfig().commands()) {
|
||||
BungeeCord.getInstance().getPluginManager()
|
||||
.dispatchCommand(BungeeCord.getInstance().getConsole(),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
command.replace("%player%", event.getPlayer().getName())));
|
||||
}
|
||||
}
|
||||
} else if(!result.isSuccess()) {
|
||||
BungeeCord.getInstance().getLogger()
|
||||
.log(Level.WARNING,
|
||||
|
||||
@@ -10,6 +10,10 @@ public interface VPNConfig {
|
||||
|
||||
String getKickString();
|
||||
|
||||
boolean runCommands();
|
||||
|
||||
List<String> commands();
|
||||
|
||||
List<String> getPrefixWhitelists();
|
||||
|
||||
boolean isDatabaseEnabled();
|
||||
|
||||
Reference in New Issue
Block a user