Search in sources :

Example 1 with MarkerDefinition

use of com.voxelgameslib.voxelgameslib.components.map.MarkerDefinition in project VoxelGamesLibv2 by VoxelGamesLib.

the class EditMode method gui.

@Subcommand("gui")
@CommandPermission("%admin")
public void gui(@Nonnull User sender) {
    if (editMode.contains(sender.getUuid())) {
        // TODO implement paginated invs
        InventoryMenuBuilder builder = new InventoryMenuBuilder().withSize(9).withTitle(Lang.legacy(LangKey.INV_MARKER));
        for (int i = 0; i < mapHandler.getMarkerDefinitions().size(); i++) {
            MarkerDefinition markerDefinition = mapHandler.getMarkerDefinitions().get(i);
            ItemStack is = new ItemBuilder(Material.PLAYER_HEAD).name(markerDefinition.getPrefix()).meta(itemMeta -> {
                char prefix = markerDefinition.getPrefix().toUpperCase().charAt(0);
                Skin skin = textureHandler.getSkin(prefix + "").orElseThrow(() -> new VoxelGameLibException("Unknown skull " + prefix));
                SkullMeta meta = ((SkullMeta) itemMeta);
                meta.setPlayerProfile(textureHandler.getPlayerProfile(skin));
                Objects.requireNonNull(meta.getPlayerProfile()).setName(markerDefinition.getPrefix());
                meta.setOwner(markerDefinition.getPrefix());
            }).build();
            builder.withItem(i, is, (player, clickType, itemStack) -> sender.getPlayer().performCommand("editmode skull " + itemStack.getItemMeta().getDisplayName()), ClickType.LEFT);
        }
        builder.show(sender.getPlayer());
    } else {
        Lang.msg(sender, LangKey.EDITMODE_NOT_ENABLED);
    }
}
Also used : ClickType(org.bukkit.event.inventory.ClickType) User(com.voxelgameslib.voxelgameslib.components.user.User) PlayerProfile(com.destroystokyo.paper.profile.PlayerProfile) CommandAlias(co.aikar.commands.annotation.CommandAlias) MapHandler(com.voxelgameslib.voxelgameslib.components.map.MapHandler) Singleton(javax.inject.Singleton) VoxelGameLibException(com.voxelgameslib.voxelgameslib.api.exception.VoxelGameLibException) TextureHandler(com.voxelgameslib.voxelgameslib.internal.texture.TextureHandler) SkullMeta(org.bukkit.inventory.meta.SkullMeta) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) InventoryMenuBuilder(org.inventivetalent.menubuilder.inventory.InventoryMenuBuilder) MarkerDefinition(com.voxelgameslib.voxelgameslib.components.map.MarkerDefinition) CommandPermission(co.aikar.commands.annotation.CommandPermission) Nonnull(javax.annotation.Nonnull) Material(org.bukkit.Material) Subcommand(co.aikar.commands.annotation.Subcommand) BaseCommand(co.aikar.commands.BaseCommand) Skin(org.mineskin.data.Skin) UUID(java.util.UUID) Logger(java.util.logging.Logger) Lang(com.voxelgameslib.voxelgameslib.internal.lang.Lang) ItemStack(org.bukkit.inventory.ItemStack) Objects(java.util.Objects) List(java.util.List) ItemBuilder(com.voxelgameslib.voxelgameslib.util.utils.ItemBuilder) Syntax(co.aikar.commands.annotation.Syntax) Optional(java.util.Optional) LangKey(com.voxelgameslib.voxelgameslib.internal.lang.LangKey) Default(co.aikar.commands.annotation.Default) ItemBuilder(com.voxelgameslib.voxelgameslib.util.utils.ItemBuilder) InventoryMenuBuilder(org.inventivetalent.menubuilder.inventory.InventoryMenuBuilder) VoxelGameLibException(com.voxelgameslib.voxelgameslib.api.exception.VoxelGameLibException) Skin(org.mineskin.data.Skin) SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack) MarkerDefinition(com.voxelgameslib.voxelgameslib.components.map.MarkerDefinition) Subcommand(co.aikar.commands.annotation.Subcommand) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Aggregations

BaseCommand (co.aikar.commands.BaseCommand)1 CommandAlias (co.aikar.commands.annotation.CommandAlias)1 CommandPermission (co.aikar.commands.annotation.CommandPermission)1 Default (co.aikar.commands.annotation.Default)1 Subcommand (co.aikar.commands.annotation.Subcommand)1 Syntax (co.aikar.commands.annotation.Syntax)1 PlayerProfile (com.destroystokyo.paper.profile.PlayerProfile)1 VoxelGameLibException (com.voxelgameslib.voxelgameslib.api.exception.VoxelGameLibException)1 MapHandler (com.voxelgameslib.voxelgameslib.components.map.MapHandler)1 MarkerDefinition (com.voxelgameslib.voxelgameslib.components.map.MarkerDefinition)1 User (com.voxelgameslib.voxelgameslib.components.user.User)1 Lang (com.voxelgameslib.voxelgameslib.internal.lang.Lang)1 LangKey (com.voxelgameslib.voxelgameslib.internal.lang.LangKey)1 TextureHandler (com.voxelgameslib.voxelgameslib.internal.texture.TextureHandler)1 ItemBuilder (com.voxelgameslib.voxelgameslib.util.utils.ItemBuilder)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1