Code Monkey home page Code Monkey logo

library-parent's Introduction

Library-Parent

A small library for bukkit and bungeecord plugins. Open sourced it because yes.

Examples

1. Module

public class ExampleModule extends AbstractModule {

    @PostInject
    public void registerCommands(final CommandService service, final Injector injector) {
        service.registerNodes(ExampleCommands.class, injector);
    }

    @PostInject
    public void registerMenus(final MenuHolderFactory factory) {
        factory.createMenu(ExampleMenu.class);
    }

}

2. Commands

@Command(aliases = "poke", description = "Poke someone.")
public void poke(@Sender Player player, @Argument("player") Player other) {
    other.playSound(other.getLocation(), Sound.GLASS, 100, 50);
    player.sendMessage(color("&eYou have poked &a" + other.getName() + "&e."));
    other.sendMessage(color("&eYou have been poked by &a" + player.getName() + "&e!"));
}

3. Menu

@MenuMeta(aliases = "example", title = "&lTesting")
public class ExampleMenu implements Menu {

    @Override
    public Table<Integer, ItemStack, MenuAction> render(Player player) {
        Table<Integer, ItemStack, MenuAction> table = HashBasedTable.create();

        /* Fill bedrock around the inventory. */
        Menus.fill(table, new ItemStack(Material.BEDROCK), 3, RowType.AROUND);

        /* Set a nether star in the middle. */
        table.put(13, new ItemStack(Material.NETHER_STAR), clickType -> {
            player.closeInventory();
            player.sendMessage(ChatColor.GOLD + "You just clicked a star!");
            return true;
        });

        return table;
    }

}

4. Sidebar

public class TestSidebarProvider implements SidebarProvider {

    private final Server server;

    @Inject
    public TestSidebarProvider(final Server server) {
        this.server = server;
    }

    @Override
    public Function<Player, String> getTitle() {
        return player -> "&dCatMC";
    }

    @Override
    public Function<Player, List<String>> getLines() {
        return player -> Arrays.asList(
                "&7&m----------------------",
                "&bOnline: &f" + server.getOnlinePlayers().size(),
                " ",
                "&bYou: &f" + player.getName(),
                "&7&m----------------------"
        );
    }

    @Override
    public Function<Player, Boolean> isShowing() {
        return player -> true;
    }
}

5. Nametag

public class TestNameTagProvider implements NameTagProvider {

    @Override
    public Function<Player, String> getPrefix() {
        return player -> "&7[Prefix] &e";
    }

    @Override
    public Function<Player, String> getSuffix() {
        return player -> " &7(Suffix)";
    }
}

library-parent's People

Contributors

virtualwinter avatar dependabot[bot] avatar

Stargazers

QwQ-dev avatar  avatar Fear avatar

Watchers

 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.