Search in sources :

Example 1 with Builder

use of com.eintosti.buildsystem.object.world.Builder in project BuildSystem by einTosti.

the class InventoryManager method formatBuilders.

/**
 * Format the {@code %builder%} placeholder which can be used by a lore.
 *
 * @param buildWorld The world which provides the builders
 * @return The formatted list of builders which have been added to the given world
 * @see BuildWorld#getBuildersInfo()
 */
private List<String> formatBuilders(BuildWorld buildWorld) {
    String template = plugin.getString("world_item_builders_builder_template");
    List<Builder> builders = new ArrayList<>();
    if (configValues.isCreatorIsBuilder()) {
        if (buildWorld.getCreator() != null && !buildWorld.getCreator().equals("-")) {
            builders.add(new Builder(buildWorld.getCreatorId(), buildWorld.getCreator()));
        }
    }
    builders.addAll(buildWorld.getBuilders());
    List<String> builderNames = new ArrayList<>();
    if (builders.isEmpty()) {
        String string = template.replace("%builder%", "-").trim();
        builderNames.add(string);
    } else {
        String string = "";
        int buildersInLine = 0;
        for (Builder builder : builders) {
            buildersInLine++;
            string = string.concat(template.replace("%builder%", builder.getName()));
            if (buildersInLine == 3) {
                builderNames.add(string.trim());
                buildersInLine = 0;
                string = "";
            }
        }
        builderNames.add(string.trim());
    }
    builderNames.removeIf(String::isEmpty);
    return builderNames;
}
Also used : Builder(com.eintosti.buildsystem.object.world.Builder) ArrayList(java.util.ArrayList)

Example 2 with Builder

use of com.eintosti.buildsystem.object.world.Builder in project BuildSystem by einTosti.

the class BuilderInventory method addItems.

private void addItems(BuildWorld buildWorld, Player player) {
    List<Builder> builders = buildWorld.getBuilders();
    this.numBuilders = builders.size();
    int numInventories = (numBuilders % MAX_BUILDERS == 0 ? numBuilders : numBuilders + 1) != 0 ? (numBuilders % MAX_BUILDERS == 0 ? numBuilders : numBuilders + 1) : 1;
    int index = 0;
    Inventory inventory = createInventory(buildWorld, player);
    inventories = new Inventory[numInventories];
    inventories[index] = inventory;
    int columnSkull = 9, maxColumnSkull = 17;
    for (Builder builder : builders) {
        String builderName = builder.getName();
        inventoryManager.addSkull(inventory, columnSkull++, plugin.getString("worldeditor_builders_builder_item").replace("%builder%", builderName), builderName, plugin.getStringList("worldeditor_builders_builder_lore"));
        if (columnSkull > maxColumnSkull) {
            columnSkull = 9;
            inventory = createInventory(buildWorld, player);
            inventories[++index] = inventory;
        }
    }
}
Also used : Builder(com.eintosti.buildsystem.object.world.Builder) Inventory(org.bukkit.inventory.Inventory)

Example 3 with Builder

use of com.eintosti.buildsystem.object.world.Builder in project BuildSystem by einTosti.

the class WorldManager method loadWorld.

public BuildWorld loadWorld(String worldName) {
    FileConfiguration configuration = worldConfig.getFile();
    if (configuration == null) {
        return null;
    }
    String creator = configuration.isString("worlds." + worldName + ".creator") ? configuration.getString("worlds." + worldName + ".creator") : "-";
    UUID creatorId = parseCreatorId(configuration, worldName, creator);
    WorldType worldType = configuration.isString("worlds." + worldName + ".type") ? WorldType.valueOf(configuration.getString("worlds." + worldName + ".type")) : WorldType.UNKNOWN;
    boolean privateWorld = configuration.isBoolean("worlds." + worldName + ".private") && configuration.getBoolean("worlds." + worldName + ".private");
    XMaterial material = parseMaterial(configuration, worldName);
    WorldStatus worldStatus = WorldStatus.valueOf(configuration.getString("worlds." + worldName + ".status"));
    String project = configuration.getString("worlds." + worldName + ".project");
    String permission = configuration.getString("worlds." + worldName + ".permission");
    long date = configuration.isLong("worlds." + worldName + ".date") ? configuration.getLong("worlds." + worldName + ".date") : -1;
    boolean physics = configuration.getBoolean("worlds." + worldName + ".physics");
    boolean explosions = !configuration.isBoolean("worlds." + worldName + ".explosions") || configuration.getBoolean("worlds." + worldName + ".explosions");
    boolean mobAI = !configuration.isBoolean("worlds." + worldName + ".mobai") || configuration.getBoolean("worlds." + worldName + ".mobai");
    String customSpawn = configuration.getString("worlds." + worldName + ".spawn");
    boolean blockBreaking = !configuration.isBoolean("worlds." + worldName + ".block-breaking") || configuration.getBoolean("worlds." + worldName + ".block-breaking");
    boolean blockPlacement = !configuration.isBoolean("worlds." + worldName + ".block-placement") || configuration.getBoolean("worlds." + worldName + ".block-placement");
    boolean blockInteractions = !configuration.isBoolean("worlds." + worldName + ".block-interactions") || configuration.getBoolean("worlds." + worldName + ".block-interactions");
    boolean buildersEnabled = configuration.isBoolean("worlds." + worldName + ".builders-enabled") && configuration.getBoolean("worlds." + worldName + ".builders-enabled");
    List<Builder> builders = parseBuilders(configuration, worldName);
    String chunkGeneratorString = configuration.getString("worlds." + worldName + ".chunk-generator");
    ChunkGenerator chunkGenerator = parseChunkGenerator(configuration, worldName);
    if (worldType == WorldType.PRIVATE) {
        privateWorld = true;
        worldType = WorldType.FLAT;
    }
    BuildWorld buildWorld = new BuildWorld(plugin, worldName, creator, creatorId, worldType, privateWorld, material, worldStatus, project, permission, date, physics, explosions, mobAI, customSpawn, blockBreaking, blockPlacement, blockInteractions, buildersEnabled, builders, chunkGenerator, chunkGeneratorString);
    buildWorlds.add(buildWorld);
    return buildWorld;
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) WorldType(com.eintosti.buildsystem.object.world.data.WorldType) Builder(com.eintosti.buildsystem.object.world.Builder) UUID(java.util.UUID) XMaterial(com.cryptomorin.xseries.XMaterial) ChunkGenerator(org.bukkit.generator.ChunkGenerator) WorldStatus(com.eintosti.buildsystem.object.world.data.WorldStatus)

