Search in sources :

Example 1 with ItemBuilder

use of com.alpsbte.plotsystem.utils.items.builder.ItemBuilder in project Plot-System by AlpsBTE.

the class BuilderUtilitiesMenu method setMenuItemsAsync.

@Override
protected void setMenuItemsAsync() {
    // Set custom-heads menu item
    getMenu().getSlot(10).setItem(new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setName("§b§l" + LangUtil.get(getMenuPlayer(), LangPaths.MenuTitle.CUSTOM_HEADS).toUpperCase()).setLore(new LoreBuilder().addLine(LangUtil.get(getMenuPlayer(), LangPaths.MenuDescription.CUSTOM_HEADS)).build()).build());
    // Set banner-maker menu item
    getMenu().getSlot(13).setItem(new ItemBuilder(Material.BANNER, 1, (byte) 14).setName("§b§l" + LangUtil.get(getMenuPlayer(), LangPaths.MenuTitle.BANNER_MAKER).toUpperCase()).setLore(new LoreBuilder().addLine(LangUtil.get(getMenuPlayer(), LangPaths.MenuDescription.BANNER_MAKER)).build()).build());
    // Set special-blocks menu item
    getMenu().getSlot(16).setItem(SpecialBlocksMenu.getMenuItem(getMenuPlayer()));
}
Also used : ItemBuilder(com.alpsbte.plotsystem.utils.items.builder.ItemBuilder) LoreBuilder(com.alpsbte.plotsystem.utils.items.builder.LoreBuilder)

Example 2 with ItemBuilder

use of com.alpsbte.plotsystem.utils.items.builder.ItemBuilder in project Plot-System by AlpsBTE.

the class CompanionMenu method setCityProjectItems.

/**
 * Sets city project items asynchronously in the menu
 * @throws SQLException When querying database
 */
private void setCityProjectItems() throws SQLException {
    for (int i = 0; i < cityProjects.size(); i++) {
        if (i <= 28) {
            CityProject cp = cityProjects.get(i);
            ItemStack cpItem = cp.getCountry().getHead();
            try {
                PlotDifficulty cpPlotDifficulty = selectedPlotDifficulty != null ? selectedPlotDifficulty : PlotManager.getPlotDifficultyForBuilder(cp.getID(), new Builder(getMenuPlayer().getUniqueId())).get();
                int plotsOpen = PlotManager.getPlots(cp.getID(), Status.unclaimed).size();
                int plotsInProgress = PlotManager.getPlots(cp.getID(), Status.unfinished, Status.unreviewed).size();
                int plotsCompleted = PlotManager.getPlots(cp.getID(), Status.completed).size();
                int plotsUnclaimed = PlotManager.getPlots(cp.getID(), cpPlotDifficulty, Status.unclaimed).size();
                getMenu().getSlot(9 + cityProjects.indexOf(cp)).setItem(new ItemBuilder(cpItem).setName("§b§l" + cp.getName()).setLore(new LoreBuilder().addLines(cp.getDescription(), "", "§6" + plotsOpen + " §7" + LangUtil.get(getMenuPlayer(), LangPaths.CityProject.PROJECT_OPEN), "§8---------------------", "§6" + plotsInProgress + " §7" + LangUtil.get(getMenuPlayer(), LangPaths.CityProject.PROJECT_IN_PROGRESS), "§6" + plotsCompleted + " §7" + LangUtil.get(getMenuPlayer(), LangPaths.CityProject.PROJECT_COMPLETED), "", plotsUnclaimed != 0 ? Utils.getFormattedDifficulty(cpPlotDifficulty) : "§f§l" + LangUtil.get(getMenuPlayer(), LangPaths.CityProject.PROJECT_NO_PLOTS)).build()).build());
            } catch (SQLException | ExecutionException | InterruptedException ex) {
                Bukkit.getLogger().log(Level.SEVERE, "A SQL error occurred!", ex);
                getMenu().getSlot(9 + cityProjects.indexOf(cp)).setItem(MenuItems.errorItem(getMenuPlayer()));
            }
        }
    }
}
Also used : ItemBuilder(com.alpsbte.plotsystem.utils.items.builder.ItemBuilder) SQLException(java.sql.SQLException) PlotDifficulty(com.alpsbte.plotsystem.utils.enums.PlotDifficulty) LoreBuilder(com.alpsbte.plotsystem.utils.items.builder.LoreBuilder) Builder(com.alpsbte.plotsystem.core.system.Builder) ItemBuilder(com.alpsbte.plotsystem.utils.items.builder.ItemBuilder) ItemStack(org.bukkit.inventory.ItemStack) LoreBuilder(com.alpsbte.plotsystem.utils.items.builder.LoreBuilder) ExecutionException(java.util.concurrent.ExecutionException) CityProject(com.alpsbte.plotsystem.core.system.CityProject)

