Search in sources :

Example 6 with MapInfo

use of com.voxelgameslib.voxelgameslib.map.MapInfo in project VoxelGamesLibv2 by VoxelGamesLib.

the class VoteFeature method openVoteMenu.

@GameEvent
public void openVoteMenu(@Nonnull PlayerInteractEvent event, User user) {
    if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) && openMenuItem.equals(event.getItem())) {
        InventoryMenuBuilder builder = new InventoryMenuBuilder().withSize(9).withTitle("Vote for a map");
        for (int id : availableMaps.keySet()) {
            MapInfo info = availableMaps.get(id);
            ItemStack item = new ItemBuilder(Material.PAPER).amount(id).name(info.getName()).lore(info.getAuthor()).build();
            builder.withItem(id - 1, item, (player, clickType, itemStack) -> confirmVote(user, id), ClickType.LEFT);
        }
        builder.show(user.getPlayer());
    }
}
Also used : ItemBuilder(com.voxelgameslib.voxelgameslib.utils.ItemBuilder) InventoryMenuBuilder(org.inventivetalent.menubuilder.inventory.InventoryMenuBuilder) MapInfo(com.voxelgameslib.voxelgameslib.map.MapInfo) ItemStack(org.bukkit.inventory.ItemStack) GameEvent(com.voxelgameslib.voxelgameslib.event.GameEvent)

Aggregations

MapInfo (com.voxelgameslib.voxelgameslib.map.MapInfo)6 JsonReader (com.google.gson.stream.JsonReader)1 GameEvent (com.voxelgameslib.voxelgameslib.event.GameEvent)1 MapException (com.voxelgameslib.voxelgameslib.exception.MapException)1 WorldException (com.voxelgameslib.voxelgameslib.exception.WorldException)1 DefaultGameData (com.voxelgameslib.voxelgameslib.game.DefaultGameData)1 Map (com.voxelgameslib.voxelgameslib.map.Map)1 ItemBuilder (com.voxelgameslib.voxelgameslib.utils.ItemBuilder)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Nonnull (javax.annotation.Nonnull)1 ZipFile (net.lingala.zip4j.core.ZipFile)1 ZipException (net.lingala.zip4j.exception.ZipException)1 FileHeader (net.lingala.zip4j.model.FileHeader)1 ItemStack (org.bukkit.inventory.ItemStack)1