crefity

When a player stands on a specific block, a DeluxeMenus INVENTORY GUI should automatically open. If the player closes the menu using ESC (without selecting any option), they are teleported to a predefined location.

Kodari AI
KodariJun 4 at 10:50 pm 9
BlockMenuTrigger
Automatically opens a configured DeluxeMenus GUI when a player steps on a specific block type or location. Tracks whether the player made a selection inside the menu — if they close it via ESC without clicking anything, they are instantly teleported to a predefined location. Includes per-player cooldowns to prevent spam-opening, and fully configurable trigger block, menu name, and teleport destination.

Plan:

  1. ConfigManager — loads trigger block, menu name, teleport location, cooldown

  2. BlockStandListener — PlayerMoveEvent, opens DeluxeMenus via console command, tracks active players

  3. MenuTracker — shared state: who entered via trigger, who clicked

  4. MenuCloseListener — InventoryClickEvent + InventoryCloseEvent, ESC detection + teleport

  5. BlockMenuPlugin — wires everything together

  6. plugin.yml + config.yml



Here’s how the plugin works:

Trigger detection — BlockStandListener fires on PlayerMoveEvent but only when the player crosses a block boundary (skips sub-block movements). It checks the block one unit below the player’s feet, matching either a material type or a specific XYZ location depending on trigger.mode.

ESC detection — MenuCloseListener tracks two things: whether the inventory that closed belongs to the configured DeluxeMenus menu (matched via title), and whether the player clicked anything inside it. If the inventory closes with no click recorded → ESC was used → teleport fires on the next tick (delayed to avoid Bukkit close-event conflicts).

Config notes:

  • Set menu.title to exactly match the menu_title: value in your DeluxeMenus .yml file — this is how ESC is distinguished from clicking an action that closes the menu.

  • mode: location is useful when you have one special pressure-plate or beacon block at a fixed coordinate rather than every block of that type.

  • cooldown-seconds prevents re-triggering while the player stands still on the block.

crefity

does it have a reload feature

Kodari AI
KodariJun 4 at 10:56 pm 8

No reload command. ConfigManager has the reload() method internally but nothing exposes it. Adding /blockmenu reload now.

Now I need to verify MenuTracker has a clearAll() method:

Done. Here’s what was added:

  • /blockmenu reload — reloads config.yml and clears all player tracking state (triggered, clicked, cooldowns). This means any player mid-interaction gets a clean slate with the new config values.

  • Permission: blockmenu.reload (console always has access)

  • clearAll() was added to MenuTracker so no stale state carries over after a reload

crefity

can you build the plugin so i can download the updated one

Kodari AI
KodariJun 4 at 10:57 pm 3

I can’t build the plugin directly in this environment — there’s no Gradle/Maven setup mounted. However, you can build it yourself in seconds:

Option 1 — Let Kodari generate the full buildable ZIP If you paste your project’s build.gradle here I can verify everything is wired correctly and confirm it compiles.

Option 2 — Build it yourself (30 seconds)

  1. Make sure you have Java 17+ and Gradle installed

  2. In your project root, run:

Shell
./gradlew build
  1. The JAR will be at:

Plain Text
build/libs/BlockMenuTrigger-1.0.jar

Your build.gradle should include:

Groovy
dependencies {
    compileOnly 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
}

DeluxeMenus is a soft-depend so no compile dependency needed — the plugin opens menus via Bukkit.dispatchCommand() which requires zero imports from DeluxeMenus.

If you share your build.gradle or tell me what server version you’re targeting, I can finalize the full file and make sure everything is correct before you build.

crefity

nothing is happening when player steps on block

Kodari AI
KodariJun 4 at 11:03 pm 4

Found the bug. Line 50 in BlockStandListener:

Java
Block below = to.getBlock().getRelative(0, -1, 0);

to.getBlock() gets the block at the player’s feet (same Y), then goes one below — but the player is already standing on top of that block, so their feet block IS the trigger block. The -1 skips it entirely and checks the block underneath instead.

Fix: check the block at the player’s feet directly, not one below.

Root cause: Players stand on top of blocks, so their feet occupy Y+1 above the block surface. The old code went one level too deep and was checking the block below the trigger block — meaning it would only have fired if you dug a hole and stood inside it.

Also double-check your config.yml:

  • trigger.mode: type and trigger.type: must match the exact block name (e.g. STONE, GOLD_BLOCK, EMERALD_BLOCK)

  • menu.name: must exactly match the filename inside DeluxeMenus’ menus/ folder (no .yml)

  • menu.title: must exactly match the menu_title: in that DeluxeMenus file, including color codes

crefity

how does it know which players menu to open

Kodari AI
KodariJun 4 at 11:03 pm 2

It uses the DeluxeMenus console command on line 68:

Plain Text
deluxemenus open <menu_name> <player_name>

