mirror of
https://github.com/funkemunky/AntiVPN.git
synced 2026-06-04 10:52:20 +00:00
Adding universal config API and adding allowed/blocked country config
This commit is contained in:
@@ -23,6 +23,8 @@ public class BukkitConfig implements VPNConfig {
|
||||
"database.username", BukkitPlugin.pluginInstance),
|
||||
defaultPassword = new ConfigDefault<>("password",
|
||||
"database.password", BukkitPlugin.pluginInstance),
|
||||
|
||||
|
||||
defaultIp = new ConfigDefault<>("localhost", "database.ip", BukkitPlugin.pluginInstance),
|
||||
defaultAlertMsg = new ConfigDefault<>("&8[&6KauriVPN&8] &e%player% &7has joined on a VPN/proxy" +
|
||||
" &8(&f%reason%&8) &7in location &8(&f%city%&7, &f%country%&8)", "alerts.message",
|
||||
@@ -43,10 +45,14 @@ public class BukkitConfig implements VPNConfig {
|
||||
private final ConfigDefault<List<String>> prefixWhitelistsDefault = new ConfigDefault<>(new ArrayList<>(),
|
||||
"prefixWhitelists", BukkitPlugin.pluginInstance), defaultCommands = new ConfigDefault<>(
|
||||
Collections.singletonList("kick %player% VPNs are not allowed on our server!"), "commands.execute",
|
||||
BukkitPlugin.pluginInstance),
|
||||
defBlockedCountries = new ConfigDefault<>(new ArrayList<>(), "blockedCountries",
|
||||
BukkitPlugin.pluginInstance),
|
||||
defAllowedCountries = new ConfigDefault<>(new ArrayList<>(), "allowedCountries",
|
||||
BukkitPlugin.pluginInstance);
|
||||
|
||||
private String license, kickMessage, databaseType, databaseName, mongoURL, username, password, ip, alertMsg;
|
||||
private List<String> prefixWhitelists, commands;
|
||||
private List<String> prefixWhitelists, commands, allowedCountries, blockedCountries;
|
||||
private int port;
|
||||
private boolean cacheResults, databaseEnabled, useCredentials, commandsEnabled, kickPlayers, alertToStaff, metrics;
|
||||
|
||||
@@ -135,6 +141,16 @@ public class BukkitConfig implements VPNConfig {
|
||||
return ip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> allowedCountries() {
|
||||
return allowedCountries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> blockedCountries() {
|
||||
return blockedCountries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
if(port == -1) {
|
||||
@@ -177,5 +193,7 @@ public class BukkitConfig implements VPNConfig {
|
||||
alertToStaff = defaultAlertToStaff.get();
|
||||
alertMsg = defaultAlertMsg.get();
|
||||
metrics = defaultMetrics.get();
|
||||
blockedCountries = defBlockedCountries.get();
|
||||
allowedCountries = defAllowedCountries.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package dev.brighten.antivpn.bukkit;
|
||||
import dev.brighten.antivpn.AntiVPN;
|
||||
import dev.brighten.antivpn.bukkit.util.ConfigDefault;
|
||||
import dev.brighten.antivpn.command.Command;
|
||||
import dev.brighten.antivpn.utils.MiscUtils;
|
||||
import dev.brighten.antivpn.utils.config.Configuration;
|
||||
import lombok.val;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
@@ -16,6 +18,7 @@ import org.bukkit.plugin.SimplePluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -35,7 +38,12 @@ public class BukkitPlugin extends JavaPlugin {
|
||||
|
||||
//Loading config
|
||||
Bukkit.getLogger().info("Loading config...");
|
||||
saveDefaultConfig();
|
||||
Configuration config = new Configuration();
|
||||
File configFile = new File(getDataFolder(), "config.yml");
|
||||
if(!configFile.exists()){
|
||||
configFile.getParentFile().mkdirs();
|
||||
MiscUtils.copy(getResource( "config.yml"), configFile);
|
||||
}
|
||||
|
||||
Bukkit.getLogger().info("Starting AntiVPN services...");
|
||||
AntiVPN.start(new BukkitConfig(), new BukkitListener(), new BukkitPlayerExecutor(), getDataFolder());
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package dev.brighten.antivpn.bukkit.util;
|
||||
|
||||
import dev.brighten.antivpn.utils.MiscUtils;
|
||||
import dev.brighten.antivpn.utils.config.Configuration;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class ConfigDefault<A> {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user