Example 4 with Builder

use of com.eintosti.buildsystem.object.world.Builder in project BuildSystem by Trichtern.

the class WorldManager method parseBuilders.

private List<Builder> parseBuilders(FileConfiguration configuration, String worldName) {
    List<Builder> builders = new ArrayList<>();
    if (configuration.isString("worlds." + worldName + ".builders")) {
        String buildersString = configuration.getString("worlds." + worldName + ".builders");
        if (buildersString != null && !buildersString.isEmpty()) {
            String[] splitBuilders = buildersString.split(";");
            for (String builder : splitBuilders) {
                String[] information = builder.split(",");
                builders.add(new Builder(UUID.fromString(information[0]), information[1]));
            }
        }
    }
    return builders;
}
Also used : Builder(com.eintosti.buildsystem.object.world.Builder) ArrayList(java.util.ArrayList)

Example 5 with Builder

use of com.eintosti.buildsystem.object.world.Builder in project BuildSystem by Trichtern.

the class InventoryManager method formatBuilders.

/**
 * Format the {@code %builder%} placeholder which can be used by a lore.
 *
 * @param buildWorld The world which provides the builders
 * @return The formatted list of builders which have been added to the given world
 * @see BuildWorld#getBuildersInfo()
 */
private List<String> formatBuilders(BuildWorld buildWorld) {
    String template = plugin.getString("world_item_builders_builder_template");
    List<Builder> builders = new ArrayList<>();
    if (configValues.isCreatorIsBuilder()) {
        if (buildWorld.getCreator() != null && !buildWorld.getCreator().equals("-")) {
            builders.add(new Builder(buildWorld.getCreatorId(), buildWorld.getCreator()));
        }
    }
    builders.addAll(buildWorld.getBuilders());
    List<String> builderNames = new ArrayList<>();
    if (builders.isEmpty()) {
        String string = template.replace("%builder%", "-").trim();
        builderNames.add(string);
    } else {
        String string = "";
        int buildersInLine = 0;
        for (Builder builder : builders) {
            buildersInLine++;
            string = string.concat(template.replace("%builder%", builder.getName()));
            if (buildersInLine == 3) {
                builderNames.add(string.trim());
                buildersInLine = 0;
                string = "";
            }
        }
        builderNames.add(string.trim());
    }
    builderNames.removeIf(String::isEmpty);
    return builderNames;
}
Also used : Builder(com.eintosti.buildsystem.object.world.Builder) ArrayList(java.util.ArrayList)

Aggregations

Builder (com.eintosti.buildsystem.object.world.Builder)10 BuildWorld (com.eintosti.buildsystem.object.world.BuildWorld)4 ArrayList (java.util.ArrayList)4 UUID (java.util.UUID)4 XMaterial (com.cryptomorin.xseries.XMaterial)2 WorldStatus (com.eintosti.buildsystem.object.world.data.WorldStatus)2 WorldType (com.eintosti.buildsystem.object.world.data.WorldType)2 PlayerChatInput (com.eintosti.buildsystem.util.external.PlayerChatInput)2 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)2 FileConfiguration (org.bukkit.configuration.file.FileConfiguration)2 Player (org.bukkit.entity.Player)2 ChunkGenerator (org.bukkit.generator.ChunkGenerator)2 Inventory (org.bukkit.inventory.Inventory)2 Difficulty (org.bukkit.Difficulty)1