Search in sources :

Example 1 with InfoMessage

use of com.magmaguy.elitemobs.utils.InfoMessage in project EliteMobs by MagmaGuy.

the class PlayerData method readExistingData.

private void readExistingData(Statement statement, UUID uuid, ResultSet resultSet) throws Exception {
    playerDataHashMap.put(uuid, this);
    currency = resultSet.getDouble("Currency");
    guildPrestigeLevel = resultSet.getInt("GuildPrestigeLevel");
    maxGuildLevel = resultSet.getInt("GuildMaxLevel");
    activeGuildLevel = resultSet.getInt("GuildActiveLevel");
    score = resultSet.getInt("Score");
    kills = resultSet.getInt("Kills");
    highestLevelKilled = resultSet.getInt("HighestLevelKilled");
    deaths = resultSet.getInt("Deaths");
    questsCompleted = resultSet.getInt("QuestsCompleted");
    backTeleportLocation = ConfigurationLocation.serialize(resultSet.getString("BackTeleportLocation"));
    if (resultSet.getBytes("QuestStatus") != null) {
        try {
            quests = (List<Quest>) ObjectSerializer.fromString(new String(resultSet.getBytes("QuestStatus"), "UTF-8"));
            // Serializes ItemStack which require specific handling, necessary recovering the rewards
            for (Quest quest : quests) if (quest instanceof CustomQuest)
                ((CustomQuest) quest).applyTemporaryPermissions(Bukkit.getPlayer(uuid));
        } catch (Exception ex) {
            new WarningMessage("Failed to serialize quest data for player " + Bukkit.getPlayer(uuid) + " ! This player's quest data will be wiped to prevent future errors.");
            try {
                resetQuests(uuid);
            } catch (Exception ex2) {
                new WarningMessage("Failed to reset quest data! Ironic.");
                ex2.printStackTrace();
            }
        }
    }
    if (resultSet.getBytes("PlayerQuestCooldowns") != null) {
        try {
            playerQuestCooldowns = (PlayerQuestCooldowns) ObjectSerializer.fromString(new String(resultSet.getBytes("PlayerQuestCooldowns"), "UTF-8"));
            playerQuestCooldowns.startCooldowns(uuid);
        } catch (Exception exception) {
            new WarningMessage("Failed to get player quest cooldowns!  ! This player's quest cooldowns will be wiped to prevent future errors.");
            try {
                resetPlayerQuestCooldowns(uuid);
            } catch (Exception ex2) {
                new WarningMessage("Failed to reset quest cooldowns! Ironic.");
                ex2.printStackTrace();
            }
        }
    }
    new InfoMessage("User " + uuid + " data successfully read!");
}
Also used : CustomQuest(com.magmaguy.elitemobs.quests.CustomQuest) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) InfoMessage(com.magmaguy.elitemobs.utils.InfoMessage) CustomQuest(com.magmaguy.elitemobs.quests.CustomQuest) Quest(com.magmaguy.elitemobs.quests.Quest)

Example 2 with InfoMessage

use of com.magmaguy.elitemobs.utils.InfoMessage in project EliteMobs by MagmaGuy.

the class ConfigurationExporter method copyDirectory.