Example 3 with ItemBuilder

use of com.alpsbte.plotsystem.utils.items.builder.ItemBuilder in project Plot-System by AlpsBTE.

the class PlayerPlotsMenu method setMenuItemsAsync.

@Override
protected void setMenuItemsAsync() {
    // Load player head
    ItemStack playerHead = Utils.getPlayerHead(builder.getUUID());
    // Set player stats item
    try {
        getMenu().getSlot(4).setItem(new ItemBuilder(playerHead).setName("§6§l" + builder.getName()).setLore(new LoreBuilder().addLines(LangUtil.get(getMenuPlayer(), LangPaths.Plot.SCORE) + ": §f" + builder.getScore(), "§7" + LangUtil.get(getMenuPlayer(), LangPaths.Plot.COMPLETED_PLOTS) + ": §f" + builder.getCompletedBuilds()).build()).build());
    } catch (SQLException ex) {
        Bukkit.getLogger().log(Level.SEVERE, "A SQL error occurred!", ex);
        getMenu().getSlot(4).setItem(MenuItems.errorItem(getMenuPlayer()));
    }
    // Set player plot items
    try {
        plots = PlotManager.getPlots(builder);
        plotDisplayCount = Math.min(plots.size(), 36);
        for (int i = 0; i < plotDisplayCount; i++) {
            Plot plot = plots.get(i);
            try {
                ItemStack item = plot.getStatus() == Status.unfinished ? new ItemStack(Material.WOOL, 1, (byte) 1) : plot.getStatus() == Status.unreviewed ? new ItemStack(Material.MAP) : new ItemStack(Material.WOOL, 1, (byte) 13);
                getMenu().getSlot(9 + i).setItem(new ItemBuilder(item).setName("§b§l" + plot.getCity().getName() + " | " + LangUtil.get(getMenuPlayer(), LangPaths.Plot.PLOT_NAME) + " #" + plot.getID()).setLore(getDescription(plot, getMenuPlayer())).build());
            } catch (SQLException ex) {
                Bukkit.getLogger().log(Level.SEVERE, "A SQL error occurred!", ex);
                getMenu().getSlot(9 + i).setItem(MenuItems.errorItem(getMenuPlayer()));
            }
        }
    } catch (SQLException ex) {
        Bukkit.getLogger().log(Level.SEVERE, "A SQL error occurred!", ex);
    }
}
Also used : ItemBuilder(com.alpsbte.plotsystem.utils.items.builder.ItemBuilder) SQLException(java.sql.SQLException) Plot(com.alpsbte.plotsystem.core.system.plot.Plot) ItemStack(org.bukkit.inventory.ItemStack) LoreBuilder(com.alpsbte.plotsystem.utils.items.builder.LoreBuilder)

Example 4 with ItemBuilder

use of com.alpsbte.plotsystem.utils.items.builder.ItemBuilder in project Plot-System by AlpsBTE.

the class PlotActionsMenu method setMenuItemsAsync.

