Search in sources :

Example 6 with WarningMessage

use of com.magmaguy.elitemobs.utils.WarningMessage 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 7 with WarningMessage

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

the class PlayerData method getDatabaseString.

private static String getDatabaseString(UUID uuid, String value) {
    try {
        Statement statement = getConnection().createStatement();
        ResultSet resultSet = statement.executeQuery("SELECT * FROM " + PLAYER_DATA_TABLE_NAME + " WHERE PlayerUUID = '" + uuid.toString() + "';");
        String reply = resultSet.getString(value);
        resultSet.close();
        statement.close();
        return reply;
    } catch (Exception e) {
        new WarningMessage("Failed to get string value from database!");
        e.printStackTrace();
        return null;
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage)

Example 8 with WarningMessage

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

the class GenerateDatabase method addColumn.

private static void addColumn(String columnName, ColumnValues type) {
    try {
        Statement statement = PlayerData.getConnection().createStatement();
        String sql = "ALTER TABLE " + PlayerData.getPLAYER_DATA_TABLE_NAME() + " ADD " + columnName + " " + type.toString();
        statement.executeUpdate(sql);
        statement.close();
    } catch (Exception ex) {
        new WarningMessage("Failed to insert new column " + columnName);
        ex.printStackTrace();
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) Statement(java.sql.Statement)

Example 9 with WarningMessage

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

the class ConfigurationExporter method overwriteSHA1.

public static void overwriteSHA1(CommandSender commandSender) {
    File serverProperties = null;
    try {
        serverProperties = new File(Paths.get(MetadataHandler.PLUGIN.getDataFolder().getParentFile().getCanonicalFile().getParentFile().toString() + File.separatorChar + "server.properties").toString());
        if (!serverProperties.exists()) {
            commandSender.sendMessage("[EliteMobs] Could not find server.properties file correctly! You will have to set the SHA-1 value manually!");
            return;
        }
    } catch (Exception exception) {
        new WarningMessage("[EliteMobs] Could not find server.properties file correctly! You will have to set the SHA-1 value manually.");
        exception.printStackTrace();
        return;
    }
    String sha1 = generateResourcePackSHA1(commandSender);
    if (sha1 == null)
        return;
    try {
        FileInputStream in = new FileInputStream(serverProperties);
        Properties props = new Properties();
        props.load(in);
        in.close();
        FileOutputStream out = new FileOutputStream(serverProperties);
        props.setProperty("resource-pack-sha1", sha1);
        props.store(out, null);
        out.close();
    } catch (Exception ex) {
        commandSender.sendMessage("[EliteMobs] Failed to save SHA1 value " + sha1 + " ! You will have to do this manually.");
    }
    commandSender.sendMessage(ChatColor.GREEN + "[EliteMobs] Successfully set the value resource-pack-sha1=" + sha1 + " in server.properties!");
    commandSender.sendMessage(ChatColor.RED + "[EliteMobs] Don't forget to update the downloadable resource pack at your online location of choice!" + " If you don't update the version people download things won't work correctly!");
    commandSender.sendMessage(ChatColor.GREEN + "[EliteMobs] The server.properties modification will work starting with the next restart!");
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) FileOutputStream(java.io.FileOutputStream) Properties(java.util.Properties) File(java.io.File) ZipFile(com.magmaguy.elitemobs.utils.ZipFile) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) FileInputStream(java.io.FileInputStream)

Example 10 with WarningMessage

use of com.magmaguy.elitemobs.utils.WarningMessage 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)

Aggregations

WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)76 InfoMessage (com.magmaguy.elitemobs.utils.InfoMessage)11 Vector (org.bukkit.util.Vector)11 Item (org.bukkit.entity.Item)10 File (java.io.File)9 CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)8 FlagConflictException (com.sk89q.worldguard.protection.flags.registry.FlagConflictException)7 RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)6 RegionContainer (com.sk89q.worldguard.protection.regions.RegionContainer)6 ArrayList (java.util.ArrayList)6 ZipFile (com.magmaguy.elitemobs.utils.ZipFile)5 GlobalProtectedRegion (com.sk89q.worldguard.protection.regions.GlobalProtectedRegion)5 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)5 Location (org.bukkit.Location)5 ItemStack (org.bukkit.inventory.ItemStack)5 CustomBossesConfigFields (com.magmaguy.elitemobs.config.custombosses.CustomBossesConfigFields)3 Minidungeon (com.magmaguy.elitemobs.dungeons.Minidungeon)3 IOException (java.io.IOException)3 Material (org.bukkit.Material)3 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)3