private static void copyDirectory(File directoryToClone, Path targetPath) {
    for (File file : directoryToClone.listFiles()) try {
        new InfoMessage("Adding " + file.getCanonicalPath());
        copyFile(file, targetPath);
    } catch (Exception exception) {
        new WarningMessage("Failed to move directories for " + file.getName() + "! Tell the dev!");
        exception.printStackTrace();
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) InfoMessage(com.magmaguy.elitemobs.utils.InfoMessage) File(java.io.File) ZipFile(com.magmaguy.elitemobs.utils.ZipFile) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 3 with InfoMessage

use of com.magmaguy.elitemobs.utils.InfoMessage in project EliteMobs by MagmaGuy.

the class CustomTreasureChestConfigFields method processConfigFields.

@Override
public void processConfigFields() {
    this.isEnabled = processBoolean("isEnabled", isEnabled, false, false);
    this.chestMaterial = processEnum("chestType", chestMaterial, Material.CHEST, Material.class, true);
    this.facing = processEnum("facing", facing, BlockFace.NORTH, BlockFace.class, true);
    this.chestTier = processInt("chestTier", chestTier, 0, true);
    this.worldName = processString("location", worldName, null, false);
    if (worldName != null)
        worldName = worldName.split(",")[0];
    this.dropStyle = processEnum("dropStyle", dropStyle, TreasureChest.DropStyle.SINGLE, TreasureChest.DropStyle.class, true);
    this.restockTimer = processInt("restockTimer", restockTimer, 0, true);
    this.lootList = processStringList("lootList", lootList, new ArrayList<>(), true);
    this.customLootTable = new CustomLootTable(this);
    this.mimicChance = processDouble("mimicChance", mimicChance, 0, true);
    this.mimicCustomBossesList = processStringList("mimicCustomBossesList", mimicCustomBossesList, new ArrayList<>(), true);
    this.restockTime = processLong("restockTime", restockTimer, 0, false);
    this.restockTimers = processStringList("restockTimers", restockTimers, new ArrayList<>(), false);
    this.effects = processStringList("effects", effects, new ArrayList<>(), false);
    this.locations = processStringList("locations", locations, new ArrayList<>(), false);
    this.location = processLocation("location", location, null, false);
    if (location == null && locations.isEmpty())
        new InfoMessage("Custom Treasure Chest in file " + filename + " does not have a defined location(s)! It will not spawn.");
    else
        new TreasureChest(this, location, restockTime);
    for (String string : locations) {
        String[] strings = string.split(":");
        Location location = ConfigurationLocation.serialize(strings[0]);
        if (location == null) {
            new WarningMessage("Bad location entry in locations for " + filename + " . Entry: " + strings[0]);
            continue;
        }
        long timestamp = 0;
        if (strings.length > 1) {
            try {
                timestamp = Long.parseLong(strings[1]);
            } catch (Exception exception) {
                new WarningMessage("Bad unix timestamp in locations for " + filename + " . Entry: " + strings[0]);
            }
        }
        new TreasureChest(this, location, timestamp);
    }
}
Also used : TreasureChest(com.magmaguy.elitemobs.treasurechest.TreasureChest) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) BlockFace(org.bukkit.block.BlockFace) ArrayList(java.util.ArrayList) Material(org.bukkit.Material) CustomLootTable(com.magmaguy.elitemobs.items.customloottable.CustomLootTable) InfoMessage(com.magmaguy.elitemobs.utils.InfoMessage) ConfigurationLocation(com.magmaguy.elitemobs.utils.ConfigurationLocation) Location(org.bukkit.Location)

Example 4 with InfoMessage

use of com.magmaguy.elitemobs.utils.InfoMessage in project EliteMobs by MagmaGuy.

the class EliteMobs method onEnable.

