-
-
Notifications
You must be signed in to change notification settings - Fork 3
Usage (Spigot)
There are several ways to get yourself a hologram provider
Add the plugin
as a provided
dependency
<dependency>
<groupId>io.github.projectunified</groupId>
<artifactId>uni-hologram-spigot-plugin</artifactId>
<version>VERSION</version>
<scope>provided</scope>
</dependency>
Add the plugin to the depend
list of your plugin.yml
depend:
- UniHologram
Now you can get the provider within the plugin
HologramProvider<Location> provider = JavaPlugin.getPlugin(UniHologramPlugin.class).getProvider();
Add the picker
dependency
<dependency>
<groupId>io.github.projectunified</groupId>
<artifactId>uni-hologram-spigot-picker</artifactId>
<version>VERSION</version>
</dependency>
Add the required plugins to the softdepend
list of your plugin.yml
softdepend:
- DecentHolograms
- HolographicDisplays
- CMI
- FancyHolograms
Now you can use the prepared picker to get yourself a hologram provider
HologramProvider<Location> provider = new SpigotHologramProviderPicker(plugin).pick();
In case you want only some providers but not all providers, you can make yourself a picker and let it choose the provider for you.
Add the picker
dependency
<dependency>
<groupId>io.github.projectunified</groupId>
<artifactId>uni-hologram-picker</artifactId>
<version>VERSION</version>
</dependency>
Add dependencies of the providers
<!-- Holographic Displays -->
<dependency>
<groupId>me.hsgamer</groupId>
<artifactId>uni-hologram-spigot-holographicdisplays</artifactId>
<version>VERSION</version>
</dependency>
<!-- DecentHolograms -->
<dependency>
<groupId>me.hsgamer</groupId>
<artifactId>uni-hologram-spigot-decentholograms</artifactId>
<version>VERSION</version>
</dependency>
<!-- CMI -->
<dependency>
<groupId>me.hsgamer</groupId>
<artifactId>uni-hologram-spigot-cmi</artifactId>
<version>VERSION</version>
</dependency>
<!-- Fancy Holograms -->
<dependency>
<groupId>me.hsgamer</groupId>
<artifactId>uni-hologram-spigot-fancyholograms</artifactId>
<version>VERSION</version>
</dependency>
<!-- Vanilla -->
<dependency>
<groupId>me.hsgamer</groupId>
<artifactId>uni-hologram-spigot-vanilla</artifactId>
<version>VERSION</version>
</dependency>
<!-- Check the project files for more providers -->
Add the required plugins to the softdepend
list of your plugin.yml
softdepend:
- DecentHolograms
- HolographicDisplays
- CMI
- FancyHolograms
Now, you can create a picker, add the providers and then let it pick an appropriate one
HologramProvider<Location> provider = new HologramProviderPicker<Plugin, Location>(plugin)
.add(CMIHologramProvider::isAvailable, CMIHologramProvider::new)
.add(DHHologramProvider::isAvailable, DHHologramProvider::new)
.add(FHHologramProvider::isAvailable, FHHologramProvider::new)
.add(HDHologramProvider::isAvailable, HDHologramProvider::new)
.add(() -> true, VanillaHologramProvider::new)
.pick();
When you shade the library to your plugin, it's recommended to relocate the package so that it doesn't cause conflict with other plugins
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<relocations>
<relocation>
<pattern>io.github.projectunified.unihologram</pattern>
<shadedPattern>YOUR_PACKAGE.unihologram</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
// Create & Initialize the hologram
Hologram<Location> hologram = provider.createHologram("test", location);
hologram.init(); // Important
// Hologram methods
hologram.addLine(new TextHologramLine("This is a fancy line"));
hologram.setLine(new TextHologramLine("This is another line"));
hologram.insertLine(0, new ItemHologramLine(new ItemStack(Material.STONE)));
hologram.removeLine(1);
hologram.setLines(Arrays.asList(
new ItemHologramLine(new ItemStack(Material.STONE)),
new TextHologramLine("&f&lThis is a mysterious stone"),
new TextHologramLine("&c&lYou cannot touch it")
));
// Visibility methods
if (hologram instanceof PlayerVisibility) {
PlayerVisibility visibility = (PlayerVisibility) hologram;
visibility.hideAll();
visibility.showAll();
visibility.hideTo(player);
visibility.showTo(player);
if (visibility.isVisible(player)) System.out.println("He can see the hologram");
}
// Clear/Delete the hologram
hologram.clear();