Skip to content

Genesis API

goflishMC edited this page Jul 1, 2025 · 1 revision

🧩 Genesis API – How to Use the Public API

Genesis provides a flexible and accessible public API that allows developers to interact with shops, items, conditions, and shop metadata dynamically.

This guide explains how to access and use the Genesis API in your own plugins.


πŸ› οΈ Getting Started

Step 1: Add Genesis to Your Plugin's Dependencies

If using Maven, you must shade Genesis manually or link it via plugin.yml using depend: or softdepend:.

# plugin.yml
depend: [Genesis]

Genesis does not provide a public Maven repo at this time.


Step 2: Access the Genesis Plugin Instance

Genesis exposes a singleton API class via:

GenesisAPI api = GenesisAPI.get();

From here, you can access shop managers, utilities, and various helper functions.


πŸ“š Available API Methods

πŸ” Get a Shop

Shop shop = api.getShop("WeekShop");

Returns a Shop object or null if the shop doesn't exist.


πŸ“¦ Get a Shop Item

ShopItem item = shop.getItem("Monday");

You can also get an item by its inventory location (slot index):

ShopItem item = shop.getItem(11);

🎯 Evaluate Conditions

boolean visible = item.canBeDisplayedTo(player);

Returns true if the item passes all condition checks for the specified player.


πŸ’¬ Placeholder Support

String message = api.getVariables().replaceVariables(player, "&7Hello %player%!");

This replaces placeholders in the message string for a given player.


🎁 Generate the ItemData ItemStack

ItemStack stack = item.createMenuItem(player);

This returns the actual visual item (including ItemData, placeholders, etc.) shown in the menu for a player.


πŸ’‘ Other Useful Utilities

// Open shop for a player
api.openShop(player, "WeekShop");

// Check if a shop exists
boolean exists = api.hasShop("DailyShop");

// Get all registered shop names
Set<String> allShops = api.getShopHandler().getShops().keySet();

πŸ“¦ Example: Open a Shop on Command

public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player)) return false;
    Player player = (Player) sender;
    
    GenesisAPI.get().openShop(player, "WeekShop");
    return true;
}

🧠 Notes

  • Genesis does not throw errors when shops or items are missing β€” always check for null.
  • You can reload all shops programmatically with:
    GenesisAPI.get().getShopHandler().reloadShops();

πŸ“ž Need More?

If you need hooks or events added, or you want to expose something new in the API, contact the plugin author.


Last updated: June 2025

Clone this wiki locally