Updated Basic tutorial (markdown)

filoghost 2022-06-04 19:01:36 +02:00
parent 5e5c58a3ac
commit 434db83e24

@ -53,30 +53,30 @@ public void onEnable() {
 
## 3) Start using the API
The API is a class called HologramsAPI, all the methods are static. With the method `createHologram(...)` you can create a hologram with some lines. The method returns the hologram just created.
The main API class is HolographicDisplaysAPI. With the method `createHologram(...)` you can create a hologram with some lines. The method returns the hologram just created.
Example:
```java
Plugin plugin = ... // Your plugin's instance
Location where = ... // A Location object
Hologram hologram = HologramsAPI.createHologram(plugin, where);
textLine = hologram.appendTextLine("A hologram line");
Hologram hologram = HolographicDisplaysAPI.createHologram(plugin, where);
TextHologramLine textLine = hologram.getLines().appendText("A hologram line");
```
Done! With just two lines of code you created a hologram. The TextLine object represents the line you added: it can be used to retrieve and modify the content of that line. Inserting a line before won't change its content: the TextLine is not related to the position of line inside the hologram.
Done! With just two lines of code you created a hologram. The TextHologramLine object represents the line you added: it can be used to retrieve and modify the content of that line.
 
## 4) Return types
Before reading further tutorials, you should be aware that when you append or insert a line, an object is returned:
``` java
TextLine textLine1 = hologram.appendTextLine("...");
TextLine textLine2 = hologram.insertTextLine(0, "...");
TextHologramLine textLine1 = hologram.getLines().appendText("...");
TextHologramLine textLine2 = hologram.getLines().insertText(0, "...");
ItemLine itemLine1 = hologram.appendItemLine(new ItemStack(Material.STONE));
ItemLine itemLine2 = hologram.insertItemLine(0, new ItemStack(Material.STONE));
ItemHologramLine itemLine1 = hologram.getLines().appendItem(new ItemStack(Material.STONE));
ItemHologramLine itemLine2 = hologram.getLines().insertItem(0, new ItemStack(Material.STONE));
```
 
## 5) What to do now?
If you think this tutorial is enough, you may want to read the [javadocs API documentation](https://ci.codemc.io/job/filoghost/job/HolographicDisplays/javadoc/index.html?com/gmail/filoghost/holographicdisplays/api/HologramsAPI.html).
The most relevant classes are ```HologramsAPI``` and the interface ```Hologram```.
If you think this tutorial is enough, you may want to read the [javadocs API documentation](https://ci.codemc.io/job/filoghost/job/HolographicDisplays/javadoc/me/filoghost/holographicdisplays/api/HolographicDisplaysAPI.html).
The most relevant classes are ```HolographicDisplaysAPI``` and the interface ```Hologram```.