2021-11-28 01:13:21 +00:00
package net.t2code.lib.Spigot.system ;
2022-07-07 11:43:50 +00:00
import net.kyori.adventure.platform.bukkit.BukkitAudiences ;
2021-11-28 01:13:21 +00:00
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.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 ;
2022-06-08 03:13:00 +00:00
public final class T2CodeMain extends JavaPlugin {
12.0 Innovation and Eco API change
The API for Economy has been rebuilt.
- - Class renamed: net.t2code.lib.Spigot.Lib.vault.Vault -> net.t2code.lib.Spigot.Lib.eco.Eco
- Methods renamed:
- buy(String prefix, Player p, Double price) -> moneyRemove(String prefix, Player player, Double price)
- addMoney(String prefix, Player p, Double price) -> moneyAdd(String prefix, Player player, Double price)
- New methods:
- itemRemove(Player player, String item, int amount)
- itemAdd(Player player, String item, int amount)
- votePointsRemove(String prefix, Player player, Integer amount) (for VotingPlugin)
- votePointsAdd(String prefix, Player player, Integer amount) (for VotingPlugin)
- VotingPlugin added to PluginCheck
2022-06-07 03:58:47 +00:00
2021-11-28 01:13:21 +00:00
public static File getPath ( ) {
return plugin . getDataFolder ( ) ;
}
2022-07-07 11:43:50 +00:00
public static BukkitAudiences adventure ;
2022-06-08 03:13:00 +00:00
private static T2CodeMain plugin ;
private static Economy eco = null ;
private static Permission perm = null ;
private static List < String > autor ;
private static String version ;
private static String prefix = Util . getPrefix ( ) ;
private static Integer spigotID = Util . getSpigotID ( ) ;
private static Integer bstatsID = Util . getBstatsID ( ) ;
private static String spigot = Util . getSpigot ( ) ;
private static String discord = Util . getDiscord ( ) ;
private static Boolean load = false ;
public static String getDiscord ( ) {
return discord ;
}
public static T2CodeMain getPlugin ( ) {
return plugin ;
}
public static Economy getEco ( ) {
return eco ;
}
2022-06-18 14:16:26 +00:00
static void setEco ( Economy eco ) {
2022-06-08 03:13:00 +00:00
T2CodeMain . eco = eco ;
}
public static Permission getPerm ( ) {
return perm ;
}
2021-11-28 01:13:21 +00:00
2022-06-08 03:13:00 +00:00
public static List < String > getAutor ( ) {
return autor ;
}
2021-11-28 01:13:21 +00:00
2022-06-08 03:13:00 +00:00
public static String getVersion ( ) {
return version ;
}
public static String getPrefix ( ) {
return prefix ;
}
public static Integer getSpigotID ( ) {
return spigotID ;
}
public static Integer getBstatsID ( ) {
return bstatsID ;
}
public static String getSpigot ( ) {
return spigot ;
}
public static Boolean getLoad ( ) {
return load ;
}
public static void setPerm ( Permission perm ) {
T2CodeMain . perm = perm ;
}
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 ( ) ;
2022-07-07 11:43:50 +00:00
this . adventure = BukkitAudiences . create ( this ) ;
2022-02-09 13:40:27 +00:00
long long_ ;
2021-11-28 01:13:21 +00:00
long_ = T2CodeTemplate . onLoadHeader ( prefix , autor , version , spigot , discord ) ;
12.0 Innovation and Eco API change
The API for Economy has been rebuilt.
- - Class renamed: net.t2code.lib.Spigot.Lib.vault.Vault -> net.t2code.lib.Spigot.Lib.eco.Eco
- Methods renamed:
- buy(String prefix, Player p, Double price) -> moneyRemove(String prefix, Player player, Double price)
- addMoney(String prefix, Player p, Double price) -> moneyAdd(String prefix, Player player, Double price)
- New methods:
- itemRemove(Player player, String item, int amount)
- itemAdd(Player player, String item, int amount)
- votePointsRemove(String prefix, Player player, Integer amount) (for VotingPlugin)
- votePointsAdd(String prefix, Player player, Integer amount) (for VotingPlugin)
- VotingPlugin added to PluginCheck
2022-06-07 03:58:47 +00:00
if ( Util . getSnapshot ( ) ) {
2022-02-09 13:40:27 +00:00
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! " ) ;
2021-12-31 01:36:03 +00:00
send . console ( prefix + " §4 §e------------------- " ) ;
}
2021-12-31 01:17:24 +00:00
2021-11-28 01:13:21 +00:00
try {
Vault . loadVault ( ) ;
} catch ( InterruptedException e ) {
e . printStackTrace ( ) ;
}
NMSVersion . onCheck ( ) ;
MCVersion . onCheck ( ) ;
12.0 Innovation and Eco API change
The API for Economy has been rebuilt.
- - Class renamed: net.t2code.lib.Spigot.Lib.vault.Vault -> net.t2code.lib.Spigot.Lib.eco.Eco
- Methods renamed:
- buy(String prefix, Player p, Double price) -> moneyRemove(String prefix, Player player, Double price)
- addMoney(String prefix, Player p, Double price) -> moneyAdd(String prefix, Player player, Double price)
- New methods:
- itemRemove(Player player, String item, int amount)
- itemAdd(Player player, String item, int amount)
- votePointsRemove(String prefix, Player player, Integer amount) (for VotingPlugin)
- votePointsAdd(String prefix, Player player, Integer amount) (for VotingPlugin)
- VotingPlugin added to PluginCheck
2022-06-07 03:58:47 +00:00
if ( MCVersion . minecraft1_19 ) {
2022-06-08 04:27:05 +00:00
send . console ( prefix + " §4!!!!!!!!!!!!!!!!!!!! " ) ;
send . console ( prefix ) ;
2022-07-08 17:06:22 +00:00
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 " ) ;
2022-06-08 04:27:05 +00:00
send . console ( prefix ) ;
send . console ( prefix + " §4!!!!!!!!!!!!!!!!!!!! " ) ;
2021-12-31 00:35:09 +00:00
try {
Thread . sleep ( 5000 ) ;
} catch ( InterruptedException e ) {
e . printStackTrace ( ) ;
}
2021-11-28 01:13:21 +00:00
}
ItemVersion . scan ( ) ;
2022-06-08 03:13:00 +00:00
send . console ( T2CodeMain . prefix + " §3Server run on: §6 " + MCVersion . isVersion + " / " + NMSVersion . isNMS ) ;
2021-11-28 01:13:21 +00:00
if ( eco ! = null ) {
2022-02-09 13:40:27 +00:00
String st = eco . getName ( ) ;
2021-11-28 01:13:21 +00:00
if ( eco . getName ( ) . equals ( " CMIEconomy " ) ) st = " CMI " ;
12.0 Innovation and Eco API change
The API for Economy has been rebuilt.
- - Class renamed: net.t2code.lib.Spigot.Lib.vault.Vault -> net.t2code.lib.Spigot.Lib.eco.Eco
- Methods renamed:
- buy(String prefix, Player p, Double price) -> moneyRemove(String prefix, Player player, Double price)
- addMoney(String prefix, Player p, Double price) -> moneyAdd(String prefix, Player player, Double price)
- New methods:
- itemRemove(Player player, String item, int amount)
- itemAdd(Player player, String item, int amount)
- votePointsRemove(String prefix, Player player, Integer amount) (for VotingPlugin)
- votePointsAdd(String prefix, Player player, Integer amount) (for VotingPlugin)
- VotingPlugin added to PluginCheck
2022-06-07 03:58:47 +00:00
if ( Bukkit . getPluginManager ( ) . getPlugin ( st ) ! = null ) {
2022-06-08 03:13:00 +00:00
send . console ( T2CodeMain . prefix + " §3Economy: §6 " + eco . getName ( ) + " - " + Bukkit . getPluginManager ( ) . getPlugin ( st ) . getDescription ( ) . getVersion ( ) + " §7- §e " +
2022-02-09 13:40:27 +00:00
( System . currentTimeMillis ( ) - long_ ) + " ms " ) ;
2022-06-08 03:13:00 +00:00
} else send . console ( T2CodeMain . prefix + " §3Economy: §6 " + eco . getName ( ) + " §7- §e " + ( System . currentTimeMillis ( ) - long_ ) + " ms " ) ;
} else send . console ( T2CodeMain . prefix + " §3Economy: §4not connected via vault! " + " §7- §e " + ( System . currentTimeMillis ( ) - long_ ) + " ms " ) ;
2021-11-28 01:13:21 +00:00
if ( perm ! = null ) {
12.0 Innovation and Eco API change
The API for Economy has been rebuilt.
- - Class renamed: net.t2code.lib.Spigot.Lib.vault.Vault -> net.t2code.lib.Spigot.Lib.eco.Eco
- Methods renamed:
- buy(String prefix, Player p, Double price) -> moneyRemove(String prefix, Player player, Double price)
- addMoney(String prefix, Player p, Double price) -> moneyAdd(String prefix, Player player, Double price)
- New methods:
- itemRemove(Player player, String item, int amount)
- itemAdd(Player player, String item, int amount)
- votePointsRemove(String prefix, Player player, Integer amount) (for VotingPlugin)
- votePointsAdd(String prefix, Player player, Integer amount) (for VotingPlugin)
- VotingPlugin added to PluginCheck
2022-06-07 03:58:47 +00:00
if ( Bukkit . getPluginManager ( ) . getPlugin ( perm . getName ( ) ) ! = null ) {
2022-06-08 03:13:00 +00:00
send . console ( T2CodeMain . prefix + " §3Permission plugin: §6 " + perm . getName ( ) + " - " + Bukkit . getPluginManager ( ) . getPlugin ( perm . getName ( ) ) . getDescription ( ) . getVersion ( )
2022-02-09 13:40:27 +00:00
+ " §7- §e " + ( System . currentTimeMillis ( ) - long_ ) + " ms " ) ;
2022-06-08 03:13:00 +00:00
} else send . console ( T2CodeMain . prefix + " §3Permission plugin: §6 " + perm . getName ( ) + " - §7- §e " + ( System . currentTimeMillis ( ) - long_ ) + " ms " ) ;
} else send . console ( T2CodeMain . prefix + " §3Permission plugin: §4not connected via vault! " + " §7- §e " + ( System . currentTimeMillis ( ) - long_ ) + " ms " ) ;
2022-02-09 13:40:27 +00:00
12.0 Innovation and Eco API change
The API for Economy has been rebuilt.
- - Class renamed: net.t2code.lib.Spigot.Lib.vault.Vault -> net.t2code.lib.Spigot.Lib.eco.Eco
- Methods renamed:
- buy(String prefix, Player p, Double price) -> moneyRemove(String prefix, Player player, Double price)
- addMoney(String prefix, Player p, Double price) -> moneyAdd(String prefix, Player player, Double price)
- New methods:
- itemRemove(Player player, String item, int amount)
- itemAdd(Player player, String item, int amount)
- votePointsRemove(String prefix, Player player, Integer amount) (for VotingPlugin)
- votePointsAdd(String prefix, Player player, Integer amount) (for VotingPlugin)
- VotingPlugin added to PluginCheck
2022-06-07 03:58:47 +00:00
if ( PluginCheck . papi ( ) ) {
2022-06-08 03:13:00 +00:00
send . console ( T2CodeMain . prefix + " §3PlaceholderAPI: §6connected " + " §7- §e " + ( System . currentTimeMillis ( ) - long_ ) + " ms " ) ;
12.0 Innovation and Eco API change
The API for Economy has been rebuilt.
- - Class renamed: net.t2code.lib.Spigot.Lib.vault.Vault -> net.t2code.lib.Spigot.Lib.eco.Eco
- Methods renamed:
- buy(String prefix, Player p, Double price) -> moneyRemove(String prefix, Player player, Double price)
- addMoney(String prefix, Player p, Double price) -> moneyAdd(String prefix, Player player, Double price)
- New methods:
- itemRemove(Player player, String item, int amount)
- itemAdd(Player player, String item, int amount)
- votePointsRemove(String prefix, Player player, Integer amount) (for VotingPlugin)
- votePointsAdd(String prefix, Player player, Integer amount) (for VotingPlugin)
- VotingPlugin added to PluginCheck
2022-06-07 03:58:47 +00:00
}
2021-11-28 01:13:21 +00:00
2022-06-08 03:13:00 +00:00
T2CodeMain . plugin . getCommand ( " t2code " ) . setExecutor ( new CmdExecuter ( ) ) ;
2021-11-28 01:13:21 +00:00
ConfigCreate . configCreate ( ) ;
LanguagesCreate . langCreate ( ) ;
SelectLibConfig . onSelect ( ) ;
SelectLibMsg . onSelect ( prefix ) ;
2022-06-18 14:16:26 +00:00
if ( ! Util . getSnapshot ( ) | | version . toLowerCase ( ) . contains ( " dev " ) ) {
2021-12-31 16:17:27 +00:00
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
2022-07-07 11:43:50 +00:00
if ( SelectLibConfig . getInventoriesCloseByServerStop ( ) ) {
12.0 Innovation and Eco API change
The API for Economy has been rebuilt.
- - Class renamed: net.t2code.lib.Spigot.Lib.vault.Vault -> net.t2code.lib.Spigot.Lib.eco.Eco
- Methods renamed:
- buy(String prefix, Player p, Double price) -> moneyRemove(String prefix, Player player, Double price)
- addMoney(String prefix, Player p, Double price) -> moneyAdd(String prefix, Player player, Double price)
- New methods:
- itemRemove(Player player, String item, int amount)
- itemAdd(Player player, String item, int amount)
- votePointsRemove(String prefix, Player player, Integer amount) (for VotingPlugin)
- votePointsAdd(String prefix, Player player, Integer amount) (for VotingPlugin)
- VotingPlugin added to PluginCheck
2022-06-07 03:58:47 +00:00
for ( Player player : Bukkit . getOnlinePlayers ( ) ) {
2021-12-31 00:35:09 +00:00
player . closeInventory ( ) ;
}
}
2022-07-07 11:43:50 +00:00
if ( this . adventure ! = null ) {
this . adventure . close ( ) ;
this . adventure = null ;
}
2021-11-28 01:13:21 +00:00
Vault . vaultDisable ( ) ;
T2CodeTemplate . onDisable ( prefix , autor , version , spigot , discord ) ;
}
}