Search in sources :

Example 1 with UpdateChecker

use of com.toonystank.armorswap.utils.UpdateChecker in project ArmorSwap by taggernation.

the class ArmorSwap method onEnable.

@Override
public void onEnable() {
    try {
        configData = new ConfigData(this);
        configData.updateConfig(this.getDescription().getVersion(), ConfigDataType.VERSION.getName());
    } catch (IOException | InvalidConfigurationException e) {
        e.printStackTrace();
    }
    new UpdateChecker(this, 97332).getVersion(version -> {
        if (this.getDescription().getVersion().equals(version)) {
            getLogger().info("There is not a new update available.");
        } else {
            getLogger().info("There is a new update available." + "\n" + ChatColor.RED + "https://www.spigotmc.org/resources/armorswap-swap-items-by-right-clicking.97332/");
        }
    });
    // bStats metrics
    // https://bstats.org/what-is-my-plugin-id
    Metrics metrics = new Metrics(this, 14140);
    setPlugin(this);
    // Events
    getServer().getPluginManager().registerEvents(new OnJoin(), this);
    try {
        getServer().getPluginManager().registerEvents(new ClickEvent(configData, this), this);
    } catch (IOException e) {
        e.printStackTrace();
    }
    // Checks if server is running on Paper or not
    boolean isOnPaper = false;
    try {
        Class.forName("com.destroystokyo.paper");
        isOnPaper = true;
    } catch (ClassNotFoundException ignored) {
    }
    // Initializing Command manager
    if (isOnPaper) {
        PaperCommandManager pcm = new PaperCommandManager(this);
        pcm.registerCommand(new CommandManager(configData, this));
    } else {
        BukkitCommandManager bcm = new BukkitCommandManager(this);
        bcm.registerCommand(new CommandManager(configData, this));
    }
    // Config
    getLogger().info(ChatColor.AQUA + "ArmorSwap " + ChatColor.UNDERLINE + "Successfully loaded.");
}
Also used : BukkitCommandManager(co.aikar.commands.BukkitCommandManager) PaperCommandManager(co.aikar.commands.PaperCommandManager) ClickEvent(com.toonystank.armorswap.Events.ClickEvent) OnJoin(com.toonystank.armorswap.Events.OnJoin) IOException(java.io.IOException) InvalidConfigurationException(org.bukkit.configuration.InvalidConfigurationException) Metrics(com.toonystank.armorswap.utils.Metrics) CommandManager(com.toonystank.armorswap.Commands.CommandManager) PaperCommandManager(co.aikar.commands.PaperCommandManager) BukkitCommandManager(co.aikar.commands.BukkitCommandManager) ConfigData(com.toonystank.armorswap.utils.ConfigData) UpdateChecker(com.toonystank.armorswap.utils.UpdateChecker)

Aggregations

BukkitCommandManager (co.aikar.commands.BukkitCommandManager)1 PaperCommandManager (co.aikar.commands.PaperCommandManager)1 CommandManager (com.toonystank.armorswap.Commands.CommandManager)1 ClickEvent (com.toonystank.armorswap.Events.ClickEvent)1 OnJoin (com.toonystank.armorswap.Events.OnJoin)1 ConfigData (com.toonystank.armorswap.utils.ConfigData)1 Metrics (com.toonystank.armorswap.utils.Metrics)1 UpdateChecker (com.toonystank.armorswap.utils.UpdateChecker)1 IOException (java.io.IOException)1 InvalidConfigurationException (org.bukkit.configuration.InvalidConfigurationException)1