Giter Club home page Giter Club logo

hotbar's Introduction

Hotbar

Simple hotbar utility to make extensive clickable items.

Features

  • Easy to setup.
  • Intuitive to implement.
  • Lightweight.

Code Examples

The below code is taken from my ModSuite which utalises the library for the staff items portion.

package io.github.thatkawaiisam.modsuite.modules.staffmode;

import io.github.thatkawaiisam.hotbar.ClickableItem;
import io.github.thatkawaiisam.hotbar.Hotbar;
import io.github.thatkawaiisam.hotbar.HotbarManager;
import io.github.thatkawaiisam.utils.ItemBuilder;
import org.bukkit.Material;
import org.bukkit.entity.Player;

import java.util.HashMap;

public class StaffModeHotbar extends Hotbar {

    public StaffModeHotbar(HotbarManager manager, String id) {
        super(manager, id);
        initItems();
    }

    @Override
    public HashMap<Integer, ClickableItem> itemsToApply(Player player) {
        HashMap<Integer, ClickableItem> items = new HashMap<>();
        items.put(0, getCachedItem("compass"));
        items.put(1, getCachedItem("inspect"));
        items.put(2, getCachedItem("carpet"));
        items.put(7, getCachedItem("onlineStaff"));
        items.put(8, getCachedItem("appear"));
        return items;
    }

    private void initItems() {
        addCachedItem("compass", new ClickableItem(
                player -> {
                    // Empty Click Handler
                },
                new ItemBuilder().material(Material.COMPASS).title("&bTeleport Compass").build(),
                false,
                false
        ));
        addCachedItem("onlineStaff", new ClickableItem(
                player -> {
                    // Open online staff
                },
                new ItemBuilder().material(Material.SKULL_ITEM).title("&bOnline Staff").build(),
                false,
                false
        ));
        addCachedItem("disappear", new ClickableItem(
                player -> {
                    applyToPlayer(player, getCachedItem("appear"), 8);
                },
                new ItemBuilder().material(Material.INK_SACK).title("&bDisappear").durability((short)10).build(),
                false,
                false
        ));
        addCachedItem("appear", new ClickableItem(
                player -> {
                    applyToPlayer(player, getCachedItem("disappear"), 8);
                },
                new ItemBuilder().material(Material.INK_SACK).title("&bAppear").durability((short)8).build(),
                false,
                false
        ));
    }
}

Contact

hotbar's People

Contributors

thatkawaiisam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.