Untitled
unknown
plain_text
2 months ago
6.1 kB
14
Indexable
package com.github.goldmember33.paper; import com.github.goldmember33.paper.command.BGPCommand; import com.github.goldmember33.paper.config.MenuConfigManager; import com.github.goldmember33.paper.data.ConfigData; import com.github.goldmember33.paper.utility.ConfigDocumentUtils; import com.github.goldmember33.paper.utility.DebugUtils; import com.github.goldmember33.paper.utility.MessageUtils; import dev.dejvokep.boostedyaml.YamlDocument; import dev.dejvokep.boostedyaml.dvs.versioning.BasicVersioning; import dev.dejvokep.boostedyaml.settings.dumper.DumperSettings; import dev.dejvokep.boostedyaml.settings.general.GeneralSettings; import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings; import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings; import dev.jorel.commandapi.CommandAPI; import dev.jorel.commandapi.CommandAPIBukkitConfig; import lombok.Getter; import nl.odalitadevelopments.menus.OdalitaMenus; import org.bukkit.plugin.java.JavaPlugin; import java.io.File; import java.io.IOException; @Getter public class BlockGravityPlusPlugin extends JavaPlugin { @Getter private static BlockGravityPlusPlugin instance; private String pluginPrefix = "<color:#3da1ff>[<color:#24ff4c>BlockGravity</color></color><color:#9429ff>Plus<color:#3da1ff>]</color></color>"; private CommandAPIBukkitConfig commandAPIBukkitConfig; private OdalitaMenus odalitaMenus; // Configuration documents and files @Getter private static YamlDocument configurationDocument; @Getter private static YamlDocument messagesDocument; @Override public void onLoad() { // Plugin loading logic instance = this; this.commandAPIBukkitConfig = new CommandAPIBukkitConfig(instance) .verboseOutput(true) .silentLogs(false) .setNamespace("blockgravityplus"); // Loading some commands configuration steps CommandAPI.onLoad(this.commandAPIBukkitConfig); // Loading configurations step MessageUtils.sendConsoleMessage(pluginPrefix + " <red> ◆</red><green> [INFO] Loading configurations... </green>"); this.loadConfigurations(); // Loading the plugin prefix from the main configuration file this.pluginPrefix = ConfigData.PREFIX(); } @Override public void onEnable() { // Plugin startup logic // CommandAPI initialization CommandAPI.onEnable(); // Loading commands MessageUtils.sendConsoleMessage(pluginPrefix + " <red> ◆</red><yellow> [INFO] Loading commands... </yellow>"); this.loadCommands(); // OdalitaMenus initialization this.odalitaMenus = OdalitaMenus.createInstance(this); MessageUtils.sendConsoleMessage(pluginPrefix + " <red> ◆</red><gold> [INFO] Plugin loaded successfully! Enjoy! (: </gold>"); } @Override public void onDisable() { // Plugin shutdown logic MessageUtils.sendConsoleMessage(pluginPrefix + " <red> ◆</red><dark_red> [INFO] Preparing to disable this plugin (: </dark_red>"); CommandAPI.onDisable(); instance = null; } public void loadCommands() { // Plugin commands loading logic // // Registering base commands new BGPCommand(this).registerCommand(); } public void loadConfigurations() { // Plugin configurations loading logic MessageUtils.sendConsoleMessage(pluginPrefix + " <red> ◆</red><yellow> [INFO] Loading config.yml configuration... </yellow>"); try { configurationDocument = YamlDocument.create( new File(getDataFolder() + File.separator + "config.yml"), getResource("config.yml"), GeneralSettings.builder().setKeyFormat(GeneralSettings.KeyFormat.STRING).build(), LoaderSettings.DEFAULT, DumperSettings.DEFAULT, UpdaterSettings.builder().setVersioning(new BasicVersioning("ConfigVersion")).build() ); } catch (IOException e) { DebugUtils.error("An error occurred while trying to load YAML configuration file named 'config.yml'.", e); } MessageUtils.sendConsoleMessage(pluginPrefix + " <red> ◆</red><yellow> [INFO] Loading messages.yml configuration... </yellow>"); // Messages and translations setup MessageUtils.sendConsoleMessage(pluginPrefix + " <red> ◆</red><yellow> [INFO] Loading messages.yml configuration... </yellow>"); try { messagesDocument = YamlDocument.create( new File(getDataFolder() + File.separator + "messages.yml"), getResource("messages.yml"), GeneralSettings.builder().setKeyFormat(GeneralSettings.KeyFormat.STRING).build(), LoaderSettings.DEFAULT, DumperSettings.DEFAULT, UpdaterSettings.builder().setVersioning(new BasicVersioning("ConfigVersion")).build() ); } catch (IOException e) { DebugUtils.error("An error occurred while trying to load YAML messages configuration file named 'messages.yml'.", e); } // Menus configuration setup MessageUtils.sendConsoleMessage(pluginPrefix + " <red> ◆</red><yellow> [INFO] Loading menus configurations... </yellow>"); new MenuConfigManager(this); } public void reloadAllConfigurations() { // Plugin configurations reloading logic ConfigDocumentUtils.reloadDocument(configurationDocument); // Messages reloading ConfigDocumentUtils.reloadDocument(messagesDocument); // Menus reloading ConfigDocumentUtils.reloadDocument(MenuConfigManager.getMainMenuGUIConfig()); ConfigDocumentUtils.reloadDocument(MenuConfigManager.getWorldSelectorGUIConfig()); } }
Editor is loading...
Leave a Comment