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

129 lines
5.5 KiB
Java
Raw Normal View History

2021-12-21 04:57:29 +00:00
package de.jatitv.commandguiv2.Spigot;
//s<ds
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.functions.Function;
2021-12-21 04:57:29 +00:00
import de.jatitv.commandguiv2.Spigot.system.Load;
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.guis.Gui;
2022-01-16 02:03:04 +00:00
import de.jatitv.commandguiv2.Spigot.system.database.MySQL;
2021-12-21 04:57:29 +00:00
import de.jatitv.commandguiv2.Util;
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.minecraftVersion.NMSVersion;
2021-12-21 04:57:29 +00:00
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public final class Main extends JavaPlugin {
public static ArrayList<String> bungeejoinplayers = new ArrayList<>();
public static File getPath() {
return plugin.getDataFolder();
}
private static Boolean enable = false;
public static Boolean legacy = false;
2021-12-21 04:57:29 +00:00
public static String prefix = "§8[§4C§9GUI§8]";
public static String version;
public static List<String> autor;
public static Main plugin;
public static List plugins;
public static String update_version = null;
public static Boolean PaPi = false;
public static Boolean PlotSquaredGUI = false;
2022-01-13 02:28:06 +00:00
public static Boolean LuckyBox = false;
2021-12-21 04:57:29 +00:00
public static Boolean PlugManGUI = false;
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
public static HashMap<String, Gui> guiHashMap = new HashMap<>();
2021-12-21 04:57:29 +00:00
public static ArrayList<String> allAliases = new ArrayList<>();
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
public static HashMap<String, Function> functionHashMap = new HashMap<>();
2021-12-21 04:57:29 +00:00
@Override
public void onEnable() {
plugins = Arrays.asList(getServer().getPluginManager().getPlugins());
// Plugin startup logic
// Plugin startup logic
Logger logger = this.getLogger();
plugin = this;
autor = plugin.getDescription().getAuthors();
version = plugin.getDescription().getVersion();
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12 || MCVersion.minecraft1_13 || MCVersion.minecraft1_14 || MCVersion.minecraft1_15 || NMSVersion.v1_16_R1) {
legacy = true;
}
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
2021-12-21 04:57:29 +00:00
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
if (PluginCheck.papi()) {
PaPi = true;
}
2022-01-01 02:40:54 +00:00
Load.onLoad(prefix, autor, version, Util.getSpigot(), Util.getSpigotID(), Util.getDiscord(), Util.getBstatsID());
2021-12-21 04:57:29 +00:00
enable = true;
}
public static void addonLoad() {
2022-01-13 02:28:06 +00:00
if (PluginCheck.plotSquaredGUI()) {
2021-12-21 04:57:29 +00:00
PlotSquaredGUI = true;
addonEnable(Bukkit.getPluginManager().getPlugin("PlotSquaredGUI"));
2022-04-16 12:32:22 +00:00
}if (PluginCheck.luckyBox()) {
2022-01-13 02:28:06 +00:00
LuckyBox = true;
addonEnable(Bukkit.getPluginManager().getPlugin("T2C-LuckyBox"));
2021-12-21 04:57:29 +00:00
}
2022-01-13 02:28:06 +00:00
if (PluginCheck.plugManGUI()) {
2021-12-21 04:57:29 +00:00
PlugManGUI = true;
addonEnable(Bukkit.getPluginManager().getPlugin("PlugManGUI"));
}
}
public static void addonEnable(Plugin plugin) {
send.console(prefix + " §aAddon for: §e" + plugin.getName() + "§7 - Version: " + plugin.getDescription().getVersion() + " §aloaded successfully!");
}
public static Boolean pluginNotFound(String pl, Integer spigotID) {
if (Bukkit.getPluginManager().getPlugin(pl) == null) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(prefix + " §e" + pl + " §4could not be found. Please download it here: " +
"§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin.");
Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
return true;
} else return false;
}
public static Boolean pluginNotFound(String pl, Integer spigotID, double ver) {
if (Bukkit.getPluginManager().getPlugin(pl) == null) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(prefix + " §e" + pl + " §4could not be found. Please download it here: " +
"§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin.");
Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
return true;
} else {
2021-12-22 20:20:55 +00:00
if (Double.parseDouble(Bukkit.getPluginManager().getPlugin(pl).getDescription().getVersion()) < ver) {
2021-12-21 04:57:29 +00:00
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(prefix + " §e" + pl + " §4is out of date! This plugin requires at least version §2" + ver + " §4of §6" + pl + " §4Please update it here: §6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to use this version of " + plugin.getDescription().getName() + ".");
Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
return true;
}
return false;
}
}
@Override
public void onDisable() {
// Plugin shutdown logic
2022-01-01 02:40:54 +00:00
if (enable) T2CodeTemplate.onDisable(prefix, autor, version, Util.getSpigot(), Util.getDiscord());
2022-01-16 02:03:04 +00:00
MySQL.close();
2021-12-21 04:57:29 +00:00
}
}