Custom Elevator Hooks

Elevators provides a flexible system for extending plugin compatibility and functionality through hooks. Hooks allow you to integrate with external plugins—such as placeholder, protection, custom-item, and hologram plugins—by implementing dedicated hook classes.

Elevator Hooks have a built in method that will be called after hook registration. This method is especially useful if a desired action should be ran after the hook is registered, such as for Item Hooks.

@Override
public void onInit() {
}

Hook Types

There are four primary hook types you can implement:

Hook Type Purpose
PlaceholderHook Integrates with placeholder plugins like PlaceholderAPI
ProtectionHook Integrates with protection plugins like GriefDefender or WorldGuard
HologramHook Integrates with hologram plugins like FancyHolograms for in-world displays
ItemHook Integrates with custom item plugins like Oraxen for item recipe support

PlaceholderHook

PlaceholderHook is used to support external placeholder plugins and handle dynamic placeholder replacement.

Basic Structure

public class CustomPlaceHolderHook extends PlaceholderHook {

	@Override
	public void onInit() {
	}

    @Override
    public String formatPlaceholders(Player player, String message) {
        // Perform placeholder replacements here
        return message;
    }
}

Example: PlaceholderAPI hook

public class PlaceholderAPIHook extends PlaceholderHook {

	@Override
	public void onInit() {
	}

    @Override
    public String formatPlaceholders(Player player, String message) {
        return PlaceholderAPI.setPlaceholders(player, message);
    }
}

ProtectionHook

ProtectionHook allows you to integrate with protection plugins and control who can interact with and use elevators.

Basic Structure

public class CustomHook extends ProtectionHook {

	public CustomHook() {
		super("PluginName") // The key provided to the superclass is what will be used in the Config. Ideally use the plugin name that you are hooking into.
	}

	@Override
	public void onInit() {
	}

    @Override
    public boolean canPlayerUseElevator(Player player, Elevator elevator, boolean sendMessage) {
        // Logic to determine if the player can use this elevator. Please do not send player messages when sendMessage is false.
    }

    @Override
    public boolean canEditName(Player player, Elevator elevator, boolean sendMessage) {
        // Logic for renaming elevator floors
    }

    @Override
    public boolean canEditSettings(Player player, Elevator elevator, boolean sendMessage) {
        // Logic for editing elevator settings
    }

    @Override
    public ItemStack createIconForElevator(Player player, Elevator elevator) {
        // Creates the icon displayed in the Elevator Menu
    }

    @Override
    public void onProtectionClick(Player player, Elevator elevator, Runnable onReturn) {
        // What happens when the protection icon is clicked in the Elevator Menu. Call onReturn when finished to re-display the Elevator menu.
    }
}

Example: GriefDefender Hook

public class GriefDefenderHook extends ProtectionHook {

    public GriefDefenderHook() {
        super("GriefDefender");
    }

	@Override
	public void onInit() {
	}

    @Override
    public boolean canPlayerUseElevator(Player player, Elevator elevator, boolean sendMessage) {
        final Claim claim = GriefDefender.getCore().getClaimAt(elevator.getLocation());
        if (claim == null || claim.isWilderness())
            return true;

        return claim.canUseBlock(elevator.getShulkerBox(), elevator.getLocation(),
            GriefDefender.getCore().getUser(player.getUniqueId()), TrustTypes.ACCESSOR);
    }

    @Override
    public boolean canEditName(Player player, Elevator elevator, boolean sendMessage) {
        final Claim claim = GriefDefender.getCore().getClaimAt(elevator.getLocation());
        if (claim == null)
            return true;

        if (claim.isWilderness())
            return true;

        return claim.canUseBlock(elevator.getShulkerBox(), elevator.getLocation(),
            GriefDefender.getCore().getUser(player.getUniqueId()), TrustTypes.ACCESSOR);
    }

    @Override
    public boolean canEditSettings(Player player, Elevator elevator, boolean sendMessage) {
        final Claim claim = GriefDefender.getCore().getClaimAt(elevator.getLocation());
        if (claim == null)
            return true;

        if (claim.isWilderness())
            return true;

        return claim.canUseBlock(elevator.getShulkerBox(), elevator.getLocation(),
            GriefDefender.getCore().getUser(player.getUniqueId()), TrustTypes.MANAGER);
    }

    @Override
    public ItemStack createIconForElevator(Player player, Elevator elevator) {
        final Claim claim = GriefDefender.getCore().getClaimAt(elevator.getLocation());
        if (claim == null || claim.isWilderness())
            return null;

        boolean flagEnabled = this.isCheckEnabled(elevator);

        List<String> lore = new ArrayList<>();
        lore.add("");
        lore.add(ChatColor.GRAY + "Controls whether claim");
        lore.add(ChatColor.GRAY + "guests are blocked from");
        lore.add(ChatColor.GRAY + "using this Elevator.");
        lore.add("");
        lore.add(ChatColor.GRAY + "Status: ");
        lore.add(flagEnabled ? (ChatColor.GREEN + "" + ChatColor.BOLD + "ENABLED") : (ChatColor.RED + "" + ChatColor.BOLD + "DISABLED"));

        return ItemStackHelper.createItem(ChatColor.GOLD + "" + ChatColor.BOLD + "Grief Defender", Material.SHIELD, 1, lore);
    }

