211 lines
8.4 KiB
Java
211 lines
8.4 KiB
Java
package de.jatitv.commandguiv2.Spigot.system;
|
|
|
|
import de.jatitv.commandguiv2.Spigot.Listener.GUIListener;
|
|
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.EventsFrom110;
|
|
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab;
|
|
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUIItem;
|
|
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_Help;
|
|
import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
|
|
import de.jatitv.commandguiv2.Spigot.config.functions.CreateFunctions;
|
|
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
|
|
import de.jatitv.commandguiv2.Spigot.config.languages.LanguagesCreate;
|
|
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
|
import de.jatitv.commandguiv2.Spigot.system.database.MySQL;
|
|
import de.jatitv.commandguiv2.Spigot.Listener.PluginEvent;
|
|
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
|
|
import de.jatitv.commandguiv2.Spigot.Main;
|
|
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
|
|
import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate;
|
|
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
|
import de.jatitv.commandguiv2.Spigot.system.database.SQLITE;
|
|
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
|
|
import de.jatitv.commandguiv2.Spigot.system.database.StorageType;
|
|
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
|
|
import net.t2code.lib.Spigot.Lib.messages.send;
|
|
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
|
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
|
|
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
|
|
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.plugin;
|
|
|
|
public static void onLoad(String prefix, List autor, String version, String spigot, int spigotID, String discord, int bstatsID) {
|
|
|
|
Long long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord);
|
|
try {
|
|
Debug.debugmsg();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
send.console(prefix + " §8-------------------------------");
|
|
|
|
|
|
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 {
|
|
ConfigCreate.configCreate();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
SelectConfig.onSelect();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
if (SelectConfig.Bungee) {
|
|
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "cgui:bungee")) {
|
|
send.debug(plugin, "registerOutgoingPluginChannel §ecgui:bungee");
|
|
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "cgui:bungee");
|
|
}
|
|
if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin, "cgui:onlinepl")) {
|
|
send.debug(plugin, "registerIncomingPluginChannel §ecgui:onlinepl");
|
|
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "cgui:onlinepl", new Bungee_Sender_Reciver());
|
|
}
|
|
}
|
|
|
|
if (PluginCheck.papi()) {
|
|
new Placeholder().register();
|
|
}
|
|
|
|
try {
|
|
LanguagesCreate.langCreate();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
Obj_Select.onSelect();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
SelectMessages.onSelect(prefix);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
SelectConfig.sound(prefix);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
send.console(prefix + " §8-------------------------------");
|
|
loadStorage(prefix);
|
|
send.console(prefix + " §8-------------------------------");
|
|
|
|
if (Main.PaPi) {
|
|
send.console(prefix + " §2PlaceholderAPI successfully connected!");
|
|
} else {
|
|
send.console(prefix + " §4PlaceholderAPI could not be connected / found!");
|
|
}
|
|
|
|
try {
|
|
RegisterPermissions.onPermRegister();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
if (SelectConfig.HelpAlias) {
|
|
Main.plugin.getCommand("commandguihelp").setExecutor(new CmdExecuter_Help());
|
|
send.debug(plugin, "CommandRegister: commandguihelp");
|
|
}
|
|
Main.plugin.getCommand("commandgui").setExecutor(new CmdExecuter_GUITab());
|
|
send.debug(plugin, "CommandRegister: commandgui");
|
|
Main.plugin.getCommand("commandgui-item").setExecutor(new CmdExecuter_GUIItem());
|
|
send.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.plugin);
|
|
|
|
if (!MCVersion.minecraft1_8 && !MCVersion.minecraft1_9) {
|
|
Bukkit.getServer().getPluginManager().registerEvents(new EventsFrom110(), plugin);
|
|
}
|
|
|
|
UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord);
|
|
Metrics.Bstats();
|
|
Main.addonLoad();
|
|
T2CodeTemplate.onLoadFooter(prefix, long_);
|
|
}
|
|
|
|
private static void loadStorage(String prefix) {
|
|
try {
|
|
SelectDatabase.setStorage(StorageType.valueOf(SelectConfig.storage));
|
|
} catch (Exception ignored) {
|
|
send.error(Main.plugin, "The storage medium " + SelectConfig.storage + " is not supported!");
|
|
send.error(Main.plugin, "Storage medium " + StorageType.SQLITE + " is used.");
|
|
SelectDatabase.setStorage(StorageType.SQLITE);
|
|
}
|
|
|
|
switch (SelectDatabase.getStorage()) {
|
|
case MYSQL:
|
|
send.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" +
|
|
";");
|
|
MySQL.query("ALTER TABLE `gui-item` ADD COLUMN IF NOT EXISTS `Slot` INT(1) NULL DEFAULT NULL AFTER `Status`;");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
break;
|
|
case YML:
|
|
send.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
|
|
break;
|
|
default:
|
|
case SQLITE:
|
|
send.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;
|
|
}
|
|
}
|
|
}
|