-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
182 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
title: Events | ||
description: Custom Events offered by DecentHolograms | ||
|
||
icon: material/text-long | ||
--- | ||
|
||
|
||
DecentHolograms offers a collection of Events, all being triggered during specific situations. | ||
To use these events, add them to your plugin like you would with any other event provided by the Server. | ||
|
||
## DecentHologramsEvent | ||
|
||
This is the most basic event. All other events extend from it and it can be used as a catch-all for any DecentHolograms-based events. | ||
It's recommended to use the more specific events, but if you want to use this one, it is recommended to do `instanceof` checks and casting to more specific Event instances to use possible getters. | ||
|
||
This event does not offer any methods outside the default ones from the Server. | ||
|
||
## DecentHologramsReloadEvent | ||
|
||
This event is called whenever DecentHolograms is being reloaded through its [`/dh reload`](../general/commands/general.md#dh-reload) command. | ||
This is useful for when your plugin needs to be aware of any reloads by DecentHolograms (i.e. to refresh own holograms added or other special cases). | ||
|
||
This event does not offer any methods outside the default ones from the Server. | ||
|
||
## HologramClickEvent | ||
|
||
This event is called whenever a player is interacting with a hologram by left or right clicking it. | ||
The event is cancellable, allowing you to stop any further handling of it. | ||
|
||
The event offers the following methods: | ||
|
||
- `getPlayer()` - Gets the Player that clicked the hologram. | ||
- `getHologram()` - Gets the hologram that has been clicked. | ||
- `getHologramPage()` - Gets the HologramPage that has been clicked. | ||
- `getClickType()` - Gets the click type (Whether it was left or right click and whether the player sneaked while clicking). | ||
- `getEntityId()` - Gets the ID of the clicked entity. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const tabSync = () => { | ||
const tabs = document.querySelectorAll(".tabbed-set > input") | ||
for (const tab of tabs) { | ||
tab.addEventListener("click", () => { | ||
const current = document.querySelector(`label[for=${tab.id}]`) | ||
const pos = current.getBoundingClientRect().top | ||
const labelContent = current.innerHTML | ||
const labels = document.querySelectorAll('.tabbed-set > label, .tabbed-alternate > .tabbed-labels > label ') | ||
for (const label of labels) { | ||
if (label.innerHTML === labelContent) { | ||
document.querySelector(`input[id=${label.getAttribute('for')}]`).checked = true | ||
} | ||
} | ||
|
||
// Preserve scroll position | ||
const delta = (current.getBoundingClientRect().top) - pos | ||
window.scrollBy(0, delta) | ||
}) | ||
} | ||
} | ||
|
||
document$.subscribe(tabSync) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters