Search in sources :

Example 51 with WarningMessage

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

the class PlayerData method setDatabaseValue.

public static void setDatabaseValue(UUID uuid, String key, Object value) {
    new BukkitRunnable() {

        @Override
        public void run() {
            Statement statement = null;
            try {
                statement = getConnection().createStatement();
                String sql;
                if (value instanceof String)
                    sql = "UPDATE " + PLAYER_DATA_TABLE_NAME + " SET " + key + " = '" + value + "' WHERE PlayerUUID = '" + uuid.toString() + "';";
                else
                    sql = "UPDATE " + PLAYER_DATA_TABLE_NAME + " SET " + key + " = " + value + " WHERE PlayerUUID = '" + uuid.toString() + "';";
                statement.executeUpdate(sql);
                statement.close();
            } catch (Exception e) {
                new WarningMessage("Failed to update database value.");
                e.printStackTrace();
            }
        }
    }.runTaskAsynchronously(MetadataHandler.PLUGIN);
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable)

Example 52 with WarningMessage

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

the class BossTrackingPage method bossTrackingPage.

protected static TextComponent[] bossTrackingPage(Player player) {
    TextComponent configTextComponent = new TextComponent();
    for (int i = 0; i < 3; i++) {
        TextComponent line = new TextComponent(PlayerStatusMenuConfig.getBossTrackerTextLines()[i] + "\n");
        if (!PlayerStatusMenuConfig.getBossTrackerHoverLines()[i].isEmpty())
            PlayerStatusScreen.setHoverText(line, PlayerStatusMenuConfig.getBossTrackerHoverLines()[i]);
        if (!PlayerStatusMenuConfig.getBossTrackerCommandLines()[i].isEmpty())
            line.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, PlayerStatusMenuConfig.getBossTrackerCommandLines()[i]));
        configTextComponent.addExtra(line);
    }
    ArrayList<TextComponent> textComponents = new ArrayList<>();
    int counter = 0;
    for (CustomBossEntity customBossEntity : CustomBossEntity.getTrackableCustomBosses()) {
        try {
            textComponents.add(SpigotMessage.commandHoverMessage(customBossEntity.getCustomBossBossBar().bossBarMessage(player, customBossEntity.getCustomBossesConfigFields().getLocationMessage()) + "\n", PlayerStatusMenuConfig.getOnBossTrackHover(), "/elitemobs trackcustomboss " + customBossEntity.getEliteUUID()));
            counter++;
        } catch (Exception ex) {
            new WarningMessage("Failed to correctly get elements for boss tracking page!");
            ex.printStackTrace();
        }
    }
    TextComponent[] textComponent;
    if (counter == 0) {
        textComponent = new TextComponent[1];
        textComponent[0] = configTextComponent;
    } else {
        textComponent = new TextComponent[(int) Math.floor(counter / 6D) + 1];
        int internalCounter = 0;
        textComponent[0] = configTextComponent;
        for (TextComponent text : textComponents) {
            int currentPage = (int) Math.floor(internalCounter / 6D);
            if (textComponent[currentPage] == null)
                textComponent[currentPage] = new TextComponent();
            textComponent[currentPage].addExtra(text);
            internalCounter++;
        }
    }
    return textComponent;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) ArrayList(java.util.ArrayList) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)

Example 53 with WarningMessage

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

the class NPCEntity method setDisguise.

private void setDisguise(LivingEntity livingEntity) {
    if (npCsConfigFields.getDisguise() == null)
        return;
    if (!Bukkit.getPluginManager().isPluginEnabled("LibsDisguises"))
        return;
    try {
        DisguiseEntity.disguise(npCsConfigFields.getDisguise(), livingEntity, npCsConfigFields.getCustomDisguiseData(), npCsConfigFields.getFilename());
        DisguiseEntity.setDisguiseNameVisibility(true, livingEntity);
        livingEntity.setCustomNameVisible(true);
        isDisguised = true;
    } catch (Exception ex) {
        new WarningMessage("Failed to load LibsDisguises disguise correctly!");
        ex.printStackTrace();
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage)

Example 54 with WarningMessage

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

Example 55 with WarningMessage

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

the class CustomWorldLoading method startupWorldInitialization.

public static void startupWorldInitialization() {
    File folder = new File(Bukkit.getWorldContainer().getAbsolutePath());
    File[] listOfFiles = folder.listFiles();
    assert listOfFiles != null;
    for (File listOfFile : listOfFiles) {
        if (listOfFile.isDirectory() && listOfFile.getName().equals(AdventurersGuildConfig.getGuildWorldName())) {
            new InfoMessage("[EliteMobs] World " + AdventurersGuildConfig.getGuildWorldName() + " found! Loading it in...");
            try {
                WorldCreator worldCreator = new WorldCreator(AdventurersGuildConfig.getGuildWorldName());
                Objects.requireNonNull(Bukkit.createWorld(worldCreator)).setKeepSpawnInMemory(false);
                new InfoMessage("[EliteMobs] World " + AdventurersGuildConfig.getGuildWorldName() + " has been successfully loaded! It can be accessed through the '/ag' command, unless you changed that config option!");
            } catch (Exception ex) {
                new WarningMessage("Failed to generate Adventurer's Guild World!");
                ex.printStackTrace();
            }
            break;
        }
    }
}
Also used : WorldCreator(org.bukkit.WorldCreator) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) InfoMessage(com.magmaguy.elitemobs.utils.InfoMessage) File(java.io.File)

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