mirror of
https://github.com/funkemunky/AntiVPN.git
synced 2026-05-31 09:31:54 +00:00
Added backwards and forwards compatibility for Atlas 1.6+
This commit is contained in:
@@ -54,6 +54,12 @@
|
||||
<version>1.6.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cc.funkemunky.utils</groupId>
|
||||
<artifactId>Atlas</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package dev.brighten.pl;
|
||||
|
||||
import cc.funkemunky.api.Atlas;
|
||||
import cc.funkemunky.api.reflections.types.WrappedClass;
|
||||
import cc.funkemunky.api.utils.MiscUtils;
|
||||
import dev.brighten.pl.handlers.AlertsHandler;
|
||||
import dev.brighten.pl.handlers.VPNHandler;
|
||||
import dev.brighten.pl.vpn.VPNAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class AntiVPN extends JavaPlugin {
|
||||
@@ -17,6 +19,8 @@ public class AntiVPN extends JavaPlugin {
|
||||
|
||||
public VPNHandler vpnHandler;
|
||||
public AlertsHandler alertsHandler;
|
||||
public String atlasVersion;
|
||||
public Plugin atlasInstance;
|
||||
|
||||
public void onEnable() {
|
||||
INSTANCE = this;
|
||||
@@ -28,9 +32,20 @@ public class AntiVPN extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void enable() {
|
||||
System.out.println("Enabling Atlas hook...");
|
||||
if((atlasInstance = Bukkit.getPluginManager().getPlugin("Atlas")) != null) {
|
||||
atlasVersion = atlasInstance.getDescription().getVersion();
|
||||
} else {
|
||||
System.out.println("Atlas not found! Disabling...");
|
||||
this.disable();
|
||||
return;
|
||||
}
|
||||
saveDefaultConfig();
|
||||
print(true, "scanner");
|
||||
Atlas.getInstance().initializeScanner(this, true, true);
|
||||
//We use reflection and check versions to add backwards compatibility for the time being.
|
||||
new WrappedClass(Atlas.class).getMethod("initializeScanner",
|
||||
atlasVersion.startsWith("1.6") ? JavaPlugin.class : Plugin.class, boolean.class, boolean.class)
|
||||
.invoke(atlasInstance, this, true, true);
|
||||
|
||||
print(true, "vpn api and handlers");
|
||||
vpnAPI = new VPNAPI();
|
||||
|
||||
Reference in New Issue
Block a user