This is run as the console sender with the player’s name appended, so DeluxeMenus opens that specific menu for that specific player — no ambiguity. Each move event fires per-player, so every player stepping on the block gets their own command dispatched with their own name.

This means:

  • ✅ Multiple players can trigger it simultaneously

  • ✅ No DeluxeMenus API imports needed — purely command-based

  • ✅ Works with any DeluxeMenus version

The only requirement is that the menu.name in your config.yml exactly matches the menu filename in DeluxeMenus’ menus/ folder (without .yml).

crefity

it says "could not find menu"

Kodari AI
KodariJun 4 at 11:18 pm 3

The command format is correct, so the issue is almost certainly a menu name mismatch. “Could not find menu” is DeluxeMenus’ own error when the name passed doesn’t match any loaded menu.

Check these in order:

  1. Exact filename match — if your file is menus/my_menu.yml, your config.yml must have:

    YAML
    menu:
      name: my_menu
    

    No .yml, no extra spaces, case-sensitive.

  2. Menu is actually loaded — run /dm list in-game. If your menu doesn’t appear in that list, DeluxeMenus hasn’t loaded it. Either move the file into the correct menus/ folder or run /dm reload.

  3. Plugin load order — if DeluxeMenus hasn’t finished loading when BlockMenuTrigger starts, it won’t find the menu. Add this to plugin.yml:

depend: DeluxeMenus is already there, so load order isn’t the issue. This is a name mismatch. Run /dm list and copy the menu name exactly as it appears there into your config.yml menu.name field — then do /blockmenu reload.

crefity

it works however when esc out it does not teleport player

Kodari AI
KodariJun 4 at 11:20 pm 3

The logic looks correct, so the issue is the title check failing — isTriggerMenu() returns false so the close event exits early without teleporting.

event.getView().getTitle() returns the rendered title (with color codes applied), but your config.yml menu.title probably has & color codes that Bukkit converts to § at runtime.

Fix: strip/convert both sides before comparing.

Also verify in your config.yml that menu.title matches the menu_title: in your DeluxeMenus file exactly — including & color codes and spacing. For example:

YAML
# config.yml
menu:
  title: "&8Select an Option"

# DeluxeMenus menu file
menu_title: '&8Select an Option'

If you’re unsure of the exact title, you can leave menu.title blank — the plugin will then skip the title check entirely and match any inventory close, which is fine if players only open one menu at a time via the block trigger.

crefity

LOCATION works but type is still not working

Kodari AI
KodariJun 4 at 11:23 pm 4

Found it. In location mode the trigger checks below.getY() == trigger.getBlockY() — but triggerLocation is built from the config coords directly (e.g. Y=64), which is the surface block. That matches correctly.

In type mode however, to.getBlock() returns the block at the player’s feet level (Y) — which is air (the player stands in air on top of the block). The fix from last time only removed the -1 but the player’s feet are still in air. The trigger block is actually one below the player’s feet.

The location mode worked because you set the Y to the exact block coordinate. For type mode we need getRelative(0, -1, 0) back — but only for type mode.

Root cause: type and location modes need different Y references:

  • location mode — you set the Y in config to match the block’s actual Y coordinate, so checking to.getBlock() (feet level) was accidentally correct for your setup.

  • type mode — the player’s feet are always in air one block above the surface, so we must go getRelative(0, -1, 0) to reach the block they’re standing on.

Now both modes check the right block independently.

crefity

could you now make it integrated with worldedit plugin so i can select a selection that makes it open the menu

Kodari AI
KodariJun 4 at 11:31 pm 24

Here’s the plan:

  1. Add region mode to ConfigManager — stores a saved cuboid (min/max corners)

  2. Add /blockmenu setregion command — reads the admin’s WorldEdit wand selection and saves it to config

  3. Update BlockStandListener — check if player is inside the saved cuboid when mode is region

  4. Update plugin.yml — add softdepend: [WorldEdit] and new command usage

  5. Update config.yml — add region section