@Override
protected void setMenuItemsAsync() {
    // Set plot submit or undo submit item
    try {
        if (plot.getStatus().equals(Status.unreviewed)) {
            getMenu().getSlot(10).setItem(new ItemBuilder(Material.FIREBALL, 1).setName("§c§l" + LangUtil.get(getMenuPlayer(), LangPaths.MenuTitle.UNDO_SUBMIT)).setLore(new LoreBuilder().addLine(LangUtil.get(getMenuPlayer(), LangPaths.MenuDescription.UNDO_SUBMIT)).build()).build());
        } else {
            getMenu().getSlot(10).setItem(new ItemBuilder(Material.NAME_TAG, 1).setName("§a§l" + LangUtil.get(getMenuPlayer(), LangPaths.MenuTitle.SUBMIT)).setLore(new LoreBuilder().addLines(LangUtil.get(getMenuPlayer(), LangPaths.MenuDescription.SUBMIT_PLOT), "", Utils.getNoteFormat(LangUtil.get(getMenuPlayer(), LangPaths.Note.WONT_BE_ABLE_CONTINUE_BUILDING))).build()).build());
        }
    } catch (SQLException ex) {
        Bukkit.getLogger().log(Level.SEVERE, "A SQL error occurred!", ex);
        getMenu().getSlot(10).setItem(MenuItems.errorItem(getMenuPlayer()));
    }
    // Set teleport to plot item
    getMenu().getSlot(hasFeedback ? 12 : 13).setItem(new ItemBuilder(Material.COMPASS, 1).setName("§6§l" + LangUtil.get(getMenuPlayer(), LangPaths.MenuTitle.TELEPORT)).setLore(new LoreBuilder().addLine(LangUtil.get(getMenuPlayer(), LangPaths.MenuDescription.TELEPORT)).build()).build());
    // Set plot abandon item
    getMenu().getSlot(hasFeedback ? 14 : 16).setItem(new ItemBuilder(Material.BARRIER, 1).setName("§c§l" + LangUtil.get(getMenuPlayer(), LangPaths.MenuTitle.ABANDON)).setLore(new LoreBuilder().addLines(LangUtil.get(getMenuPlayer(), LangPaths.MenuDescription.ABANDON), "", Utils.getNoteFormat(LangUtil.get(getMenuPlayer(), LangPaths.Note.WONT_BE_ABLE_CONTINUE_BUILDING))).build()).build());
    // Set plot feedback item
    if (hasFeedback) {
        getMenu().getSlot(16).setItem(new ItemBuilder(Material.BOOK_AND_QUILL).setName("§b§l" + LangUtil.get(getMenuPlayer(), LangPaths.Review.FEEDBACK)).setLore(new LoreBuilder().addLine(LangUtil.get(getMenuPlayer(), LangPaths.MenuDescription.FEEDBACK)).build()).build());
    }
    // Set plot members item
    try {
        if (!plot.isReviewed()) {
            FileConfiguration config = PlotSystem.getPlugin().getConfigManager().getConfig();
            if ((getMenuPlayer() == plot.getPlotOwner().getPlayer() || getMenuPlayer().hasPermission("plotsystem.admin")) && config.getBoolean(ConfigPaths.ENABLE_GROUP_SUPPORT)) {
                getMenu().getSlot(22).setItem(new ItemBuilder(Utils.getItemHead(Utils.CustomHead.ADD_BUTTON)).setName("§b§l" + LangUtil.get(getMenuPlayer(), LangPaths.MenuTitle.MANAGE_MEMBERS)).setLore(new LoreBuilder().addLines(LangUtil.get(getMenuPlayer(), LangPaths.MenuDescription.MANAGE_MEMBERS), "", Utils.getNoteFormat(LangUtil.get(getMenuPlayer(), LangPaths.Note.SCORE_WILL_BE_SPLIT))).build()).build());
            } else if (plot.getPlotMembers().stream().anyMatch(m -> m.getUUID().equals(getMenuPlayer().getUniqueId()))) {
                getMenu().getSlot(22).setItem(new ItemBuilder(Utils.getItemHead(Utils.CustomHead.REMOVE_BUTTON)).setName("§b§l" + LangUtil.get(getMenuPlayer(), LangPaths.MenuTitle.LEAVE_PLOT)).setLore(new LoreBuilder().addLines(LangUtil.get(getMenuPlayer(), LangPaths.MenuDescription.LEAVE_PLOT), "", Utils.getNoteFormat(LangUtil.get(getMenuPlayer(), LangPaths.Note.WONT_BE_ABLE_CONTINUE_BUILDING))).build()).build());
            }
        }
    } catch (SQLException ex) {
        Bukkit.getLogger().log(Level.SEVERE, "A SQL error occurred!", ex);
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) LangPaths(com.alpsbte.plotsystem.utils.io.language.LangPaths) Player(org.bukkit.entity.Player) Plot(com.alpsbte.plotsystem.core.system.plot.Plot) Level(java.util.logging.Level) PlotSystem(com.alpsbte.plotsystem.PlotSystem) Builder(com.alpsbte.plotsystem.core.system.Builder) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) SQLException(java.sql.SQLException) Utils(com.alpsbte.plotsystem.utils.Utils) LoreBuilder(com.alpsbte.plotsystem.utils.items.builder.LoreBuilder) Mask(org.ipvp.canvas.mask.Mask) ConfigPaths(com.alpsbte.plotsystem.utils.io.config.ConfigPaths) MenuItems(com.alpsbte.plotsystem.utils.items.MenuItems) ItemBuilder(com.alpsbte.plotsystem.utils.items.builder.ItemBuilder) Status(com.alpsbte.plotsystem.utils.enums.Status) LangUtil(com.alpsbte.plotsystem.utils.io.language.LangUtil) BinaryMask(org.ipvp.canvas.mask.BinaryMask) Material(org.bukkit.Material) Bukkit(org.bukkit.Bukkit) ItemBuilder(com.alpsbte.plotsystem.utils.items.builder.ItemBuilder) SQLException(java.sql.SQLException) LoreBuilder(com.alpsbte.plotsystem.utils.items.builder.LoreBuilder)

