2021-12-29 02:28:50 +00:00
package de.jatitv.opsecurity.system ;
2022-01-06 01:08:20 +00:00
import de.jatitv.opsecurity.Util ;
2021-12-29 02:28:50 +00:00
import de.jatitv.opsecurity.objects.PlayerObject ;
2022-01-06 01:08:20 +00:00
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate ;
2021-12-29 02:28:50 +00:00
import org.bukkit.Bukkit ;
import org.bukkit.plugin.java.JavaPlugin ;
import java.io.File ;
import java.util.HashMap ;
import java.util.List ;
2022-01-06 01:08:20 +00:00
import java.util.Objects ;
import java.util.logging.Level ;
2021-12-29 02:28:50 +00:00
public final class Main extends JavaPlugin {
2022-01-06 01:08:20 +00:00
public static List < String > autor ;
public static String version ;
2021-12-29 02:28:50 +00:00
public static Main plugin ;
2022-01-06 01:08:20 +00:00
private static boolean enable ;
2021-12-29 02:28:50 +00:00
public static File getPath ( ) {
return plugin . getDataFolder ( ) ;
}
public static HashMap < String , PlayerObject > opHashMap = new HashMap < String , PlayerObject > ( ) ;
public static HashMap < String , PlayerObject > permissionHashMap = new HashMap < String , PlayerObject > ( ) ;
@Override
public void onEnable ( ) {
// Plugin startup logic
plugin = this ;
2022-01-06 01:08:20 +00:00
try {
enable ( ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
2021-12-29 02:28:50 +00:00
}
2022-01-06 01:08:20 +00:00
}
private static void enable ( ) {
autor = plugin . getDescription ( ) . getAuthors ( ) ;
version = plugin . getDescription ( ) . getVersion ( ) ;
if ( pluginNotFound ( " T2CodeLib " , 96388 , Util . getRequiredT2CodeLibVersion ( ) ) ) return ;
Load . onLoad ( Util . getPrefix ( ) , autor , version , Util . getSpigot ( ) , Util . getSpigotID ( ) , Util . getDiscord ( ) , Util . getBstatsID ( ) ) ;
enable = true ;
2021-12-29 02:28:50 +00:00
}
@Override
public void onDisable ( ) {
// Plugin shutdown logic
2022-01-06 01:08:20 +00:00
if ( enable ) T2CodeTemplate . onDisable ( Util . getPrefix ( ) , autor , version , Util . getSpigot ( ) , Util . getDiscord ( ) ) ;
}
public static Boolean pluginNotFound ( String pl , Integer spigotID , double ver ) {
if ( Bukkit . getPluginManager ( ) . getPlugin ( pl ) = = null ) {
plugin . getLogger ( ) . log ( Level . SEVERE , " Plugin can not be loaded! " ) ;
Bukkit . getConsoleSender ( ) . sendMessage ( Util . getPrefix ( ) + " §e " + pl + " §4could not be found. Please download it here: " +
" §6https://spigotmc.org/resources/ " + pl + " . " + spigotID + " §4to be able to use this plugin. " ) ;
Main . plugin . getPluginLoader ( ) . disablePlugin ( Main . plugin ) ;
return true ;
} else {
if ( Double . parseDouble ( Objects . requireNonNull ( Bukkit . getPluginManager ( ) . getPlugin ( pl ) ) . getDescription ( ) . getVersion ( ) ) < ver ) {
plugin . getLogger ( ) . log ( Level . SEVERE , " Plugin can not be loaded! " ) ;
Bukkit . getConsoleSender ( ) . sendMessage ( Util . getPrefix ( ) + " §e " + pl + " §4is out of date! This plugin requires at least version §2 " + ver + " §4of §6 " + pl + " §4Please update it here: §6https://spigotmc.org/resources/ " + pl + " . " + spigotID + " §4to use this version of " + plugin . getDescription ( ) . getName ( ) + " . " ) ;
Main . plugin . getPluginLoader ( ) . disablePlugin ( Main . plugin ) ;
return true ;
}
return false ;
}
2021-12-29 02:28:50 +00:00
}
}