Skip to content

Commit 386ceff

Browse files
committed
1.4.7: 1.21.11 Holograms
1 parent bf3ab80 commit 386ceff

12 files changed

Lines changed: 493 additions & 9 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
uses: softprops/action-gh-release@v2
2828
with:
2929
tag_name: "latest-1.21.11"
30-
name: "[1.4.6 for 1.21.11] Development Build"
31-
body: "Push-ly development build for Caramel. Updated on every push - ignore the 'commits to master since this release', github works weird."
30+
name: "[1.4.7 for 1.21.11] Development Build"
31+
body: "Push-ly development build for Caramel. Updated on every push - ignore the 'commits to master since this release' if you're on the latest tag."
3232
prerelease: false
3333
files: |
3434
./target/*.jar

docs/holos.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Holograms
2+
3+
Caramel holograms are lightweight wrappers around Minecraft `TextDisplay` entities, designed for easy multi-line floating text.
4+
They use holograms
5+
6+
---
7+
8+
## Creating a hologram
9+
10+
You can create a hologram either empty, or pre-filled with lines.
11+
12+
```java
13+
// Empty hologram as a base
14+
CaramelHologram hologram = new CaramelHologram();
15+
16+
// Hologram with initial lines
17+
CaramelHologram hologram = new CaramelHologram(List.of(
18+
new CaramelHologramLine(CaramelUtility.colorcomp("Hello")),
19+
new CaramelHologramLine(CaramelUtility.colorcomp("World"))
20+
));
21+
````
22+
23+
Before spawning, you **must** set a location:
24+
25+
```java
26+
hologram.setLocation(location);
27+
```
28+
29+
---
30+
31+
<br/><br/>
32+
33+
## Managing lines
34+
35+
You can fully control the hologram’s lines after creation.
36+
37+
```java
38+
hologram.addLine(new CaramelHologramLine(Component.text("New Line")));
39+
hologram.addFront(new CaramelHologramLine(Component.text("Top Line")));
40+
hologram.addBack(new CaramelHologramLine(Component.text("Bottom Line")));
41+
```
42+
43+
Removing lines:
44+
45+
```java
46+
hologram.removeLine(0); // via index
47+
hologram.removeLine(line); // via direct line object
48+
hologram.clear(); // removes all lines, keeps it spawned if it is
49+
```
50+
51+
Replacing all lines:
52+
53+
```java
54+
hologram.setLines(List.of(
55+
new CaramelHologramLine(Component.text("Replaced"))
56+
));
57+
```
58+
59+
Retrieving lines:
60+
61+
```java
62+
List<CaramelHologramLine> lines = hologram.getLines();
63+
```
64+
65+
---
66+
67+
<br/><br/>
68+
69+
## Line spacing
70+
71+
Line spacing is controlled via `lineHeight`.
72+
73+
```java
74+
hologram.setLineHeight(0.25);
75+
double spacing = hologram.getLineHeight();
76+
```
77+
78+
Values are in **world units (blocks)**, not pixels.
79+
Typical values range from `0.22` to `0.30`.
80+
81+
---
82+
83+
<br/><br/>
84+
85+
## Showing and hiding
86+
87+
Once configured, the hologram can be shown or hidden without despawning:
88+
89+
```java
90+
hologram.show();
91+
hologram.hide();
92+
```
93+
94+
* `show()` spawns the hologram if needed and makes it visible
95+
* `hide()` visually hides it without removing entities
96+
97+
---
98+
99+
<br/><br/>
100+
101+
## Updating holograms
102+
103+
If line content or formatting changes, call `update()` to reapply settings:
104+
105+
```java
106+
hologram.update();
107+
```
108+
109+
This reapplies all `CaramelHologramLine` settings to their backing `TextDisplay` entities.
110+
111+
---
112+
113+
<br/><br/>
114+
115+
## Destroying holograms
116+
117+
To fully remove the hologram and clean up entities:
118+
119+
```java
120+
hologram.destroy();
121+
```
122+
123+
This removes all spawned `TextDisplay` entities and clears internal state.
124+
125+
---
126+
127+
<br/><br/>
128+
129+
## Accessing entities
130+
131+
If you need direct access to the underlying displays:
132+
133+
```java
134+
List<TextDisplay> entities = hologram.getEntities();
135+
```
136+
137+
This can be useful for advanced effects or debugging.
138+
139+
---
140+
141+
<br/><br/>
142+
143+
## Summary
144+
145+
Typical usage flow:
146+
147+
```java
148+
CaramelHologram hologram = new CaramelHologram();
149+
hologram.setLocation(location);
150+
151+
hologram.addLine(new CaramelHologramLine(Component.text("Line 1")));
152+
hologram.addLine(new CaramelHologramLine(Component.text("Line 2")));
153+
154+
hologram.setLineHeight(0.25);
155+
hologram.show();
156+
```
157+
158+
That’s all you need for clean, stable holograms.
159+
160+
```

docs/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Caramel is a multipurpose AIO api for PaperAPI plugins. ***Caramel can not and w
99
![Not for Forge](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy/unsupported/forge_vector.svg)
1010

1111
## Quickstart
12-
- Simply drop in the latest Caramel jarfile from [here](https://github.com/klashdevelopment/Caramel/releases/tag/latest-1.21)
12+
- Simply drop in the latest Caramel jarfile from [Releases](https://github.com/klashdevelopment/Caramel/releases)
1313

1414
## Quickstart (Developer)
1515
- Make sure you have Paper API 1.21.11 in your pom
@@ -24,7 +24,7 @@ Caramel is a multipurpose AIO api for PaperAPI plugins. ***Caramel can not and w
2424
<dependency>
2525
<groupId>dev.klash</groupId>
2626
<artifactId>Caramel</artifactId>
27-
<version>1.4.6</version>
27+
<version>1.4.7</version>
2828
<scope>provided</scope>
2929
</dependency>
3030
```
@@ -41,7 +41,8 @@ Caramel has a few main features.
4141
- [Commands](https://pages.klash.dev/Caramel/commands)
4242
- [Items](https://pages.klash.dev/Caramel/items) (WIP Docs)
4343
- [Guis](https://pages.klash.dev/Caramel/guis)
44+
- [Holograms](https://pages.klash.dev/Caramel/holos)
4445
- [Currencies](https://pages.klash.dev/Caramel/currencies)
4546
- [Recipes](https://pages.klash.dev/Caramel/recipes)
4647
- [YAML Configs](https://pages.klash.dev/Caramel/configs)
47-
- [SQL Configs](https://pages.klash.dev/Caramel/sql)
48+
- [SQL Databases](https://pages.klash.dev/Caramel/sql)

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>dev.klash</groupId>
88
<artifactId>Caramel</artifactId>
9-
<version>1.4.6</version>
9+
<version>1.4.7 </version>
1010
<packaging>jar</packaging>
1111

1212
<name>Caramel</name>

src/main/java/dev/klash/caramel/Caramel.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.samjakob.spigui.SpiGUI;
44
import dev.klash.caramel.commands.CaramelCommand;
55
import dev.klash.caramel.gui.CaramelGuiList;
6+
import dev.klash.caramel.hologram.CaramelHologram;
67
import dev.klash.caramel.plugin.ImplCaramelDefault;
78
import dev.klash.caramel.recipe.CaramelRecipe;
89
import dev.klash.caramel.recipe.CaramelRecipeList;
@@ -11,6 +12,7 @@
1112
import org.bukkit.command.Command;
1213
import org.bukkit.command.CommandSender;
1314
import org.bukkit.entity.Player;
15+
import org.bukkit.entity.TextDisplay;
1416
import org.bukkit.plugin.java.JavaPlugin;
1517
import org.jetbrains.annotations.NotNull;
1618
import org.jetbrains.annotations.Nullable;
@@ -56,6 +58,11 @@ public void onEnable() {
5658
currencies.register(new ImplCaramelDefault.CaramelBaseDefaultCurrency());
5759
}
5860

61+
@Override
62+
public void onDisable() {
63+
ImplCaramelDefault.demoHolos.forEach(CaramelHologram::destroy);
64+
}
65+
5966
public CaramelRecipeList createRecipeList(CaramelRecipe... recipes) {
6067
CaramelRecipeList recipeList = new CaramelRecipeList();
6168
for(CaramelRecipe recipe : recipes) {

src/main/java/dev/klash/caramel/CaramelListening.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void onItemClick(PlayerInteractEvent event) {
2222
if(gui.finalCheck.apply(event.getPlayer())) {
2323
event.setCancelled(true);
2424
event.getPlayer().closeInventory();
25-
Bukkit.getScheduler().scheduleSyncDelayedTask(Caramel.getInstance(), () -> gui.open(event.getPlayer()), 1L);
25+
Bukkit.getRegionScheduler().runDelayed(Caramel.getInstance(), event.getPlayer().getLocation(), (st) -> gui.open(event.getPlayer()), 1L);
2626
}
2727
}
2828
}

src/main/java/dev/klash/caramel/CaramelUtility.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
import net.kyori.adventure.text.format.TextDecoration;
1515
import net.kyori.adventure.text.minimessage.MiniMessage;
1616
import org.apache.logging.log4j.util.TriConsumer;
17+
import org.bukkit.Bukkit;
1718
import org.bukkit.ChatColor;
19+
import org.bukkit.Location;
1820
import org.bukkit.Material;
1921
import org.bukkit.entity.Player;
2022
import org.bukkit.event.inventory.InventoryClickEvent;
2123
import org.bukkit.inventory.ItemStack;
24+
import org.bukkit.plugin.java.JavaPlugin;
2225

2326
import java.util.ArrayList;
2427
import java.util.Arrays;

0 commit comments

Comments
 (0)