Workflow for you: Select a region with the WorldEdit wand (//pos1, //pos2), then run /blockmenu setregion. Anyone who walks into that box gets the menu.

Now I have everything I need. Implementing all changes:

Now update ConfigManager to support region mode:

Now update BlockStandListener for region mode, and update BlockMenuPlugin for the setregion command:

Now update the main plugin class to handle /blockmenu setregion:

Done. Here’s how to use it:

Setup:

  1. Make sure WorldEdit is installed on your server

  2. Use your WorldEdit wand — //pos1 and //pos2 to mark the two corners of your region

  3. Run /blockmenu setregion — the plugin saves the cuboid to config.yml and switches mode to region automatically

How it works:

  • Any player who walks into the saved cuboid gets the menu opened

  • Stepping out and back in respects the cooldown like normal

  • The region is persisted in config.yml so it survives restarts

  • /blockmenu reload still works to reload everything

You can also manually set the region in config.yml under trigger.region with mode: region if you prefer coordinates over the wand.

crefity

great work

Kodari AI
KodariJun 4 at 11:38 pm 2

Thanks! If you need anything else — new features, bug fixes, or a fresh plugin — just ask. 🚀

crefity

can you make custom guis for itemsadder?

Kodari AI
KodariJun 4 at 11:41 pm 3

Before building anything, a few quick questions to make sure I build exactly what you need:

  1. What kind of custom GUIs?

    • Textured backgrounds — GUIs that use ItemsAdder’s font/resource pack system to render a custom image as the inventory background (shift characters in the title)

    • ItemsAdder items as buttons — GUIs that display custom ItemsAdder items (NAMESPACEID:item_id) as clickable buttons

    • Both — textured background + custom items inside

  2. What should the GUIs do? (e.g. shop, player profile, upgrades, cosmetics, etc.)

  3. Do you already have ItemsAdder items/textures set up in your resource pack, or do you need example namespace/item IDs stubbed in as placeholders?

crefity

textured background for /buy

Kodari AI
KodariJun 4 at 11:41 pm 6

I have everything I need. I’ll create a standalone /buy GUI plugin with a textured ItemsAdder background, using TexturedInventoryWrapper.

A few things to confirm before I build:

  1. What namespace:id is your font image for the GUI background in ItemsAdder? (e.g. myshop:buy_gui_background)

  2. How many rows should the inventory be? (1–6 rows, most shop GUIs use 6 = 54 slots)

  3. What items/buttons go inside? (e.g. categories, specific items to buy, or just a placeholder for now)

  4. Economy plugin — Vault, PlayerPoints, CoinsEngine, or something else?

Once you answer these I’ll build the full plugin with the textured GUI, /buy command, click handling, and purchase logic.

Kodari can make mistakes. Review important code before using.
Files
src
Code
7 515
src/main/java/com/kodari/blockmenu/BlockMenuPlugin.java
package com.kodari.blockmenu;

import com.kodari.blockmenu.listener.BlockStandListener;
import com.kodari.blockmenu.listener.MenuCloseListener;
import com.kodari.blockmenu.manager.ConfigManager;
import com.kodari.blockmenu.manager.MenuTracker;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class BlockMenuPlugin extends JavaPlugin {

    private ConfigManager configManager;
    private MenuTracker menuTracker;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        this.configManager = new ConfigManager(this);
        this.menuTracker = new MenuTracker();

        getServer().getPluginManager().registerEvents(new BlockStandListener(this, configManager, menuTracker), this);
        getServer().getPluginManager().registerEvents(new MenuCloseListener(this, configManager, menuTracker), this);

        getLogger().info("BlockMenuTrigger enabled.");
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!command.getName().equalsIgnoreCase("blockmenu")) return false;
        if (!sender.hasPermission("blockmenu.reload")) {
            sender.sendMessage(ChatColor.RED + "You don't have permission to do that.");
            return true;
        }
        if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
            configManager.reload();
            menuTracker.clearAll();
            sender.sendMessage(ChatColor.GREEN + "[BlockMenuTrigger] Config reloaded.");
            return true;
        }
        if (args.length == 1 && args[0].equalsIgnoreCase("setregion")) {
            if (!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.RED + "Only players can use setregion.");
                return true;
            }
            if (getServer().getPluginManager().getPlugin("WorldEdit") == null) {
                sender.sendMessage(ChatColor.RED + "WorldEdit is not installed.");
                return true;
            }
            Player player = (Player) sender;
            try {
                LocalSession session = WorldEdit.getInstance().getSessionManager()
                        .get(BukkitAdapter.adapt(player));
                Region region = session.getSelection(BukkitAdapter.adapt(player.getWorld()));
                BlockVector3 min = region.getMinimumPoint();
                BlockVector3 max = region.getMaximumPoint();
                configManager.saveRegion(
                        player.getWorld(),
                        min.getBlockX(), min.getBlockY(), min.getBlockZ(),
                        max.getBlockX(), max.getBlockY(), max.getBlockZ()
                );
                menuTracker.clearAll();
                sender.sendMessage(ChatColor.GREEN + "[BlockMenuTrigger] Region saved! "
                        + ChatColor.YELLOW + "(" + min.getBlockX() + "," + min.getBlockY() + "," + min.getBlockZ()
                        + ") to (" + max.getBlockX() + "," + max.getBlockY() + "," + max.getBlockZ() + ")");
            } catch (IncompleteRegionException e) {
                sender.sendMessage(ChatColor.RED + "No WorldEdit selection found. Use //pos1 and //pos2 first.");
            }
            return true;
        }
        sender.sendMessage(ChatColor.YELLOW + "Usage: /blockmenu reload | setregion");
        return true;
    }

    @Override
    public void onDisable() {
        getLogger().info("BlockMenuTrigger disabled.");
    }
}