DevNatan / inventory-framework

Minecraft Inventory API framework
MIT License
127 stars 22 forks source link

Duvida #675

Closed kaiquyricardo closed 3 weeks ago

kaiquyricardo commented 6 months ago

Queria saber como eu faço pra criar uma "task" onde eu posso alterar a mensagem utilizando o scheduler de vcs

public class CosmeticsView extends View {

private int selectedHead = 0;

private final List<String> HEADS_ANIMATED_TEXTURES = List.of(
        "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDI3MzdlOTllNGMwNTk2YTM3MTJlNzcxMWJhZWNhZThkMWRkYjc3NGFjMWNmNTMxODk2ODYyMzgwNzUzZTE2In19fQ==",
        "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjY0NjE0YWQ0YmIyZWI2MWIwNmIxYThiNWQ1N2YwMjQ0OGE5NzVhODIxN2VjMTY1NzFmODdjNDkyMjdjYmQifX19"
);

@Override
public void onInit(@NotNull ViewConfigBuilder config) {
    config.title("Cosmeticos")
            .size(6)
            .scheduleUpdate(20L)
            .cancelOnClick()
            .cancelOnDrag()
            .cancelOnPickup()
            .cancelOnDrop();
}

@Override
public void onUpdate(@NotNull Context update) {
    selectedHead = (selectedHead + 1) % HEADS_ANIMATED_TEXTURES.size();
}

@Override
public void onFirstRender(@NotNull RenderContext render) {
    render.slot(11,
            new ItemCreator(Material.WHITE_BANNER)
                    .display("§aʙᴀɴᴅᴇɪʀᴀs")
                    .addLore(
                            "§7Adquira diversas bandeiras e",
                            "§7ande com estilo pelo lobby!",
                            "",
                            "§aᴄʟɪǫᴜᴇ ᴘᴀʀᴀ ᴀʟᴛᴇʀᴀʀ.")
                    .create()
    );

    render.slot(13).onRender(item -> item.setItem(
            new ItemCreator(Material.PLAYER_HEAD)
                    .texture(HEADS_ANIMATED_TEXTURES.get(selectedHead))
                    .display("§aᴄʜᴀᴘᴇᴜs ᴀɴɪᴍᴀᴅᴏs")
                    .addLore(
                            "§7Passeie pelo lobby usando!",
                            "§7seus chapéus animados!",
                            "",
                            "§aᴄʟɪǫᴜᴇ ᴘᴀʀᴀ ᴀʟᴛᴇʀᴀʀ.")
                    .create()
    ));

}

}