Near final staged for refactor

This commit is contained in:
2025-12-04 14:19:02 -05:00
parent c7734b2294
commit c95c9bb8f3
17 changed files with 265 additions and 104 deletions
-4
View File
@@ -53,10 +53,6 @@
<resource>antivpn-bukkit.jarinjar</resource>
<file>${project.parent.basedir}/Plugin/target/Plugin-${project.version}.jar</file>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
<resource>antivpn-source.jarinjar</resource>
<file>${project.parent.parent.basedir}/Common/Source/target/Source-${project.version}.jar</file>
</transformer>
</transformers>
</configuration>
</execution>
+1 -1
View File
@@ -95,7 +95,7 @@
<groupId>dev.brighten.antivpn</groupId>
<artifactId>loader-utils</artifactId>
<version>1.9.4</version>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
</dependencies>
+87
View File
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>dev.brighten.antivpn</groupId>
<artifactId>Bungee</artifactId>
<version>1.9.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>dev.brighten.antivpn.bungee</groupId>
<artifactId>BungeeLoader</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>17</source>
<target>17</target>
<compilerArgument>-XDignore.symbol.file</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>false</minimizeJar>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
<resource>antivpn-bungee.jarinjar</resource>
<file>${project.parent.basedir}/BungeePlugin/target/BungeePlugin-${project.version}.jar</file>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.21-R0.2</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dev.brighten.antivpn</groupId>
<artifactId>Plugin</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dev.brighten.antivpn</groupId>
<artifactId>loader-utils</artifactId>
<version>1.9.4</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,36 @@
package dev.brighten.antivpn.bungee;
import dev.brighten.antivpn.loader.JarInJarClassLoader;
import dev.brighten.antivpn.loader.LoaderBootstrap;
import net.md_5.bungee.api.plugin.Plugin;
public class BungeeLoaderPlugin extends Plugin {
private static final String JAR_NAME = "antivpn-bungee.jarinjar";
private static final String SOURCE_NAME = "antivpn-source.jarinjar";
private static final String BOOTSTRAP_CLASS = "dev.brighten.antivpn.bungee.BungeePlugin";
private final LoaderBootstrap plugin;
public BungeeLoaderPlugin() {
JarInJarClassLoader loader = new JarInJarClassLoader(getClass().getClassLoader(), JAR_NAME, SOURCE_NAME);
this.plugin = loader.instantiatePlugin(BOOTSTRAP_CLASS, Plugin.class, this);
}
@Override
public void onLoad() {
this.plugin.onLoad(getDataFolder());
}
@Override
public void onEnable() {
this.plugin.onEnable();
}
@Override
public void onDisable() {
this.plugin.onDisable();
}
}
@@ -1,5 +1,5 @@
name: KauriVPN
main: dev.brighten.antivpn.bungee.BungeePlugin
main: dev.brighten.antivpn.bungee.BungeeLoaderPlugin
description: A simple and fast antivpn plugin.
version: ${project.version}
author: funkemunky
+96
View File
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>dev.brighten.antivpn</groupId>
<artifactId>Bungee</artifactId>
<version>1.9.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>BungeePlugin</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>17</source>
<target>17</target>
<compilerArgument>-XDignore.symbol.file</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<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>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>dev.brighten.antivpn</groupId>
<artifactId>Source</artifactId>
<version>1.9.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.21-R0.2</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bungeecord</artifactId>
<version>2.2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>dev.brighten.antivpn</groupId>
<artifactId>loader-utils</artifactId>
<version>1.9.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -25,7 +25,7 @@ public class BungeeListener extends VPNExecutor implements Listener {
@Override
public void registerListeners() {
BungeePlugin.pluginInstance.getProxy().getPluginManager()
.registerListener(BungeePlugin.pluginInstance, this);
.registerListener(BungeePlugin.pluginInstance.getPlugin(), this);
}
@Override
@@ -51,12 +51,12 @@ public class BungeeListener extends VPNExecutor implements Listener {
@Override
public void disablePlugin() {
BungeePlugin.pluginInstance.getProxy().getPluginManager().unregisterListeners(BungeePlugin.pluginInstance);
BungeePlugin.pluginInstance.getProxy().getPluginManager().unregisterListeners(BungeePlugin.pluginInstance.getPlugin());
if (cacheResetTask != null) {
cacheResetTask.cancel();
cacheResetTask = null;
}
BungeePlugin.pluginInstance.getProxy().getPluginManager().unregisterCommands(BungeePlugin.pluginInstance);
BungeePlugin.pluginInstance.getProxy().getPluginManager().unregisterCommands(BungeePlugin.pluginInstance.getPlugin());
BungeePlugin.pluginInstance.onDisable();
}
@@ -7,39 +7,58 @@ 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.loader.LoaderBootstrap;
import lombok.Getter;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import org.bstats.bungeecord.Metrics;
import org.bstats.charts.SimplePie;
import java.io.File;
import java.util.concurrent.TimeUnit;
public class BungeePlugin extends Plugin {
public class BungeePlugin implements LoaderBootstrap {
public static BungeePlugin pluginInstance;
@Getter
private File dataFolder;
@Getter
private final Plugin plugin;
public BungeePlugin(Plugin plugin) {
this.plugin = plugin;
}
@Override
public void onLoad(File dataFolder) {
this.dataFolder = dataFolder;
}
@Override
public void onEnable() {
pluginInstance = this;
//Setting up config
getProxy().getLogger().info("Loading config...");
ProxyServer.getInstance().getLogger().info("Loading config...");
//Loading plugin
getProxy().getLogger().info("Starting AntiVPN services...");
ProxyServer.getInstance().getLogger().info("Starting AntiVPN services...");
AntiVPN.start(new BungeeListener(), new BungeePlayerExecutor(), getDataFolder());
if(AntiVPN.getInstance().getVpnConfig().metrics()) {
getProxy().getLogger().info("Starting bStats metrics...");
Metrics metrics = new Metrics(this, 12616);
ProxyServer.getInstance().getLogger().info("Starting bStats metrics...");
Metrics metrics = new Metrics(getPlugin(), 12616);
metrics.addCustomChart(new SimplePie("database_used", this::getDatabaseType));
getProxy().getScheduler().schedule(this,
ProxyServer.getInstance().getScheduler().schedule(getPlugin(),
() -> AntiVPN.getInstance().checked = AntiVPN.getInstance().detections = 0,
10, 10, TimeUnit.MINUTES);
}
for (Command command : AntiVPN.getInstance().getCommands()) {
getProxy().getPluginManager().registerCommand(pluginInstance, new BungeeCommand(command));
ProxyServer.getInstance().getPluginManager().registerCommand(getPlugin(), new BungeeCommand(command));
}
}
@@ -61,4 +80,8 @@ public class BungeePlugin extends Plugin {
return "No-Database";
}
}
public ProxyServer getProxy() {
return ProxyServer.getInstance();
}
}
+1 -74
View File
@@ -7,82 +7,9 @@
<groupId>dev.brighten.antivpn</groupId>
<version>1.9.4</version>
</parent>
<packaging>pom</packaging>
<modelVersion>4.0.0</modelVersion>
<artifactId>Bungee</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>17</source>
<target>17</target>
<compilerArgument>-XDignore.symbol.file</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<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>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>dev.brighten.antivpn</groupId>
<artifactId>Source</artifactId>
<version>1.9.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.21-R0.2</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bungeecord</artifactId>
<version>2.2.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
+7 -9
View File
@@ -18,12 +18,6 @@
</properties>
<dependencies>
<dependency>
<groupId>dev.brighten.antivpn</groupId>
<artifactId>Source</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>dev.brighten.antivpn.bukkit</groupId>
<artifactId>Loader</artifactId>
@@ -32,13 +26,13 @@
</dependency>
<dependency>
<groupId>dev.brighten.antivpn</groupId>
<artifactId>Bungee</artifactId>
<artifactId>VelocityLoader</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>dev.brighten.antivpn</groupId>
<artifactId>VelocityPlugin</artifactId>
<groupId>dev.brighten.antivpn.bungee</groupId>
<artifactId>BungeeLoader</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
@@ -61,6 +55,10 @@
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
<resource>antivpn-source.jarinjar</resource>
<file>${project.parent.basedir}/Common/Source/target/Source-${project.version}.jar</file>
</transformer>
</transformers>
<relocations>
<relocation>
-4
View File
@@ -81,10 +81,6 @@
<resource>antivpn-velocity.jarinjar</resource>
<file>${project.parent.basedir}/VelocityPlugin/target/VelocityPlugin-${project.version}.jar</file>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
<resource>antivpn-source.jarinjar</resource>
<file>${project.parent.parent.basedir}/Common/Source/target/Source-${project.version}.jar</file>
</transformer>
</transformers>
<relocations>
<relocation>
+1 -1
View File
@@ -48,7 +48,7 @@
<groupId>dev.brighten.antivpn</groupId>
<artifactId>loader-utils</artifactId>
<version>1.9.4</version>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
</dependencies>
+2
View File
@@ -18,6 +18,8 @@
<module>Universal</module>
<module>Velocity/VelocityLoader</module>
<module>Velocity/VelocityPlugin</module>
<module>Bungee/BungeeLoader</module>
<module>Bungee/BungeePlugin</module>
</modules>
<properties>