T2C-CommandGUI/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/system/Load.java

211 lines
8.4 KiB
Java
Raw Normal View History

2021-12-21 04:57:29 +00:00
package de.jatitv.commandguiv2.Spigot.system;
import de.jatitv.commandguiv2.Spigot.Listener.GUIListener;
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.EventsFrom110;
2022-04-16 12:32:22 +00:00
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUITab;
2021-12-21 04:57:29 +00:00
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUIItem;
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_Help;
import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
2.7.0 Snapshot 1 In this update some functions were rewritten, changed and added. Also some minor bugs have been fixed. The GUIs files have been split into GUI files and function files, this provides more clarity in the complete plugin structure and offers the possibility to access a function from multiple GUIs. Thus, for example, you can create a back button as a function and open it from 3 GUIs, the item, the function can also be in different places, because the slot is set in the GUI file. In the GUI files is thus specified on which slot which function should be located. In addition, the permission for See and for Use of the functions can now be set individually in the GUI Config. In the functions also 2 new functions were added, with which players can switch permissions on and off and an option to switch the UseItem on and off. Placeholders have been added. This update includes a converter that builds the new structure from the old config structure. Your options should be taken over. For security reasons your old GUI files are saved under the path 'plugins/CommandGUI/OldConfig/GUIs/Version4'. Bug fixes: - Fixed a bug that prevented GUIs from opening. - The OpenGUI option, the command '/cgui <guiname>' did not work. The GUI that was set as default GUI in UseItem was always opened. This was fixed New features: - Placeholders - %commandgui_useitem% - Shows if you have activated or deactivated the UseItem (in color, customizable in config.yml) - %commandgui_useitem_boolean% - Shows if you have enabled or disabled the UseItem - %commandgui_useitem_slot% - shows on which slot you have set the UseItem - ToggleUseItem as new option for slots - TogglePermission as new option for slots Changes: - The config structure has been revised.
2022-04-19 05:08:33 +00:00
import de.jatitv.commandguiv2.Spigot.config.functions.CreateFunctions;
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
2022-01-06 01:21:27 +00:00
import de.jatitv.commandguiv2.Spigot.config.languages.LanguagesCreate;
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
2021-12-21 04:57:29 +00:00
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;
2.7.0 Snapshot 1 In this update some functions were rewritten, changed and added. Also some minor bugs have been fixed. The GUIs files have been split into GUI files and function files, this provides more clarity in the complete plugin structure and offers the possibility to access a function from multiple GUIs. Thus, for example, you can create a back button as a function and open it from 3 GUIs, the item, the function can also be in different places, because the slot is set in the GUI file. In the GUI files is thus specified on which slot which function should be located. In addition, the permission for See and for Use of the functions can now be set individually in the GUI Config. In the functions also 2 new functions were added, with which players can switch permissions on and off and an option to switch the UseItem on and off. Placeholders have been added. This update includes a converter that builds the new structure from the old config structure. Your options should be taken over. For security reasons your old GUI files are saved under the path 'plugins/CommandGUI/OldConfig/GUIs/Version4'. Bug fixes: - Fixed a bug that prevented GUIs from opening. - The OpenGUI option, the command '/cgui <guiname>' did not work. The GUI that was set as default GUI in UseItem was always opened. This was fixed New features: - Placeholders - %commandgui_useitem% - Shows if you have activated or deactivated the UseItem (in color, customizable in config.yml) - %commandgui_useitem_boolean% - Shows if you have enabled or disabled the UseItem - %commandgui_useitem_slot% - shows on which slot you have set the UseItem - ToggleUseItem as new option for slots - TogglePermission as new option for slots Changes: - The config structure has been revised.
2022-04-19 05:08:33 +00:00
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
2022-01-06 01:21:27 +00:00
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;
2021-12-21 04:57:29 +00:00
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
2022-04-16 12:32:22 +00:00
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
2021-12-21 04:57:29 +00:00
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import java.io.*;
import java.sql.SQLException;
2021-12-21 04:57:29 +00:00
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 {
2.7.0 Snapshot 1 In this update some functions were rewritten, changed and added. Also some minor bugs have been fixed. The GUIs files have been split into GUI files and function files, this provides more clarity in the complete plugin structure and offers the possibility to access a function from multiple GUIs. Thus, for example, you can create a back button as a function and open it from 3 GUIs, the item, the function can also be in different places, because the slot is set in the GUI file. In the GUI files is thus specified on which slot which function should be located. In addition, the permission for See and for Use of the functions can now be set individually in the GUI Config. In the functions also 2 new functions were added, with which players can switch permissions on and off and an option to switch the UseItem on and off. Placeholders have been added. This update includes a converter that builds the new structure from the old config structure. Your options should be taken over. For security reasons your old GUI files are saved under the path 'plugins/CommandGUI/OldConfig/GUIs/Version4'. Bug fixes: - Fixed a bug that prevented GUIs from opening. - The OpenGUI option, the command '/cgui <guiname>' did not work. The GUI that was set as default GUI in UseItem was always opened. This was fixed New features: - Placeholders - %commandgui_useitem% - Shows if you have activated or deactivated the UseItem (in color, customizable in config.yml) - %commandgui_useitem_boolean% - Shows if you have enabled or disabled the UseItem - %commandgui_useitem_slot% - shows on which slot you have set the UseItem - ToggleUseItem as new option for slots - TogglePermission as new option for slots Changes: - The config structure has been revised.
2022-04-19 05:08:33 +00:00
CreateGUI.configCreate();
} catch (Exception e) {
e.printStackTrace();
}
try {
CreateFunctions.create();
2021-12-21 04:57:29 +00:00
} catch (Exception e) {
e.printStackTrace();
}
}
try {
ConfigCreate.configCreate();
} catch (Exception e) {
e.printStackTrace();
}
try {
SelectConfig.onSelect();
} catch (Exception e) {
e.printStackTrace();
}
if (SelectConfig.Bungee) {
2.7.0 Snapshot 1 In this update some functions were rewritten, changed and added. Also some minor bugs have been fixed. The GUIs files have been split into GUI files and function files, this provides more clarity in the complete plugin structure and offers the possibility to access a function from multiple GUIs. Thus, for example, you can create a back button as a function and open it from 3 GUIs, the item, the function can also be in different places, because the slot is set in the GUI file. In the GUI files is thus specified on which slot which function should be located. In addition, the permission for See and for Use of the functions can now be set individually in the GUI Config. In the functions also 2 new functions were added, with which players can switch permissions on and off and an option to switch the UseItem on and off. Placeholders have been added. This update includes a converter that builds the new structure from the old config structure. Your options should be taken over. For security reasons your old GUI files are saved under the path 'plugins/CommandGUI/OldConfig/GUIs/Version4'. Bug fixes: - Fixed a bug that prevented GUIs from opening. - The OpenGUI option, the command '/cgui <guiname>' did not work. The GUI that was set as default GUI in UseItem was always opened. This was fixed New features: - Placeholders - %commandgui_useitem% - Shows if you have activated or deactivated the UseItem (in color, customizable in config.yml) - %commandgui_useitem_boolean% - Shows if you have enabled or disabled the UseItem - %commandgui_useitem_slot% - shows on which slot you have set the UseItem - ToggleUseItem as new option for slots - TogglePermission as new option for slots Changes: - The config structure has been revised.
2022-04-19 05:08:33 +00:00
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "cgui:bungee")) {
2022-01-08 06:47:49 +00:00
send.debug(plugin, "registerOutgoingPluginChannel §ecgui:bungee");
2.7.0 Snapshot 1 In this update some functions were rewritten, changed and added. Also some minor bugs have been fixed. The GUIs files have been split into GUI files and function files, this provides more clarity in the complete plugin structure and offers the possibility to access a function from multiple GUIs. Thus, for example, you can create a back button as a function and open it from 3 GUIs, the item, the function can also be in different places, because the slot is set in the GUI file. In the GUI files is thus specified on which slot which function should be located. In addition, the permission for See and for Use of the functions can now be set individually in the GUI Config. In the functions also 2 new functions were added, with which players can switch permissions on and off and an option to switch the UseItem on and off. Placeholders have been added. This update includes a converter that builds the new structure from the old config structure. Your options should be taken over. For security reasons your old GUI files are saved under the path 'plugins/CommandGUI/OldConfig/GUIs/Version4'. Bug fixes: - Fixed a bug that prevented GUIs from opening. - The OpenGUI option, the command '/cgui <guiname>' did not work. The GUI that was set as default GUI in UseItem was always opened. This was fixed New features: - Placeholders - %commandgui_useitem% - Shows if you have activated or deactivated the UseItem (in color, customizable in config.yml) - %commandgui_useitem_boolean% - Shows if you have enabled or disabled the UseItem - %commandgui_useitem_slot% - shows on which slot you have set the UseItem - ToggleUseItem as new option for slots - TogglePermission as new option for slots Changes: - The config structure has been revised.
2022-04-19 05:08:33 +00:00
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "cgui:bungee");
2021-12-21 04:57:29 +00:00
}
2.7.0 Snapshot 1 In this update some functions were rewritten, changed and added. Also some minor bugs have been fixed. The GUIs files have been split into GUI files and function files, this provides more clarity in the complete plugin structure and offers the possibility to access a function from multiple GUIs. Thus, for example, you can create a back button as a function and open it from 3 GUIs, the item, the function can also be in different places, because the slot is set in the GUI file. In the GUI files is thus specified on which slot which function should be located. In addition, the permission for See and for Use of the functions can now be set individually in the GUI Config. In the functions also 2 new functions were added, with which players can switch permissions on and off and an option to switch the UseItem on and off. Placeholders have been added. This update includes a converter that builds the new structure from the old config structure. Your options should be taken over. For security reasons your old GUI files are saved under the path 'plugins/CommandGUI/OldConfig/GUIs/Version4'. Bug fixes: - Fixed a bug that prevented GUIs from opening. - The OpenGUI option, the command '/cgui <guiname>' did not work. The GUI that was set as default GUI in UseItem was always opened. This was fixed New features: - Placeholders - %commandgui_useitem% - Shows if you have activated or deactivated the UseItem (in color, customizable in config.yml) - %commandgui_useitem_boolean% - Shows if you have enabled or disabled the UseItem - %commandgui_useitem_slot% - shows on which slot you have set the UseItem - ToggleUseItem as new option for slots - TogglePermission as new option for slots Changes: - The config structure has been revised.
2022-04-19 05:08:33 +00:00
if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin, "cgui:onlinepl")) {
2022-01-08 06:47:49 +00:00
send.debug(plugin, "registerIncomingPluginChannel §ecgui:onlinepl");
2.7.0 Snapshot 1 In this update some functions were rewritten, changed and added. Also some minor bugs have been fixed. The GUIs files have been split into GUI files and function files, this provides more clarity in the complete plugin structure and offers the possibility to access a function from multiple GUIs. Thus, for example, you can create a back button as a function and open it from 3 GUIs, the item, the function can also be in different places, because the slot is set in the GUI file. In the GUI files is thus specified on which slot which function should be located. In addition, the permission for See and for Use of the functions can now be set individually in the GUI Config. In the functions also 2 new functions were added, with which players can switch permissions on and off and an option to switch the UseItem on and off. Placeholders have been added. This update includes a converter that builds the new structure from the old config structure. Your options should be taken over. For security reasons your old GUI files are saved under the path 'plugins/CommandGUI/OldConfig/GUIs/Version4'. Bug fixes: - Fixed a bug that prevented GUIs from opening. - The OpenGUI option, the command '/cgui <guiname>' did not work. The GUI that was set as default GUI in UseItem was always opened. This was fixed New features: - Placeholders - %commandgui_useitem% - Shows if you have activated or deactivated the UseItem (in color, customizable in config.yml) - %commandgui_useitem_boolean% - Shows if you have enabled or disabled the UseItem - %commandgui_useitem_slot% - shows on which slot you have set the UseItem - ToggleUseItem as new option for slots - TogglePermission as new option for slots Changes: - The config structure has been revised.
2022-04-19 05:08:33 +00:00
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "cgui:onlinepl", new Bungee_Sender_Reciver());
2022-01-08 06:47:49 +00:00
}
2021-12-21 04:57:29 +00:00
}
2.7.0 Snapshot 1 In this update some functions were rewritten, changed and added. Also some minor bugs have been fixed. The GUIs files have been split into GUI files and function files, this provides more clarity in the complete plugin structure and offers the possibility to access a function from multiple GUIs. Thus, for example, you can create a back button as a function and open it from 3 GUIs, the item, the function can also be in different places, because the slot is set in the GUI file. In the GUI files is thus specified on which slot which function should be located. In addition, the permission for See and for Use of the functions can now be set individually in the GUI Config. In the functions also 2 new functions were added, with which players can switch permissions on and off and an option to switch the UseItem on and off. Placeholders have been added. This update includes a converter that builds the new structure from the old config structure. Your options should be taken over. For security reasons your old GUI files are saved under the path 'plugins/CommandGUI/OldConfig/GUIs/Version4'. Bug fixes: - Fixed a bug that prevented GUIs from opening. - The OpenGUI option, the command '/cgui <guiname>' did not work. The GUI that was set as default GUI in UseItem was always opened. This was fixed New features: - Placeholders - %commandgui_useitem% - Shows if you have activated or deactivated the UseItem (in color, customizable in config.yml) - %commandgui_useitem_boolean% - Shows if you have enabled or disabled the UseItem - %commandgui_useitem_slot% - shows on which slot you have set the UseItem - ToggleUseItem as new option for slots - TogglePermission as new option for slots Changes: - The config structure has been revised.
2022-04-19 05:08:33 +00:00
if (PluginCheck.papi()) {
2022-04-16 12:32:22 +00:00
new Placeholder().register();
}
2021-12-21 04:57:29 +00:00
try {
LanguagesCreate.langCreate();
} catch (Exception e) {
e.printStackTrace();
}
try {
Obj_Select.onSelect();
} catch (Exception e) {
e.printStackTrace();
}
try {
2022-04-16 12:32:22 +00:00
CmdExecuter_GUITab.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
2021-12-21 04:57:29 +00:00
} 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-------------------------------");
2021-12-21 04:57:29 +00:00
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());
2022-04-16 12:32:22 +00:00
send.debug(plugin, "CommandRegister: commandguihelp");
2021-12-21 04:57:29 +00:00
}
2022-04-16 12:32:22 +00:00
Main.plugin.getCommand("commandgui").setExecutor(new CmdExecuter_GUITab());
send.debug(plugin, "CommandRegister: commandgui");
2021-12-21 04:57:29 +00:00
Main.plugin.getCommand("commandgui-item").setExecutor(new CmdExecuter_GUIItem());
2022-04-16 12:32:22 +00:00
send.debug(plugin, "CommandRegister: commandgui-item");
2021-12-21 04:57:29 +00:00
try {
AliasRegister.onRegister();
} catch (Exception e) {
e.printStackTrace();
}
Bukkit.getServer().getPluginManager().registerEvents(new GUIListener(), plugin);
2021-12-21 04:57:29 +00:00
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);
2021-12-21 04:57:29 +00:00
}
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;
}
}
2021-12-21 04:57:29 +00:00
}