@Override
public void onEnable() {
    Bukkit.getLogger().info(" _____ _     _____ _____ ________  ______________  _____");
    Bukkit.getLogger().info("|  ___| |   |_   _|_   _|  ___|  \\/  |  _  | ___ \\/  ___|");
    Bukkit.getLogger().info("| |__ | |     | |   | | | |__ | .  . | | | | |_/ /\\ `--.");
    Bukkit.getLogger().info("|  __|| |     | |   | | |  __|| |\\/| | | | | ___ \\ `--. \\");
    Bukkit.getLogger().info("| |___| |_____| |_  | | | |___| |  | \\ \\_/ / |_/ //\\__/ /");
    Bukkit.getLogger().info("\\____/\\_____/\\___/  \\_/ \\____/\\_|  |_/\\___/\\____/ \\____/");
    MetadataHandler.PLUGIN = this;
    Bukkit.getLogger().info("By MagmaGuy - v. " + MetadataHandler.PLUGIN.getDescription().getVersion());
    ServerTime.startTickCounter();
    if (Bukkit.getServer().spigot().getConfig().getDouble("settings.attribute.maxHealth.max") < 100000000) {
        Bukkit.getServer().spigot().getConfig().set("settings.attribute.maxHealth.max", 100000000);
        try {
            File spigotConfigContainer = new File(Paths.get(MetadataHandler.PLUGIN.getDataFolder().getParentFile().getCanonicalFile().getParentFile().toString() + "/spigot.yml").toString());
            Bukkit.getServer().spigot().getConfig().save(spigotConfigContainer);
            new InfoMessage("New default max health set correctly!");
        } catch (IOException e) {
            new WarningMessage("Failed to save max health value! For the plugin to work correctly, you should increase your max health on the spigot.yml config file to " + 100000000);
        }
    }
    // Remove entities that should not exist
    CrashFix.startupCheck();
    /*
        New config loading
         */
    initializeConfigs();
    if (Bukkit.getPluginManager().isPluginEnabled("LibsDisguises"))
        DisguiseEntity.initialize();
    if (worldGuardIsEnabled)
        Bukkit.getLogger().info("[EliteMobs] WorldGuard compatibility is enabled!");
    else
        Bukkit.getLogger().warning("[EliteMobs] WorldGuard compatibility is not enabled!");
    // Enable Vault
    try {
        VaultCompatibility.vaultSetup();
    } catch (Exception e) {
        Bukkit.getLogger().warning("[EliteMobs] Something went wrong with the vault configuration - your Vault " + "version is probably not compatible with this EliteMobs version. Please contact the dev about this error.");
        VaultCompatibility.VAULT_ENABLED = false;
    }
    // Hook up all listeners, some depend on config
    EventsRegistrer.registerEvents();
    // Launch the local data cache
    PlayerData.initializeDatabaseConnection();
    ElitePlayerInventory.initialize();
    // Get world list
    worldScanner();
    // Start the repeating tasks such as scanners
    launchRunnables();
    // launch events
    ActionEvent.initializeBlueprintEvents();
    TimedEvent.initializeBlueprintEvents();
    // launch internal clock for attack cooldown
    EliteMobDamagedByPlayerEvent.EliteMobDamagedByPlayerEventFilter.launchInternalClock();
    /*
        Initialize mob values
         */
    PluginMobProperties.initializePluginMobValues();
    /*
        Cache animation vectors
         */
    MinorPowerStanceMath.initializeVectorCache();
    MajorPowerStanceMath.initializeVectorCache();
    /*
        Scan for loaded SuperMobs
         */
    PassiveEliteMobDeathHandler.SuperMobScanner.scanSuperMobs();
    // Small check to make sure that PlaceholderAPI is installed
    if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
        Placeholders placeholders = new Placeholders();
        placeholders.register();
        this.placeholders = placeholders;
    }
    // Enable stats
    metrics = new Metrics(this, 1081);
    // Initialize custom charts
    new CustomCharts();
    // Imports custom configurations and mindungeons from the import folder
    ConfigurationImporter.initializeConfigs();
    ConfigurationExporter.initializeConfigs();
    // Import custom items after potentially importing new items
    new CustomItemsConfig();
    CustomItem.initializeCustomItems();
    LootTables.initialize();
    // Load minidungeons, most of all load the worlds of minidungeons
    new DungeonPackagerConfig();
    // Load Adventurer's Guild
    if (AdventurersGuildConfig.isGuildWorldIsEnabled()) {
        try {
            CustomWorldLoading.startupWorldInitialization();
            AdventurersGuildCommand.defineTeleportLocation();
            if (AdventurersGuildConfig.getGuildWorldLocation() == null)
                AdventurersGuildConfig.toggleGuildInstall();
        } catch (Exception e) {
            AdventurersGuildConfig.toggleGuildInstall();
            new WarningMessage("Failed to initialize the Adventurer's Guild Hub! It is now disabled. You can try to" + "reenable it in /em setup");
        }
    }
    // Load all regional bosses
    new CustomBossesConfig();
    new CustomTreasureChestsConfig();
    // Find the stats of bosses in minidungeons
    for (Minidungeon minidungeon : Minidungeon.getMinidungeons().values()) {
        if (minidungeon.getDungeonPackagerConfigFields().getDungeonLocationType() != null)
            if (minidungeon.getDungeonPackagerConfigFields().getDungeonLocationType().equals(DungeonPackagerConfigFields.DungeonLocationType.WORLD))
                minidungeon.quantifyWorldBosses();
            else if (minidungeon.getDungeonPackagerConfigFields().getDungeonLocationType().equals(DungeonPackagerConfigFields.DungeonLocationType.SCHEMATIC))
                minidungeon.quantifySchematicBosses(false);
    }
    // Initialize npcs
    new NPCsConfig();
    // Initialize custom spawn methods, this runs late because it compares loaded worlds against worlds listed in the config
    try {
        new CustomSpawnConfig();
    } catch (Exception ex) {
        new WarningMessage("You are using a version of Spigot or a branch thereof (Paper, Purpur, so on) that is (probably) HORRIBLY outdated!" + " This issue will probably be fixed if you update your server version to the latest patch of the version you are running.");
        new WarningMessage(" This does not mean that you have to update your Minecraft version, but it does mean you must update your server version to the latest patch" + " available for that Minecraft version. Download from trustworthy sources, as if you download Spigot from some random website other than Spigot," + " you are probably not getting the latest version (and also there's a high chance you'll get a virus).");
    }
    new CustomQuestsConfig();
    new WormholeConfig();
    // Commands
    new CommandHandler();
    /*
        Check for new plugin version or for dungeon updates
         */
    VersionChecker.check();
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) CustomItemsConfig(com.magmaguy.elitemobs.config.customitems.CustomItemsConfig) Minidungeon(com.magmaguy.elitemobs.dungeons.Minidungeon) CustomQuestsConfig(com.magmaguy.elitemobs.config.customquests.CustomQuestsConfig) CustomTreasureChestsConfig(com.magmaguy.elitemobs.config.customtreasurechests.CustomTreasureChestsConfig) IOException(java.io.IOException) CommandHandler(com.magmaguy.elitemobs.commands.CommandHandler) IOException(java.io.IOException) CustomCharts(com.magmaguy.elitemobs.thirdparty.bstats.CustomCharts) DungeonPackagerConfig(com.magmaguy.elitemobs.config.dungeonpackager.DungeonPackagerConfig) WormholeConfig(com.magmaguy.elitemobs.config.wormholes.WormholeConfig) Metrics(org.bstats.bukkit.Metrics) Placeholders(com.magmaguy.elitemobs.thirdparty.placeholderapi.Placeholders) InfoMessage(com.magmaguy.elitemobs.utils.InfoMessage) NPCsConfig(com.magmaguy.elitemobs.config.npcs.NPCsConfig) CustomSpawnConfig(com.magmaguy.elitemobs.config.customspawns.CustomSpawnConfig) File(java.io.File) CustomBossesConfig(com.magmaguy.elitemobs.config.custombosses.CustomBossesConfig)

