Search in sources :

Example 1 with PlayerChatInput

use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by einTosti.

the class WorldManager method createCustomWorld.

/**
 * Generate a {@link BuildWorld} with a custom generator.
 *
 * @param player       The player who is creating the world
 * @param worldName    The name of the world
 * @param privateWorld Is world going to be a private world?
 * @return {@code true} if the world was successfully created, {@code false otherwise}
 * @author Ein_Jojo
 */
public boolean createCustomWorld(Player player, String worldName, boolean privateWorld) {
    if (worldExists(player, worldName)) {
        return false;
    }
    new PlayerChatInput(plugin, player, "enter_generator_name", input -> {
        List<String> genArray;
        if (input.contains(":")) {
            genArray = Arrays.asList(input.split(":"));
        } else {
            genArray = Arrays.asList(input, input);
        }
        ChunkGenerator chunkGenerator = getChunkGenerator(genArray.get(0), genArray.get(1), worldName);
        if (chunkGenerator == null) {
            player.sendMessage(plugin.getString("worlds_import_unknown_generator"));
            XSound.ENTITY_ITEM_BREAK.play(player);
            return;
        } else {
            plugin.getLogger().info("Using custom world generator: " + input);
        }
        BuildWorld buildWorld = new BuildWorld(plugin, worldName, player.getName(), player.getUniqueId(), WorldType.CUSTOM, System.currentTimeMillis(), privateWorld, input);
        buildWorlds.add(buildWorld);
        player.sendMessage(plugin.getString("worlds_world_creation_started").replace("%world%", buildWorld.getName()).replace("%type%", buildWorld.getTypeName()));
        generateBukkitWorld(worldName, buildWorld.getType(), chunkGenerator);
        player.sendMessage(plugin.getString("worlds_creation_finished"));
    });
    return true;
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) PlayerChatInput(com.eintosti.buildsystem.util.external.PlayerChatInput) ChunkGenerator(org.bukkit.generator.ChunkGenerator)

Example 2 with PlayerChatInput

use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by einTosti.

the class WorldsCommand method getProjectInput.

public void getProjectInput(Player player, boolean closeInventory) {
    BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
    if (buildWorld == null) {
        player.closeInventory();
        player.sendMessage(plugin.getString("worlds_setproject_error"));
        return;
    }
    new PlayerChatInput(plugin, player, "enter_world_project", input -> {
        buildWorld.setProject(input.trim());
        playerManager.forceUpdateSidebar(buildWorld);
        XSound.ENTITY_PLAYER_LEVELUP.play(player);
        player.sendMessage(plugin.getString("worlds_setproject_set").replace("%world%", buildWorld.getName()));
        if (closeInventory) {
            player.closeInventory();
        } else {
            player.openInventory(plugin.getEditInventory().getInventory(player, buildWorld));
        }
    });
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) PlayerChatInput(com.eintosti.buildsystem.util.external.PlayerChatInput)

Example 3 with PlayerChatInput

use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by einTosti.

the class WorldsCommand method getCreatorInput.

private void getCreatorInput(Player player) {
    BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
    if (buildWorld == null) {
        player.closeInventory();
        player.sendMessage(plugin.getString("worlds_setcreator_error"));
        return;
    }
    new PlayerChatInput(plugin, player, "enter_world_creator", input -> {
        String creator = input.trim();
        buildWorld.setCreator(creator);
        if (!creator.equalsIgnoreCase("-")) {
            buildWorld.setCreatorId(UUIDFetcher.getUUID(creator));
        } else {
            buildWorld.setCreatorId(null);
        }
        playerManager.forceUpdateSidebar(buildWorld);
        XSound.ENTITY_PLAYER_LEVELUP.play(player);
        player.sendMessage(plugin.getString("worlds_setcreator_set").replace("%world%", buildWorld.getName()));
        player.closeInventory();
    });
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) PlayerChatInput(com.eintosti.buildsystem.util.external.PlayerChatInput)

Example 4 with PlayerChatInput

use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by einTosti.

the class WorldsCommand method getRenameInput.

private void getRenameInput(Player player) {
    BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
    if (buildWorld == null) {
        player.closeInventory();
        player.sendMessage(plugin.getString("worlds_rename_unknown_world"));
        return;
    }
    new PlayerChatInput(plugin, player, "enter_world_name", input -> {
        player.closeInventory();
        worldManager.renameWorld(player, buildWorld, input.trim());
        playerManager.getSelectedWorld().remove(player.getUniqueId());
        XSound.ENTITY_PLAYER_LEVELUP.play(player);
        player.closeInventory();
    });
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) PlayerChatInput(com.eintosti.buildsystem.util.external.PlayerChatInput)

Example 5 with PlayerChatInput

use of com.eintosti.buildsystem.util.external.PlayerChatInput in project BuildSystem by Trichtern.

the class WorldsCommand method getRemoveBuilderInput.

public void getRemoveBuilderInput(Player player, boolean closeInventory) {
    BuildWorld buildWorld = playerManager.getSelectedWorld().get(player.getUniqueId());
    if (buildWorld == null) {
        player.closeInventory();
        player.sendMessage(plugin.getString("worlds_removebuilder_error"));
        return;
    }
    new PlayerChatInput(plugin, player, "enter_player_name", input -> {
        String builderName = input.trim();
        Player builderPlayer = Bukkit.getPlayerExact(builderName);
        UUID builderId;
        if (builderPlayer == null) {
            builderId = UUIDFetcher.getUUID(builderName);
            if (builderId == null) {
                player.sendMessage(plugin.getString("worlds_removebuilder_player_not_found"));
                player.closeInventory();
                return;
            }
        } else {
            builderId = builderPlayer.getUniqueId();
        }
        if (builderId.equals(player.getUniqueId()) && buildWorld.isCreator(player)) {
            player.sendMessage(plugin.getString("worlds_removebuilder_not_yourself"));
            player.closeInventory();
            return;
        }
        if (!buildWorld.isBuilder(builderId)) {
            player.sendMessage(plugin.getString("worlds_removebuilder_not_builder"));
            player.closeInventory();
            return;
        }
        buildWorld.removeBuilder(builderId);
        XSound.ENTITY_PLAYER_LEVELUP.play(player);
        player.sendMessage(plugin.getString("worlds_removebuilder_removed").replace("%builder%", builderName));
        if (closeInventory) {
            player.closeInventory();
        } else {
            player.openInventory(plugin.getBuilderInventory().getInventory(buildWorld, player));
        }
    });
}
Also used : BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) Player(org.bukkit.entity.Player) PlayerChatInput(com.eintosti.buildsystem.util.external.PlayerChatInput) UUID(java.util.UUID)

Aggregations

BuildWorld (com.eintosti.buildsystem.object.world.BuildWorld)14 PlayerChatInput (com.eintosti.buildsystem.util.external.PlayerChatInput)14 UUID (java.util.UUID)4 Player (org.bukkit.entity.Player)4 Builder (com.eintosti.buildsystem.object.world.Builder)2 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)2 ChunkGenerator (org.bukkit.generator.ChunkGenerator)2