2021-12-21 04:55:23 +00:00
package net.t2code.alias.Spigot ;
import net.t2code.alias.Spigot.objects.Alias_Objekt ;
import net.t2code.alias.Spigot.system.Load ;
import net.t2code.alias.Util ;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate ;
import org.bukkit.Bukkit ;
import org.bukkit.plugin.java.JavaPlugin ;
import java.io.File ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.List ;
2022-01-29 18:08:14 +00:00
import java.util.Objects ;
2021-12-21 04:55:23 +00:00
import java.util.logging.Level ;
public final class Main extends JavaPlugin {
public static File getPath ( ) {
return plugin . getDataFolder ( ) ;
}
public static String version ;
public static List < String > autor ;
public static Main plugin ;
public static HashMap < String , Alias_Objekt > aliasHashMap = new HashMap < > ( ) ;
public static ArrayList < String > allAliases = new ArrayList < > ( ) ;
@Override
public void onEnable ( ) {
// Plugin startup logic
plugin = this ;
autor = plugin . getDescription ( ) . getAuthors ( ) ;
version = plugin . getDescription ( ) . getVersion ( ) ;
2022-01-29 18:08:14 +00:00
if ( pluginNotFound ( " T2CodeLib " , 96388 , Util . getRequiredT2CodeLibVersion ( ) ) ) return ;
Load . onLoad ( Util . getPrefix ( ) , autor , version , Util . getSpigot ( ) , Util . getSpigotID ( ) , Util . getDiscord ( ) , Util . getBstatsID ( ) ) ;
2021-12-21 04:55:23 +00:00
}
@Override
public void onDisable ( ) {
// Plugin shutdown logic
aliasHashMap . clear ( ) ;
allAliases . clear ( ) ;
if ( Bukkit . getPluginManager ( ) . getPlugin ( " T2CodeLib " ) = = null ) return ;
2022-01-29 18:08:14 +00:00
T2CodeTemplate . onDisable ( Util . getPrefix ( ) , autor , version , Util . getSpigot ( ) , Util . getDiscord ( ) ) ;
2021-12-21 04:55:23 +00:00
}
2022-01-29 18:08:14 +00:00
public static Boolean pluginNotFound ( String pl , Integer spigotID , double ver ) {
2021-12-21 04:55:23 +00:00
if ( Bukkit . getPluginManager ( ) . getPlugin ( pl ) = = null ) {
plugin . getLogger ( ) . log ( Level . SEVERE , " Plugin can not be loaded! " ) ;
2022-01-29 18:08:14 +00:00
Bukkit . getConsoleSender ( ) . sendMessage ( Util . getPrefix ( ) + " §e " + pl + " §4could not be found. Please download it here: " +
2021-12-21 04:55:23 +00:00
" §6https://spigotmc.org/resources/ " + pl + " . " + spigotID + " §4to be able to use this plugin. " ) ;
Main . plugin . getPluginLoader ( ) . disablePlugin ( Main . plugin ) ;
2022-01-29 18:08:14 +00:00
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-21 04:55:23 +00:00
}
}
}