Search in sources :

Example 6 with InfoMessage

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

the class TimedEvent method queueEvent.

/**
 * Queues an event to start when the start conditions are met
 */
public void queueEvent() {
    this.primaryEliteMobs = customSpawn.getCustomBossEntities();
    setEventStartLocation(customSpawn.getSpawnLocation());
    for (CustomBossEntity customBossEntity : primaryEliteMobs) if (!customBossEntity.exists()) {
        if (!silentRetry) {
            new InfoMessage("Boss " + customBossEntity.getCustomBossesConfigFields().getFilename() + " for event " + getCustomEventsConfigFields().getFilename() + " wasn't considered to be valid. Trying spawn again .");
            new InfoMessage("Note: further failures will be silent. EliteMobs can only predict WorldGuard protections," + " so it will keep trying to spawn things until plugins preventing spawning allow it to do so. This might take a while.");
            silentRetry = true;
        }
        Bukkit.getScheduler().runTaskLater(MetadataHandler.PLUGIN, () -> {
            customSpawn.setSpawnLocation(null);
            customSpawn.queueSpawn();
        }, 1);
        return;
    }
    primaryEliteMobs.forEach(CustomBossEntity::announceSpawn);
    start();
}
Also used : InfoMessage(com.magmaguy.elitemobs.utils.InfoMessage) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)

Example 7 with InfoMessage

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

the class TimedEvent method instantiateEvent.

/**
 * Just because the event is instantiated, does not necessarily mean it started. If the spawn isn't instant, then
 * it needs to be queued for a later date. If the spawn is instant but no valid location can be found, it should retry
 * on a delay.
 */
public void instantiateEvent() {
    new InfoMessage("Event " + getCustomEventsConfigFields().getFilename() + " has been queued!");
    TimedEvent timedEvent = new TimedEvent(customEventsConfigFields);
    CustomEventStartEvent customEventStartEvent = new CustomEventStartEvent(timedEvent);
    if (customEventStartEvent.isCancelled())
        return;
    timedEvent.customSpawn = new CustomSpawn(customEventsConfigFields.getCustomSpawn(), customEventsConfigFields.getBossFilenames(), timedEvent);
    // Failed to initialize event
    if (timedEvent.customSpawn.getCustomSpawnConfigFields() == null)
        return;
    // This handles the elitemobs-events flag
    timedEvent.customSpawn.setEvent(true);
    // Note: this will finish running at an arbitrary time in the future
    timedEvent.customSpawn.queueSpawn();
    // global cooldown - 60 seconds right now
    nextEventTrigger = System.currentTimeMillis() + globalCooldown * 60 * 1000;
    timedEvents.add(timedEvent);
}
Also used : CustomSpawn(com.magmaguy.elitemobs.mobconstructor.CustomSpawn) InfoMessage(com.magmaguy.elitemobs.utils.InfoMessage) CustomEventStartEvent(com.magmaguy.elitemobs.api.CustomEventStartEvent)

Example 8 with InfoMessage

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

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

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

the class GenerateDatabase method addEntryIfEmpty.

private static void addEntryIfEmpty(String columnName, ColumnValues columnValues) {
    try {
        DatabaseMetaData metaData = PlayerData.getConnection().getMetaData();
        ResultSet resultSet = metaData.getColumns(null, null, PlayerData.getPLAYER_DATA_TABLE_NAME(), columnName);
        if (resultSet.next()) {
        // Developer.message("Database already had " + columnName);
        } else {
            new InfoMessage("Adding new database column " + columnName);
            addColumn(columnName, columnValues);
        }
        resultSet.close();
    } catch (Exception ex) {
        new WarningMessage("Could not process column " + columnName);
        ex.printStackTrace();
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) InfoMessage(com.magmaguy.elitemobs.utils.InfoMessage) ResultSet(java.sql.ResultSet) DatabaseMetaData(java.sql.DatabaseMetaData)

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