#
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, and hologram plugins—by implementing dedicated hook classes.
#
Hook Types
There are three primary hook types you can implement:
#
PlaceholderHook
PlaceholderHook
is used to support external placeholder plugins and handle dynamic placeholder replacement.
#
Basic Structure
public class CustomPlaceHolderHook extends PlaceholderHook {
@Override
public String formatPlaceholders(Player player, String message) {
// Perform placeholder replacements here
return message;
}
}
#
Example: PlaceholderAPI hook
public class PlaceholderAPIHook extends PlaceholderHook {
@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 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 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);
}
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);
}
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);
}
}
}
#
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, and support for hologram display plugins.
🧪 Want to contribute more hooks? Feel free to fork the plugin and submit PRs via GitHub!