Example 5 with InfoMessage

use of com.magmaguy.elitemobs.utils.InfoMessage in project EliteMobs by MagmaGuy.

the class VersionChecker method checkPluginVersion.

private static void checkPluginVersion() {
    new BukkitRunnable() {

        @Override
        public void run() {
            String currentVersion = MetadataHandler.PLUGIN.getDescription().getVersion();
            boolean snapshot = false;
            if (currentVersion.contains("SNAPSHOT")) {
                snapshot = true;
                currentVersion = currentVersion.split("-")[0];
            }
            String publicVersion = "";
            try {
                Bukkit.getLogger().info("[EliteMobs] Latest public release is " + VersionChecker.readStringFromURL("https://api.spigotmc.org/legacy/update.php?resource=40090"));
                Bukkit.getLogger().info("[EliteMobs] Your version is " + MetadataHandler.PLUGIN.getDescription().getVersion());
                publicVersion = VersionChecker.readStringFromURL("https://api.spigotmc.org/legacy/update.php?resource=40090");
            } catch (IOException e) {
                Bukkit.getLogger().warning("[EliteMobs] Couldn't check latest version");
                return;
            }
            if (Double.parseDouble(currentVersion.split("\\.")[0]) < Double.parseDouble(publicVersion.split("\\.")[0])) {
                outOfDateHandler();
                return;
            }
            if (Double.parseDouble(currentVersion.split("\\.")[0]) == Double.parseDouble(publicVersion.split("\\.")[0])) {
                if (Double.parseDouble(currentVersion.split("\\.")[1]) < Double.parseDouble(publicVersion.split("\\.")[1])) {
                    outOfDateHandler();
                    return;
                }
                if (Double.parseDouble(currentVersion.split("\\.")[1]) == Double.parseDouble(publicVersion.split("\\.")[1])) {
                    if (Double.parseDouble(currentVersion.split("\\.")[2]) < Double.parseDouble(publicVersion.split("\\.")[2])) {
                        outOfDateHandler();
                        return;
                    }
                }
            }
            if (!snapshot)
                Bukkit.getLogger().info("[EliteMobs] You are running the latest version!");
            else
                new InfoMessage("You are running a snapshot version! You can check for updates in the #releases channel on the EliteMobs Discord!");
            pluginIsUpToDate = true;
        }
    }.runTaskAsynchronously(MetadataHandler.PLUGIN);
}
Also used : InfoMessage(com.magmaguy.elitemobs.utils.InfoMessage) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) IOException(java.io.IOException)

Aggregations

InfoMessage (com.magmaguy.elitemobs.utils.InfoMessage)14 WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)11 File (java.io.File)7 ZipFile (com.magmaguy.elitemobs.utils.ZipFile)3 IOException (java.io.IOException)3 Minidungeon (com.magmaguy.elitemobs.dungeons.Minidungeon)2 WorldCreator (org.bukkit.WorldCreator)2 CustomEventStartEvent (com.magmaguy.elitemobs.api.CustomEventStartEvent)1 CommandHandler (com.magmaguy.elitemobs.commands.CommandHandler)1 CustomBossesConfig (com.magmaguy.elitemobs.config.custombosses.CustomBossesConfig)1 CustomItemsConfig (com.magmaguy.elitemobs.config.customitems.CustomItemsConfig)1 CustomQuestsConfig (com.magmaguy.elitemobs.config.customquests.CustomQuestsConfig)1 CustomSpawnConfig (com.magmaguy.elitemobs.config.customspawns.CustomSpawnConfig)1 CustomTreasureChestsConfig (com.magmaguy.elitemobs.config.customtreasurechests.CustomTreasureChestsConfig)1 DungeonPackagerConfig (com.magmaguy.elitemobs.config.dungeonpackager.DungeonPackagerConfig)1 NPCsConfig (com.magmaguy.elitemobs.config.npcs.NPCsConfig)1 WormholeConfig (com.magmaguy.elitemobs.config.wormholes.WormholeConfig)1 CustomLootTable (com.magmaguy.elitemobs.items.customloottable.CustomLootTable)1 CustomSpawn (com.magmaguy.elitemobs.mobconstructor.CustomSpawn)1 CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)1