Skip to content

Commit

Permalink
Add Events page to API section
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre601 committed Jan 5, 2024
1 parent 7ce58b0 commit 01cb47d
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 20 deletions.
7 changes: 4 additions & 3 deletions docs/api/basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
title: Basic Usage
description: Basic examples of how to use the API of DecentHolograms

icon: material/cog
icon: material/code-json
---

The best way to use DecentHolograms API is the DHAPI class. This class was added in version 2.0.12 and is made, so that no matter what changes are made in the code or event the API, DHAPI class will stay the same changing just the implementation. Thanks to this, you can just implement a support for DecentHolograms once and will not have to change it no matter what version of DH is used. (After 2.0.12 of course)
The best way to use the DecentHolograms API is through the DHAPI class. This class was added in version 2.0.12 of the plugin and was made to offer a consistent set of methods, no matter what changes are being made to the code itself. See it as a basic interface for the more complex API structure.
Thanks to this can you implement support for DecentHologram using only this class and it will work on any version of DecentHolograms (After 2.0.12 of course).

## Using DHAPI class

Expand Down Expand Up @@ -112,7 +113,7 @@ HologramPage page = DHAPI.insertHologramPage(hologram, page, lines);
HologramPage page = DHAPI.removeHologramPage(hologram, page);
```

## More
### More

There are a lot more methods in the DHAPI. Way too many to list here.
If you would like to see some more examples here, contact us on [Discord][discord]
Expand Down
37 changes: 37 additions & 0 deletions docs/api/events.md
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.
106 changes: 104 additions & 2 deletions docs/api/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ description: How to get started with DecentHolograms' API
icon: material/cog
---

On this page, you can find how to add DecentHolograms into your plugins and use its API. Keep in mind, that you aslo need to have the DecentHolograms plugin on your server, in order for the API to work.
On this page, you can find how to add DecentHolograms into your plugins and use its API. Keep in mind, that you also need to have the DecentHolograms plugin on your server, in order for the API to work.

Latest version of the plugin can be found in Releases on the GitHub page.

## Add the API

Add the following to your build file to add the DecentHolograms API to your project.

/// tab | :simple-gradle: Gradle
```{ .groovy title="build.gradle" data-md-component="api-version" }
repositories {
maven { url = "https://jitpack.io" }
maven {
id = "jitpack"
url = "https://jitpack.io/"
}
}
depencencies {
Expand All @@ -39,4 +46,99 @@ depencencies {
</dependency>
</dependencies>
```
///

/// question | Receiving errors about NBT-API not being found?
Try adding the CodeMC repository to your build file to fix this:

//// tab | :simple-gradle: Gradle
```groovy title="build.gradle"
repositories {
// Other repositories, including jitpack
maven {
id = "codemc"
url = "https://repo.codemc.io/repositories/maven-public/"
}
}
```
////

//// tab | :simple-apachemaven: Maven
```xml
<repositories>
<!-- Other repositories, including jitpack -->
<repository>
<id>codemc</id>
<url>https://repo.codemc.io/repositories/maven-public/</url>
</repository>
</repositories>
```
////
///

## Add plugin as a (soft) dependency

DecentHolograms needs to be on your server for your plugin to be able to use the API.
To make sure that DecentHolograms is loaded before your plugin, add it as a (soft) dependency to your `plugin.yml` or `paper-plugin.yml` file:

/// tab | :simple-spigotmc: / :fontawesome-solid-paper-plane: plugin.yml
//// tab | Soft dependency
```yaml
name: 'MyPlugin'
author: 'Me'
version: '1.0.0'

main: 'com.example.plugin.MyPlugin'

softdepend:
- DecentHolograms
```
////
//// tab | Dependency
```yaml
name: 'MyPlugin'
author: 'Me'
version: '1.0.0'

main: 'com.example.plugin.MyPlugin'

depend:
- DecentHolograms
```
////
///
/// tab | :fontawesome-solid-paper-plane: paper-plugin.yml
//// tab | Soft dependency
```yaml
name: 'MyPlugin'
author: 'Me'
version: '1.0.0'

main: 'com.example.plugin.MyPlugin'

dependencies:
server:
DecentHolograms:
load: BEFORE
required: false # This is the default when not present
```
////
//// tab | Dependency
```yaml
name: 'MyPlugin'
author: 'Me'
version: '1.0.0'

main: 'com.example.plugin.MyPlugin'

dependencies:
server:
DecentHolograms:
load: BEFORE
required: true
```
////
///
22 changes: 22 additions & 0 deletions docs/assets/js/tab-sync.js
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)
28 changes: 13 additions & 15 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ icon: material/home
hide_icon: true
---

/// note | Important
Please note that this wiki is a work in progress and may be incomplete. If you find any missing information or have questions, please contact us on our Discord channel and we'll be happy to assist you.
///

## What's DecentHolograms?

DecentHolograms is a very versatile hologram plugin that offers a wide range of features and customization options, making it easy to create unique and personalized holograms.
Expand All @@ -18,14 +14,14 @@ With a user-friendly command interface, you can easily create and customize holo

## Features

- Our holograms are created entirely using packets, which eliminates the need for physical entities in your world, providing a wide range of possibilities for individual player behaviour.
- Our holograms support multiple pages, allowing you to display more information in one place.
- Our holograms are interactive, featuring a variety of click actions for added functionality.
- Our holograms feature a system for text animations, adding dynamic visual elements to each line.
- Our holograms support line offset, allowing you to position individual lines away from the center of the parent hologram.
- Our holograms feature a permission system, allowing you to restrict access to specific holograms or lines for certain players.
- Our holograms include preset features such as damage and heal displays, providing ready-to-use functionality for your server.
- And so much more...
- Holograms are completely packed-based, eliminating the need for physical entities in your world, improving performance on the server while providing a wide range of possibilities for individual per-player behaviour.
- Holograms support multiple pages, allowing you to display more information in a single place.
- Holograms are interacive, allowing multiple click actions to be added for extended functionality.
- Holograms offer a system for text animations, allowing dynamic visual elements for each line.
- Holograms support per-line offsets, allowing you to shift the line's center away from the hologram itself.
- Holograms allow permissions to set who can and can't see it. This works for the whole hologram, specific pages or even specific lines.
- Pre-made features such as damage and healing displays are available, providing ready-to-use functionalities for your server.
- And a lot more...

## Useful link

Expand All @@ -34,10 +30,12 @@ If you need assistance or have any inquiries, please feel free to reach out to u
We also welcome bug reports and suggestions on both our Discord and our GitHub repository.

/// warning | Official downloads
Please note that the **only official downloads** can be found on our Spigot page and our GitHub repository!
Any other site sharing DecentHologram jar files does so without our consent and may even share harmful malware and/or exploits.
Official downloads of DecentHolograms are only provided through its Spigot Page, GitHub Repository and the Discord Server.

Any other site offering downloads for DecentHolograms does so without or knowledge nor our endorsement or support.
Please do **not** download from such sites! They may contain changes that could add malware to your server or contain expoits and/or backdoors that could harm your server.

**Only download from the Spigot Page or GitHub repository!**
**Only download the plugin from its original sources as mentioned above!**
///

- [:simple-spigotmc: SpigotMC Page](https://www.spigotmc.org/resources/96927/){ target="_blank" rel="noreferral" }
Expand Down
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extra_css:

extra_javascript:
- 'assets/js/github-release.js'
- 'assets/js/tab-sync.js'

plugins:
- search
Expand Down Expand Up @@ -126,5 +127,6 @@ nav:
- API:
- api/get-started.md
- api/basic-usage.md
- api/events.md
- Spigot: 'http://decentholograms.eu/'
- Discord: 'https://discord.decentsoftware.eu/'

0 comments on commit 01cb47d

Please sign in to comment.