Example 5 with ItemBuilder

use of com.alpsbte.plotsystem.utils.items.builder.ItemBuilder in project Plot-System by AlpsBTE.

the class PlotMemberMenu method setMenuItemsAsync.

@Override
protected void setMenuItemsAsync() {
    // Set plot owner item
    try {
        getMenu().getSlot(10).setItem(new ItemBuilder(Utils.getPlayerHead(plot.getPlotOwner().getUUID())).setName("§6§l" + LangUtil.get(getMenuPlayer(), LangPaths.Plot.OWNER)).setLore(new LoreBuilder().addLine(plot.getPlotOwner().getName()).build()).build());
    } catch (SQLException ex) {
        Bukkit.getLogger().log(Level.SEVERE, "A SQL error occurred!", ex);
    }
    // Set plot member items
    try {
        builders = plot.getPlotMembers();
        for (int i = 12; i < 15; i++) {
            if (builders.size() >= (i - 11)) {
                Builder builder = builders.get(i - 12);
                getMenu().getSlot(i).setItem(new ItemBuilder(Utils.getPlayerHead(builder.getUUID())).setName("§b§l" + LangUtil.get(getMenuPlayer(), LangPaths.Plot.MEMBER)).setLore(new LoreBuilder().addLines(builder.getName(), "", Utils.getActionFormat(LangUtil.get(getMenuPlayer(), LangPaths.Note.Action.CLICK_TO_REMOVE_PLOT_MEMBER))).build()).build());
            }
        }
    } catch (SQLException ex) {
        Bukkit.getLogger().log(Level.SEVERE, "A SQL error occurred!", ex);
    }
    // Set add plot member item
    ItemStack whitePlus = Utils.getItemHead(Utils.CustomHead.ADD_BUTTON);
    getMenu().getSlot(16).setItem(new ItemBuilder(whitePlus).setName("§6§l" + LangUtil.get(getMenuPlayer(), LangPaths.MenuTitle.ADD_MEMBER_TO_PLOT)).setLore(new LoreBuilder().addLines(LangUtil.get(getMenuPlayer(), LangPaths.MenuDescription.ADD_MEMBER_TO_PLOT), "", Utils.getNoteFormat(LangUtil.get(getMenuPlayer(), LangPaths.Note.PLAYER_HAS_TO_BE_ONLINE))).build()).build());
    // Set back item
    getMenu().getSlot(22).setItem(MenuItems.backMenuItem(getMenuPlayer()));
}
Also used : ItemBuilder(com.alpsbte.plotsystem.utils.items.builder.ItemBuilder) SQLException(java.sql.SQLException) Builder(com.alpsbte.plotsystem.core.system.Builder) LoreBuilder(com.alpsbte.plotsystem.utils.items.builder.LoreBuilder) ItemBuilder(com.alpsbte.plotsystem.utils.items.builder.ItemBuilder) LoreBuilder(com.alpsbte.plotsystem.utils.items.builder.LoreBuilder) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

ItemBuilder (com.alpsbte.plotsystem.utils.items.builder.ItemBuilder)10 LoreBuilder (com.alpsbte.plotsystem.utils.items.builder.LoreBuilder)9 SQLException (java.sql.SQLException)6 ItemStack (org.bukkit.inventory.ItemStack)6 Builder (com.alpsbte.plotsystem.core.system.Builder)4 Plot (com.alpsbte.plotsystem.core.system.plot.Plot)3 LangUtil (com.alpsbte.plotsystem.utils.io.language.LangUtil)3 Utils (com.alpsbte.plotsystem.utils.Utils)2 Status (com.alpsbte.plotsystem.utils.enums.Status)2 LangPaths (com.alpsbte.plotsystem.utils.io.language.LangPaths)2 MenuItems (com.alpsbte.plotsystem.utils.items.MenuItems)2 Level (java.util.logging.Level)2 Bukkit (org.bukkit.Bukkit)2 Material (org.bukkit.Material)2 Player (org.bukkit.entity.Player)2 BinaryMask (org.ipvp.canvas.mask.BinaryMask)2 Mask (org.ipvp.canvas.mask.Mask)2 PlotSystem (com.alpsbte.plotsystem.PlotSystem)1 CityProject (com.alpsbte.plotsystem.core.system.CityProject)1 PlotManager (com.alpsbte.plotsystem.core.system.plot.PlotManager)1