MCPcopy Index your code
hub / github.com/Cortex-MC/SimpAPI

github.com/Cortex-MC/SimpAPI @4.6.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 4.6.1 ↗ · + Follow
148 symbols 286 edges 26 files 60 documented · 41%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

SimpAPI v4.6.1

Table Of Contents:


Introduction


SimpAPI, finally a good API that can make coding MC Plugins much easier and less painful. This API includes all of my primary utilities like Menu Manager, Command Manager, ColorTranslator, and more.

Video Showcase: https://youtu.be/kKaIf7EkCWg

JavaDocs: https://kodysimpson.github.io/SimpAPI/index.html

Installation

Maven

Repository

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Dependency

<dependency>
    <groupId>com.github.KodySimpson</groupId>
    <artifactId>SimpAPI</artifactId>
    <version>4.6.1</version>
</dependency>

Gradle

Repository

Groovy:

repositories {
    maven { url 'https://jitpack.io' }
}

Kotlin:

repositories {
    maven { url = uri("https://jitpack.io") }
}

Dependency

Groovy/Kotlin:

dependencies {
    implementation 'com.github.KodySimpson:SimpAPI:4.6.1'
}

Usage

ColorTranslator - Hexadecimal Color Usage


To produce MC text with hexadecimal colors in it, use the translateColorCodes() method from the ColorTranslator class.

Example:

ColorTranslator.translateColorCodes("&#baebabThis is &c&lcool")

As you can see, all you need to do is provide the color code after an & as you would with a normal color code.

There is also a method for TextComponents called translateColorCodesToTextComponent() which works the same.

Skull Creator


What the skull creator does should be pretty self-explanatory, here are a few tutorials on how to use it.

Creating a skull

Example: 1

ItemStack playerSkull = SkullCreator.itemFromUuid(player.getUniqueId());

In the example above, we are using the itemFromUuid, this will take in the player's uuid, which will return an ItemStack

Example: 2

ItemStack playerSkull = SkullCreator.itemFromUuid(player.getName());

Although the example above works, it is not recommended because names are not as accurate as id's.

Keep in mind that when you create a skull, the default name of said skull will be {Player name}'s Head. If you would like to change this to be just the players name, without 's head, all you have to do is get the item's meta, and change the display name to the player's display name, simple!:

ItemStack playerSkull = SkullCreator.itemFromUuid(player.getUniqueId());
playerSkull.getItemMeta().setDisplayName(
       player.getDisplayName() 
    );
Note:

The skull creator was not created by Kody Simpson, the creator of the library is Dean B

Menu Manager


The Menu Manager is something I came up with a while ago and showed on my Youtube channel, but in the SimpAPI it is much more advanced and has been made much easier for the developers who use it.

Step One: Setup and Initializise the MenuManager by calling the Setup method. Do this in the plugin's onEnable method and all you need to do is provide the PlayerMenuUtility you just created.

    @Override
    public void onEnable() {
        // Plugin startup logic

        //Setup and register the MenuManager. It will take care of the annoying parts.
        MenuManager.setup(getServer(), this);

    }

Step Two: Add Menus.

public class FreezeMainMenu extends Menu {

    public FreezeMainMenu(PlayerMenuUtility playerMenuUtility) {
        super(playerMenuUtility);
    }

    @Override
    public String getMenuName() {
        return "Iceberg";
    }

    @Override
    public int getSlots() {
        return 9;
    }

    @Override
    public boolean cancelAllClicks() {
        return true;
    }

    @Override
    public void handleMenu(InventoryClickEvent e) throws MenuManagerNotSetupException, MenuManagerException {

        switch (e.getCurrentItem().getType()){
            case PACKED_ICE:

                MenuManager.openMenu(FreezeListMenu.class, playerMenuUtility.getOwner());

                break;
            case LAVA_BUCKET:

                MenuManager.openMenu(MeltListMenu.class, playerMenuUtility.getOwner());

                break;
        }

    }

    @Override
    public void setMenuItems() {

        ItemStack freezePlayer = makeItem(Material.PACKED_ICE, ColorTranslator.translateColorCodes("&b&lFreeze Player"));
        ItemStack meltPlayer = makeItem(Material.LAVA_BUCKET, ColorTranslator.translateColorCodes("&e&lMelt player"));

        inventory.setItem(3, freezePlayer);
        inventory.setItem(5, meltPlayer);

    }
}

