2021-11-28 01:13:21 +00:00
package net.t2code.lib.Spigot.system ;
import net.milkbowl.vault.economy.Economy ;
import net.milkbowl.vault.permission.Permission ;
import net.t2code.lib.Spigot.Lib.items.ItemVersion ;
import net.t2code.lib.Spigot.Lib.messages.send ;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion ;
import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion ;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate ;
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck ;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI ;
import net.t2code.lib.Spigot.Lib.vault.Vault ;
import net.t2code.lib.Spigot.system.config.ConfigCreate ;
import net.t2code.lib.Spigot.system.languages.LanguagesCreate ;
import net.t2code.lib.Util ;
import net.t2code.lib.Spigot.system.config.SelectLibConfig ;
import net.t2code.lib.Spigot.system.languages.SelectLibMsg ;
import org.bukkit.Bukkit ;
2021-12-31 00:35:09 +00:00
import org.bukkit.entity.Player ;
2021-11-28 01:13:21 +00:00
import org.bukkit.plugin.java.JavaPlugin ;
import java.io.File ;
import java.util.List ;
public final class Main extends JavaPlugin {
public static File getPath ( ) {
return plugin . getDataFolder ( ) ;
}
public static Main plugin ;
public static Economy eco = null ;
public static Permission perm = null ;
public static List < String > autor ;
public static String version ;
2021-12-31 01:17:24 +00:00
public static String prefix = Util . getPrefix ( ) ;
public static Integer spigotID = Util . getSpigotID ( ) ;
public static Integer bstatsID = Util . getBstatsID ( ) ;
public static String spigot = Util . getSpigot ( ) ;
public static String discord = Util . getDiscord ( ) ;
2021-11-28 01:13:21 +00:00
@Override
public void onEnable ( ) {
// Plugin startup logic
plugin = this ;
autor = plugin . getDescription ( ) . getAuthors ( ) ;
version = plugin . getDescription ( ) . getVersion ( ) ;
Long long_ ;
long_ = T2CodeTemplate . onLoadHeader ( prefix , autor , version , spigot , discord ) ;
2021-12-31 01:36:03 +00:00
if ( Util . getSnapshot ( ) ) {
send . console ( prefix + " §eYou are running §4 " + version + " §eof " + prefix + " §e! §4This is a trial version! §eSome features may not be working as expected. Please report all bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled! " ) ;
send . console ( prefix + " §4 §e------------------- " ) ;
try {
Thread . sleep ( 5000 ) ;
} catch ( InterruptedException e ) {
e . printStackTrace ( ) ;
}
}
2021-12-31 01:17:24 +00:00
2021-11-28 01:13:21 +00:00
//send.console("§4 _|_|_|_|_| _|_| _|_|_| _| ");
//send.console("§4 _| _| _| _| _|_| _|_|_| _|_| ");
//send.console("§4 _| _| _| _| _| _| _| _|_|_|_| ");
//send.console("§4 _| _| _| _| _| _| _| _| ");
//send.console("§4 _| _|_|_|_| _|_|_| _|_| _|_|_| _|_|_| ");
//T2CodeTemplate.onLoadSeparateStroke(prefix);
try {
Vault . loadVault ( ) ;
} catch ( InterruptedException e ) {
e . printStackTrace ( ) ;
}
NMSVersion . onCheck ( ) ;
MCVersion . onCheck ( ) ;
2021-12-31 00:35:09 +00:00
if ( MCVersion . minecraft1_19 ) {
send . warning ( this , " The 1.19 is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net " ) ;
try {
Thread . sleep ( 5000 ) ;
} catch ( InterruptedException e ) {
e . printStackTrace ( ) ;
}
2021-11-28 01:13:21 +00:00
}
ItemVersion . scan ( ) ;
send . console ( Main . prefix + " §3Server run on: §6 " + MCVersion . isVersion + " / " + NMSVersion . isNMS ) ;
if ( eco ! = null ) {
String st ;
st = eco . getName ( ) ;
if ( eco . getName ( ) . equals ( " CMIEconomy " ) ) st = " CMI " ;
if ( Bukkit . getPluginManager ( ) . getPlugin ( st ) ! = null ) {
send . console ( Main . prefix + " §3Economy: §6 " + eco . getName ( ) + " - " + Bukkit . getPluginManager ( ) . getPlugin ( st ) . getDescription ( ) . getVersion ( ) + " §7- §e " + ( System . currentTimeMillis ( ) - long_ . longValue ( ) ) + " ms " ) ;
} else send . console ( Main . prefix + " §3Economy: §6 " + eco . getName ( ) + " §7- §e " + ( System . currentTimeMillis ( ) - long_ . longValue ( ) ) + " ms " ) ;
} else send . console ( Main . prefix + " §3Economy: §4not connected via vault! " + " §7- §e " + ( System . currentTimeMillis ( ) - long_ . longValue ( ) ) + " ms " ) ;
if ( perm ! = null ) {
if ( Bukkit . getPluginManager ( ) . getPlugin ( perm . getName ( ) ) ! = null ) {
send . console ( Main . prefix + " §3Permission plugin: §6 " + perm . getName ( ) + " - " + Bukkit . getPluginManager ( ) . getPlugin ( perm . getName ( ) ) . getDescription ( ) . getVersion ( ) + " §7- §e " + ( System . currentTimeMillis ( ) - long_ . longValue ( ) ) + " ms " ) ;
} else send . console ( Main . prefix + " §3Permission plugin: §6 " + perm . getName ( ) + " - §7- §e " + ( System . currentTimeMillis ( ) - long_ . longValue ( ) ) + " ms " ) ;
} else send . console ( Main . prefix + " §3Permission plugin: §4not connected via vault! " + " §7- §e " + ( System . currentTimeMillis ( ) - long_ . longValue ( ) ) + " ms " ) ;
if ( PluginCheck . pluginCheck ( " PlaceholderAPI " ) ) {
send . console ( Main . prefix + " §3PlaceholderAPI: §6connected " + " §7- §e " + ( System . currentTimeMillis ( ) - long_ . longValue ( ) ) + " ms " ) ;
}
Main . plugin . getCommand ( " t2code " ) . setExecutor ( new CmdExecuter ( ) ) ;
ConfigCreate . configCreate ( ) ;
LanguagesCreate . langCreate ( ) ;
SelectLibConfig . onSelect ( ) ;
SelectLibMsg . onSelect ( prefix ) ;
2021-12-31 16:17:27 +00:00
if ( ! Util . getSnapshot ( ) ) {
UpdateAPI . onUpdateCheck ( plugin , prefix , spigot , spigotID , discord ) ;
Metrics . Bstats ( plugin , bstatsID ) ;
}
2021-12-31 01:17:24 +00:00
2021-11-28 01:13:21 +00:00
Bukkit . getServer ( ) . getPluginManager ( ) . registerEvents ( new JoinEvent ( ) , plugin ) ;
T2CodeTemplate . onLoadFooter ( prefix , long_ ) ;
}
@Override
public void onDisable ( ) {
// Plugin shutdown logic
2021-12-31 00:35:09 +00:00
if ( SelectLibConfig . InventoriesCloseByServerStop ) {
for ( Player player : Bukkit . getOnlinePlayers ( ) ) {
player . closeInventory ( ) ;
}
}
2021-11-28 01:13:21 +00:00
Vault . vaultDisable ( ) ;
T2CodeTemplate . onDisable ( prefix , autor , version , spigot , discord ) ;
}
}