2018-04-07 02:10:25 +02:00
package net.ME1312.SubServers.Bungee.Library.Compatibility ;
2021-02-07 05:53:03 +01:00
import net.ME1312.Galaxi.Library.Callback.ExceptionRunnable ;
2020-11-11 08:35:02 +01:00
import net.ME1312.Galaxi.Library.Util ;
2020-11-16 21:34:59 +01:00
2020-11-11 08:35:02 +01:00
import net.md_5.bungee.api.ProxyServer ;
import net.md_5.bungee.api.plugin.PluginDescription ;
import java.io.File ;
2021-02-07 05:53:03 +01:00
import java.io.IOException ;
2020-11-11 08:35:02 +01:00
public final class Plugin extends net . md_5 . bungee . api . plugin . Plugin {
private static final PluginDescription description = new PluginDescription ( ) ;
2021-02-07 05:53:03 +01:00
private final ExceptionRunnable enable ;
private final Runnable disable ;
2020-11-11 08:35:02 +01:00
@Deprecated
public Plugin ( ) {
2021-02-07 05:53:03 +01:00
enable = null ;
disable = null ;
2020-11-11 08:35:02 +01:00
}
private static PluginDescription describe ( ) {
description . setName ( " SubServers-Bungee " ) ;
description . setMain ( Plugin . class . getCanonicalName ( ) ) ;
description . setFile ( Util . getDespiteException ( ( ) - > new File ( Plugin . class . getProtectionDomain ( ) . getCodeSource ( ) . getLocation ( ) . toURI ( ) ) , null ) ) ;
description . setVersion ( net . ME1312 . SubServers . Bungee . SubProxy . version . toString ( ) ) ;
description . setAuthor ( " ME1312 " ) ;
return description ;
}
2021-02-07 05:53:03 +01:00
public Plugin ( ProxyServer proxy , ExceptionRunnable enable , Runnable disable ) {
2020-11-11 08:35:02 +01:00
super ( proxy , describe ( ) ) ;
2021-02-07 05:53:03 +01:00
this . enable = enable ;
this . disable = disable ;
2020-11-11 08:35:02 +01:00
// 2020 BungeeCord builds don't run init(), but future builds may uncomment that line. We wouldn't want to repeat ourselves.
if ( getDescription ( ) = = null ) Util . isException ( ( ) - > Util . reflect ( net . md_5 . bungee . api . plugin . Plugin . class . getDeclaredMethod ( " init " , ProxyServer . class , PluginDescription . class ) , this , proxy , description ) ) ;
}
2018-04-07 02:10:25 +02:00
@Override
public void onEnable ( ) {
2021-02-07 05:53:03 +01:00
if ( enable = = null ) {
throw new IllegalStateException ( " SubServers.Bungee does not run as a plugin, but a wrapper. For more information on how to install, please visit this page: https://github.com/ME1312/SubServers-2/wiki/Install " ) ;
} else try {
enable . run ( ) ;
} catch ( Throwable e ) {
e . printStackTrace ( ) ;
}
}
@Override
public void onDisable ( ) {
if ( disable ! = null ) disable . run ( ) ;
2018-04-07 02:10:25 +02:00
}
}