Giter Site home page Giter Site logo

gamesenselib's Introduction

GameSenseLib

Build your own Minecraft minigame with flexible, extensible, and modular API.

Build your game with a simple style API with some built-in modules:

public class ExampleGame {
    public static AbstractGame simpleGame() {
        GameTemplate.of(plugin)
                .withWaitingRoom(
                        1, // min player
                        2, // max player
                        Duration.ofSeconds(10), // waiting duration
                        new Location(Bukkit.getWorld("game_world"), 0, 64, 0) // waiting room spawn location
                )
                .withBroadcastMessagePlayerJoinAndQuit(
                        player -> "Player Join the game: " + player.getName(),
                        player -> "Player Quit the game: " + player.getName()
                )
                .setRemovePlayerOnQuit(true)
                .setTeleportPlayerOnQuit(true)
                .setQuitCommand("quit")
                .setJoinCommand("join")
                .addPhase(
                        0, // priority
                        () -> Phase.builder()
                                .onStart((it) -> Bukkit.broadcastMessage("Game Start!"))
                                .build()
                )
                .world(Bukkit.getWorld("game_world"))
                .build();
    }
}

Or, try a more complex, flexible style:

public class ExampleGame extends AbstractGame {

    public ExampleGame(Plugin plugin) {
        super(plugin);
    }

    @Override
    public void init() {
        super.init();

        Bukkit.broadcastMessage("Game Created...");

        installModule(new ExampleModule(this));

        // do your own stuff...
    }

    @Override
    protected FlowManager.FlowManagerBuilder generateFlowManager() {
        FlowManager.FlowManagerBuilder builder = FlowManager.builder();

        builder.addPhase(
                0, // priority
                () -> Phase.builder()
                        .onStart((it) -> Bukkit.broadcastMessage("Game Start!"))
                        .build()
        );

        PhaseAndModule<PhaseBlockingModule> blockingModule = ExtraPhases.blockingPhase();
        builder.addPhase(
                1,
                blockingModule::getPhase
        );
        builder.addPhase(
                1,
                () -> Phase.builder()
                        .onStart((it) -> Bukkit.broadcastMessage("Waiting for game end..."))
                        .build()
        );

        builder.addPhase(
                2,
                () -> Phase.builder()
                        .onStart((it) -> Bukkit.broadcastMessage("Game end!"))
                        .build()
        );

        return builder;
    }
}

Getting Started

Please read the Wiki for more information.

License

GameSenseLib is licensed under the Apache License 2.0.

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.