    @Override
    public void onProtectionClick(Player player, Elevator elevator, Runnable onReturn) {
        this.toggleCheckEnabled(elevator);
        onReturn.run();
    }
}

HologramHook

A HologramHook integrates with external hologram plugins to display floating text above elevators.

Basic Structure

public class CustomHologramHook extends HologramHook {

    @Override
    public WrappedHologram createHologram(Elevator elevator, String... lines) {
        return new CustomWrappedHologram(elevator, lines);
    }

	@Override
	public void onInit() {
	}

    public static class CustomWrappedHologram extends WrappedHologram {

        public CustomWrappedHologram(Elevator elevator, String... lines) {
            super(elevator);
            // Initialize your hologram here
        }

        @Override
        public void addLine(String text) {
            // Add a line to your hologram
        }

        @Override
        public void setLines(List<String> text) {
            // Set all lines in the hologram
        }

        @Override
        public double getHeight() {
            // Return the height of the hologram
            return 0;
        }

        @Override
        public void teleportTo(Location location) {
            // Move the hologram to a new location
        }

        @Override
        public void onDelete() {
            // Remove and clean up the hologram
        }
    }
}

Example: FancyHolograms Integration

public class FancyHologramsHook extends HologramHook {

    @Override
    public WrappedHologram createHologram(Elevator elevator, String... lines) {
        return new FancyHologramWrapper(elevator, lines);
    }

	@Override
	public void onInit() {
	}

    public static class FancyHologramWrapper extends WrappedHologram {

        private final Hologram hologram;

        public FancyHologramWrapper(Elevator elevator, String... lines) {
            super(elevator);

            TextHologramData textData = new TextHologramData(this.getUUID(), elevator.getLocation().clone());
            Arrays.stream(lines).forEach(textData::addLine);

            textData.setBillboard(Display.Billboard.CENTER);
            textData.setPersistent(false);

            this.hologram = FancyHologramsPlugin.get().getHologramManager().create(textData);
            FancyHologramsPlugin.get().getHologramManager().addHologram(this.hologram);
        }

        @Override
        public void addLine(String text) {
            TextHologramData data = (TextHologramData) this.hologram.getData();
            List<String> hologramText = new ArrayList<>(data.getText());
            hologramText.add(text);
            data.setText(hologramText);
            this.hologram.queueUpdate();
        }

        @Override
        public void setLines(List<String> text) {
            TextHologramData data = (TextHologramData) this.hologram.getData();
            data.setText(text);
            this.hologram.queueUpdate();
        }

        @Override
        public double getHeight() {
            return ((TextHologramData) this.hologram.getData()).getScale().y();
        }

        @Override
        public void teleportTo(Location location) {
            this.hologram.getData().setLocation(location);
            this.hologram.queueUpdate();
        }

        @Override
        public void onDelete() {
            FancyHologramsPlugin.get().getHologramManager().removeHologram(this.hologram);
        }
    }
}

ItemHook

ItemHook is used to support custom item plugins and handle items in elevator recipes.

Basic Structure

public class CustomPlaceHolderHook extends ItemsHook {

    @Override
    public void onInit() {
    }

    @Override
    public ItemStack createItemStackFromKey(NamespacedKey key) {
		// Return an ItemStack based on a provided NamespacedKey. You can return null.
    }

    @Override
    public NamespacedKey getKeyFromItemStack(ItemStack item) {
		// Return a Namespaced Key based on a provided ItemStack. You can return null.
    }
}

Example: Oraxen Hook

public class OraxenHook extends ItemsHook {

    @Override
    public void onInit() {
        Elevators.log("Oraxen has been hooked. Reloading recipes for Oraxen support");
        Elevators.pushLog();
        ElevatorRecipeService.refreshRecipes();
        Elevators.popLog();
    }

    @Override
    public ItemStack createItemStackFromKey(NamespacedKey key) {
        if(!key.getKey().equalsIgnoreCase("oraxen"))
            return null;

        Optional<ItemBuilder> itemBuilder = OraxenItems.getOptionalItemById(key.getNamespace());
        return itemBuilder.map(ItemBuilder::build).orElse(null);
    }

    @Override
    public NamespacedKey getKeyFromItemStack(ItemStack item) {
        String key = OraxenItems.getIdByItem(item);
        if(key == null)
            return null;

        return new NamespacedKey(key, "oraxen");
    }

}

Summary

By implementing these hooks, you can ensure that Elevators fully integrates with a server’s plugin ecosystem. This enables dynamic placeholder expansion, respect for region protection, custom items in recipes, and support for hologram display plugins.

🧪 Want to contribute more hooks? Feel free to fork the plugin and submit PRs via GitHub!