261 lines
10 KiB
Java
261 lines
10 KiB
Java
package net.t2code.commandguiv2.Spigot.system;
|
|
|
|
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
|
import net.t2code.commandguiv2.Spigot.config.config.ConfigSelect;
|
|
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV5;
|
|
import net.t2code.commandguiv2.Spigot.config.functions.SelectFunctions;
|
|
import net.t2code.commandguiv2.Spigot.config.gui.SelectGui;
|
|
import net.t2code.commandguiv2.Spigot.config.useItems.UseItemSelect;
|
|
import net.t2code.commandguiv2.Spigot.function.gui.GUIListener;
|
|
import net.t2code.commandguiv2.Spigot.function.listener.Bungee_Sender_Reciver;
|
|
import net.t2code.commandguiv2.Spigot.function.useItem.EventsFrom110;
|
|
import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI;
|
|
import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUIItem;
|
|
import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_Help;
|
|
import net.t2code.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
|
|
import net.t2code.commandguiv2.Spigot.config.functions.CreateFunctions;
|
|
import net.t2code.commandguiv2.Spigot.config.gui.CreateGUI;
|
|
import net.t2code.commandguiv2.Spigot.config.languages.LanguagesCreate;
|
|
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
|
import net.t2code.commandguiv2.Spigot.database.MySQL;
|
|
import net.t2code.commandguiv2.Spigot.function.listener.PluginEvent;
|
|
import net.t2code.commandguiv2.Spigot.function.useItem.Events;
|
|
import net.t2code.commandguiv2.Spigot.Main;
|
|
import net.t2code.commandguiv2.Spigot.database.SQLITE;
|
|
import net.t2code.commandguiv2.Spigot.database.SelectDatabase;
|
|
import net.t2code.commandguiv2.Spigot.enums.StorageEnum;
|
|
import net.t2code.commandguiv2.Util;
|
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
|
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
|
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
|
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
import java.io.*;
|
|
import java.sql.SQLException;
|
|
import java.util.List;
|
|
|
|
public class Load {
|
|
static Plugin plugin = Main.getPlugin();
|
|
|
|
public static void onLoad(String prefix, List<String> autor, String version, String spigot, int spigotID, String discord, int bstatsID) {
|
|
|
|
long long_ = T2Ctemplate.onLoadHeader(prefix, autor, version, spigot, discord);
|
|
try {
|
|
Debug.debugmsg();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
T2Csend.console(prefix + " §8-------------------------------");
|
|
try {
|
|
ConfigConverterV5.renameMainFolder();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
|
|
if (!new File(Main.getPath(), "config.yml").exists()) {
|
|
|
|
try {
|
|
CreateGUI.configCreate();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
CreateFunctions.create();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
UseItemSelect.create();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
ConfigSelect.selectConfig();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
plugin.saveResource("configDeclaration.yml", true);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
plugin.saveResource("GUIs/guiDeclaration.yml", true);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
plugin.saveResource("Functions/functionDeclaration.yml", true);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
plugin.saveResource("UseItems/useItemDeclaration.yml", true);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
if (T2CLibConfig.getBungee()) {
|
|
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "t2c:bcmd")) {
|
|
T2Csend.debug(plugin, "registerOutgoingPluginChannel §et2c:bcmd");
|
|
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
|
|
}
|
|
if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin, "t2c:cguiopl")) {
|
|
T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:cguiopl");
|
|
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "t2c:cguiopl", new Bungee_Sender_Reciver());
|
|
}
|
|
}
|
|
|
|
if (T2CpluginCheck.papi()) {
|
|
new Papi().register();
|
|
}
|
|
|
|
try {
|
|
LanguagesCreate.langCreate();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
SelectFunctions.onSelectFunction();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
SelectGui.onSelectGui();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
UseItemSelect.onSelect();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
SelectMessages.onSelect(prefix);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
ConfigValues.sound();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
CmdExecuter_GUI.arg1.put(String.valueOf(ConfigValues.adminSubCommand.value), Permissions.admin + ";" + Permissions.giveItemOther + ";" + Permissions.info);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
T2Csend.console(prefix + " §8-------------------------------");
|
|
loadStorage(prefix);
|
|
T2Csend.console(prefix + " §8-------------------------------");
|
|
|
|
if (Main.PaPi) {
|
|
T2Csend.console(prefix + " §2PlaceholderAPI successfully connected!");
|
|
} else {
|
|
T2Csend.console(prefix + " §4PlaceholderAPI could not be connected / found!");
|
|
}
|
|
|
|
try {
|
|
Permissions.onPermRegister();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
if ((Boolean) ConfigValues.helpAlias.value) {
|
|
Main.getPlugin().getCommand("commandguihelp").setExecutor(new CmdExecuter_Help());
|
|
T2Csend.debug(plugin, "CommandRegister: commandguihelp");
|
|
}
|
|
Main.getPlugin().getCommand("commandgui").setExecutor(new CmdExecuter_GUI());
|
|
T2Csend.debug(plugin, "CommandRegister: commandgui");
|
|
Main.getPlugin().getCommand("commandgui-item").setExecutor(new CmdExecuter_GUIItem());
|
|
T2Csend.debug(plugin, "CommandRegister: commandgui-item");
|
|
|
|
try {
|
|
AliasRegister.onRegister();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
Bukkit.getServer().getPluginManager().registerEvents(new GUIListener(), plugin);
|
|
Bukkit.getServer().getPluginManager().registerEvents(new PluginEvent(), plugin);
|
|
|
|
Bukkit.getServer().getPluginManager().registerEvents(new Events(), Main.getPlugin());
|
|
|
|
if (!T2CmcVersion.isMc1_8() && !T2CmcVersion.isMc1_9()) {
|
|
Bukkit.getServer().getPluginManager().registerEvents(new EventsFrom110(), plugin);
|
|
}
|
|
|
|
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), spigotID, discord
|
|
, (Boolean) ConfigValues.updateCheckOnJoin.value, (Boolean) ConfigValues.updateCheckSeePreReleaseUpdates.value, (Integer) ConfigValues.updateCheckTimeInterval.value);
|
|
Metrics.Bstats();
|
|
Main.addonLoad();
|
|
T2Ctemplate.onLoadFooter(prefix, long_);
|
|
}
|
|
|
|
private static void loadStorage(String prefix) {
|
|
try {
|
|
SelectDatabase.setStorage(StorageEnum.valueOf(String.valueOf(ConfigValues.storage.value)));
|
|
} catch (Exception ignored) {
|
|
T2Csend.error(plugin, "The storage medium '" + ConfigValues.storage.value + "' is not supported!");
|
|
T2Csend.error(plugin, "Storage medium " + StorageEnum.SQLITE + " is used.");
|
|
SelectDatabase.setStorage(StorageEnum.SQLITE);
|
|
}
|
|
|
|
switch (SelectDatabase.getStorage()) {
|
|
case MYSQL:
|
|
T2Csend.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
|
|
MySQL.main();
|
|
try {
|
|
MySQL.query("CREATE TABLE IF NOT EXISTS `gui-item` (" +
|
|
" `UUID` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_general_ci'," +
|
|
" `Name` TINYTEXT NOT NULL COLLATE 'utf8mb4_general_ci'," +
|
|
" `Status` INT(1) NOT NULL DEFAULT '1'," +
|
|
" `Slot` INT(1) NULL DEFAULT NULL," +
|
|
" UNIQUE INDEX `UUID` (`UUID`)" +
|
|
")" +
|
|
"COLLATE='utf8mb4_general_ci'" +
|
|
"ENGINE=InnoDB" +
|
|
";");
|
|
} catch (Exception e) {
|
|
Main.sendTryCatch(Load.class, e.getStackTrace()[0]);
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
MySQL.query("ALTER TABLE `gui-item` ADD COLUMN `Slot` INT(1) NULL DEFAULT NULL AFTER `Status`;");
|
|
} catch (SQLException e) {
|
|
}
|
|
break;
|
|
case YML:
|
|
T2Csend.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
|
|
break;
|
|
default:
|
|
case SQLITE:
|
|
T2Csend.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
|
|
try {
|
|
SQLITE.main();
|
|
SQLITE.query("CREATE TABLE IF NOT EXISTS `gui-item` (" +
|
|
"UUID TEXT NOT NULL," +
|
|
"Name TEXT NOT NULL," +
|
|
"Status INTEGER NOT NULL DEFAULT 1," +
|
|
"Slot INTEGER," +
|
|
"PRIMARY KEY(UUID)" +
|
|
");");
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|