Search in sources :

Example 1 with UpdateChecker

use of com.archyx.aureliumskills.util.version.UpdateChecker in project AureliumSkills by Archy-X.

the class AureliumSkills method checkUpdates.

public void checkUpdates() {
    // Check for updates
    if (!OptionL.getBoolean(Option.CHECK_FOR_UPDATES))
        return;
    new UpdateChecker(this, 81069).getVersion(version -> {
        if (!this.getDescription().getVersion().contains("Pre-Release") && !this.getDescription().getVersion().contains("Build")) {
            if (!this.getDescription().getVersion().equalsIgnoreCase(version)) {
                getLogger().info("New update available! You are on version " + this.getDescription().getVersion() + ", latest version is " + version);
                getLogger().info("Download it on Spigot:");
                getLogger().info("https://spigotmc.org/resources/81069");
            }
        } else {
            getLogger().info("You are on an in development version of the plugin, plugin may be buggy or unstable!");
            getLogger().info("Report any bugs to the support discord server or submit an issue here: https://github.com/Archy-X/AureliumSkills/issues");
        }
    });
}
Also used : UpdateChecker(com.archyx.aureliumskills.util.version.UpdateChecker)

Example 2 with UpdateChecker

use of com.archyx.aureliumskills.util.version.UpdateChecker in project AureliumSkills by Archy-X.

the class SkillsCommand method onVersion.

@Subcommand("version")
@CommandPermission("aureliumskills.version")
public void onVersion(CommandSender sender) {
    Locale locale = plugin.getLang().getLocale(sender);
    new UpdateChecker(plugin, 81069).getVersion(latestVersion -> sender.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.VERSION, locale), "{current_version}", plugin.getDescription().getVersion(), "{latest_version}", latestVersion)));
}
Also used : Locale(java.util.Locale) UpdateChecker(com.archyx.aureliumskills.util.version.UpdateChecker)

Example 3 with UpdateChecker

use of com.archyx.aureliumskills.util.version.UpdateChecker in project AureliumSkills by Archy-X.

the class PlayerJoinQuit method onPlayerJoin.

@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    PlayerManager playerManager = plugin.getPlayerManager();
    if (plugin.getStorageProvider() instanceof MySqlStorageProvider) {
        // Handles MySQL storage
        if (OptionL.getBoolean(Option.MYSQL_ALWAYS_LOAD_ON_JOIN) || playerManager.getPlayerData(player) == null) {
            int loadDelay = OptionL.getInt(Option.MYSQL_LOAD_DELAY);
            if (loadDelay == 0) {
                // Load immediately
                loadPlayerDataAsync(player);
            } else {
                // Delay loading
                new BukkitRunnable() {

                    @Override
                    public void run() {
                        loadPlayerDataAsync(player);
                    }
                }.runTaskLater(plugin, loadDelay);
            }
        }
    } else {
        // Yaml storage
        if (playerManager.getPlayerData(player) == null) {
            loadPlayerDataAsync(player);
        }
    }
    // Load player skull
    Location playerLoc = player.getLocation();
    Location loc = new Location(playerLoc.getWorld(), playerLoc.getX(), 0, playerLoc.getZ());
    Block b = loc.getBlock();
    if (!(b.getState() instanceof InventoryHolder)) {
        BlockState state = b.getState();
        SkullCreator.blockWithUuid(b, player.getUniqueId());
        state.update(true);
    }
    // Update message
    if (OptionL.getBoolean(Option.CHECK_FOR_UPDATES) && player.hasPermission("aureliumskills.checkupdates")) {
        if (System.currentTimeMillis() > ReleaseData.RELEASE_TIME + 21600000L) {
            // Check for updates
            new UpdateChecker(plugin, 81069).getVersion(version -> {
                if (!plugin.getDescription().getVersion().contains("Pre-Release") && !plugin.getDescription().getVersion().contains("Build")) {
                    if (!plugin.getDescription().getVersion().equalsIgnoreCase(version)) {
                        player.sendMessage(AureliumSkills.getPrefix(Lang.getDefaultLanguage()) + ChatColor.WHITE + "New update available! You are on version " + ChatColor.AQUA + plugin.getDescription().getVersion() + ChatColor.WHITE + ", latest version is " + ChatColor.AQUA + version);
                        player.sendMessage(AureliumSkills.getPrefix(Lang.getDefaultLanguage()) + ChatColor.WHITE + "Download it on Spigot: " + ChatColor.YELLOW + "" + ChatColor.UNDERLINE + "https://spigotmc.org/resources/81069");
                    }
                }
            });
        }
    }
}
Also used : Player(org.bukkit.entity.Player) BlockState(org.bukkit.block.BlockState) PlayerManager(com.archyx.aureliumskills.data.PlayerManager) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Block(org.bukkit.block.Block) MySqlStorageProvider(com.archyx.aureliumskills.data.storage.MySqlStorageProvider) InventoryHolder(org.bukkit.inventory.InventoryHolder) Location(org.bukkit.Location) UpdateChecker(com.archyx.aureliumskills.util.version.UpdateChecker) EventHandler(org.bukkit.event.EventHandler)

Aggregations

UpdateChecker (com.archyx.aureliumskills.util.version.UpdateChecker)3 PlayerManager (com.archyx.aureliumskills.data.PlayerManager)1 MySqlStorageProvider (com.archyx.aureliumskills.data.storage.MySqlStorageProvider)1 Locale (java.util.Locale)1 Location (org.bukkit.Location)1 Block (org.bukkit.block.Block)1 BlockState (org.bukkit.block.BlockState)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1 InventoryHolder (org.bukkit.inventory.InventoryHolder)1 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)1