Search in sources :

Example 46 with WarningMessage

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

the class MinidungeonWorldLoader method loadWorld.

public static World loadWorld(Minidungeon minidungeon, String worldName, World.Environment environment) {
    File folder = new File(Bukkit.getWorldContainer().getAbsolutePath());
    new InfoMessage("Trying to load Minidungeon world " + worldName);
    if (!Files.exists(Paths.get(folder.getAbsolutePath() + "/" + worldName)))
        return null;
    new InfoMessage("Detected Minidungeon world " + worldName);
    try {
        WorldCreator worldCreator = new WorldCreator(worldName);
        worldCreator.environment(environment);
        World world = Bukkit.createWorld(worldCreator);
        if (world != null)
            world.setKeepSpawnInMemory(false);
        new InfoMessage("Minidungeons world " + worldName + " was loaded successfully!");
        minidungeon.setInstalled(true);
        world.setDifficulty(Difficulty.HARD);
        return world;
    } catch (Exception exception) {
        new WarningMessage("Failed to load Minidungeon world " + worldName + " !");
        exception.printStackTrace();
    }
    return null;
}
Also used : WorldCreator(org.bukkit.WorldCreator) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) InfoMessage(com.magmaguy.elitemobs.utils.InfoMessage) World(org.bukkit.World) File(java.io.File)

Example 47 with WarningMessage

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

the class PlayerData method getDatabaseInteger.

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

Example 48 with WarningMessage

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

the class PlayerData method getDatabaseDouble.

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

Example 49 with WarningMessage

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

the class PlayerData method initializeDatabaseConnection.

public static void initializeDatabaseConnection() {
    new File(MetadataHandler.PLUGIN.getDataFolder().getPath() + "/data").mkdirs();
    try {
        new InfoMessage("Opened database successfully");
        GenerateDatabase.generate();
        for (Player player : Bukkit.getOnlinePlayers()) new PlayerData(player.getUniqueId());
    } catch (Exception e) {
        new WarningMessage(e.getClass().getName() + ": " + e.getMessage());
        new WarningMessage("Failed to establish a connection to the SQLite database. This is not good.");
    }
    new PortOldData();
}
Also used : Player(org.bukkit.entity.Player) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) InfoMessage(com.magmaguy.elitemobs.utils.InfoMessage) File(java.io.File)

Example 50 with WarningMessage

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

the class PlayerData method getDatabaseBlob.

private static Object getDatabaseBlob(UUID uuid, String value) {
    try {
        Statement statement = getConnection().createStatement();
        ResultSet resultSet = statement.executeQuery("SELECT * FROM " + PLAYER_DATA_TABLE_NAME + " WHERE PlayerUUID = '" + uuid.toString() + "';");
        byte[] bytes = resultSet.getBytes(value);
        resultSet.close();
        statement.close();
        if (bytes == null)
            return null;
        return new String(bytes);
    } catch (Exception e) {
        new WarningMessage("Failed to get blob value from database!");
        new WarningMessage("UUID: " + uuid + " | Value: " + value);
        e.printStackTrace();
        return null;
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage)

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