How to Open Menus for a Player:

This can be called anywhere. Just provide the correct arguments!

MenuManager.openMenu(FreezeListMenu.class, player);

Provide the .class of the Menu Class you want to open for the player, and then provide an instance of the player to open it for.

Storing Data in the PlayerMenuUtility to be passed between Menus:

        @Override
        public void handleMenu(InventoryClickEvent e) throws MenuManagerNotSetupException, MenuManagerException {

            switch (e.getCurrentItem().getType()){
                case PLAYER_HEAD:

                    Player target = Bukkit.getPlayer(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));

                    playerMenuUtility.setData("playerToFreeze", target);

                    MenuManager.openMenu(ConfirmFreezeMenu.class, playerMenuUtility.getOwner());

                    break;
            }

        }

Retrieving Data from the PlayerMenuUtility:

    @Override
    public void handleMenu(InventoryClickEvent e) throws MenuManagerNotSetupException, MenuManagerException {

        switch (e.getCurrentItem().getType()){
            case GREEN_BANNER:

                Player target = playerMenuUtility.getData("playerToFreeze", Player.class);

                playerMenuUtility.getOwner().closeInventory();
                playerMenuUtility.getOwner().sendMessage(target.getDisplayName() + " has been frozen.");

                IcebergMenuManagerModule.getFrozenPlayers().add(target);

                break;
            case RED_BANNER:
                MenuManager.openMenu(FreezeListMenu.class, playerMenuUtility.getOwner());
                break;
        }

    }

I recommend also making an Enum to go along with your Menus that correspond to the data you will be storing in the PMC(PlayerMenuUtility), it will make it easier to remember and pass in the keys.

public enum PMUData {
    PLAYER_TO_FREEZE,
    PLAYER_TO_MELT
}

These enumerators can be passed into the PMC instead of a String key, they will be converted to a String internally.

Command Manager

Video: https://youtu.be/NFYg9Tmk-vo

Extension points exported contracts — how you extend this code

CommandList (Interface)
A functional interface used to allow the dev to specify how the listing of the subcommands on a core command works.
src/main/java/me/kodysimpson/simpapi/command/CommandList.java

Core symbols most depended-on inside this repo

notNull
called by 16
src/main/java/me/kodysimpson/simpapi/heads/SkullCreator.java
makeSlime
called by 12
src/main/java/me/kodysimpson/simpapi/region/RegionSelector.java
getSubCommands
called by 10
src/main/java/me/kodysimpson/simpapi/command/CoreCommand.java
getName
called by 6
src/main/java/me/kodysimpson/simpapi/command/SubCommand.java
makeItem
called by 6
src/main/java/me/kodysimpson/simpapi/menu/Menu.java
getWorld
called by 6
src/main/java/me/kodysimpson/simpapi/region/Region.java
reloadItems
called by 5
src/main/java/me/kodysimpson/simpapi/menu/Menu.java
translateColorCodes
called by 4
src/main/java/me/kodysimpson/simpapi/colors/ColorTranslator.java

Shape

Method 119
Class 25
Function 2
Enum 1
Interface 1

Languages

Java99%
TypeScript1%

Modules by API surface

src/main/java/me/kodysimpson/simpapi/heads/SkullCreator.java18 symbols
src/main/java/me/kodysimpson/simpapi/menu/PaginatedMenu.java17 symbols
src/main/java/me/kodysimpson/simpapi/menu/Menu.java15 symbols
src/main/java/me/kodysimpson/simpapi/region/Region.java12 symbols
src/main/java/me/kodysimpson/simpapi/conversations/ServerReloadListener.java8 symbols
src/main/java/me/kodysimpson/simpapi/menu/PlayerMenuUtility.java7 symbols
src/main/java/me/kodysimpson/simpapi/command/SubCommand.java7 symbols
src/main/java/me/kodysimpson/simpapi/region/RegionSelector.java6 symbols
src/main/java/me/kodysimpson/simpapi/config/ConfigManager.java6 symbols
src/main/java/me/kodysimpson/simpapi/menu/MenuManager.java5 symbols
src/main/java/me/kodysimpson/simpapi/input/ChatInput.java5 symbols
src/main/java/me/kodysimpson/simpapi/conversations/ArrayMatchCanceller.java5 symbols

For agents

$ claude mcp add SimpAPI \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page