All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.hsgamer.unihologram.spigot.SpigotHologramProvider Maven / Gradle / Ivy

There is a newer version: 2.5.0
Show newest version
package me.hsgamer.unihologram.spigot;

import me.hsgamer.unihologram.common.api.Hologram;
import me.hsgamer.unihologram.common.api.HologramProvider;
import me.hsgamer.unihologram.spigot.decentholograms.provider.DHHologramProvider;
import me.hsgamer.unihologram.spigot.holographicdisplays.provider.HDHologramProvider;
import me.hsgamer.unihologram.spigot.vanilla.provider.VanillaHologramProvider;
import org.bukkit.Location;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import java.util.Optional;

/**
 * A hologram provider for Spigot.
 * It will use the best provider available.
 */
public class SpigotHologramProvider implements HologramProvider {
    private final HologramProvider provider;

    /**
     * Create a new hologram provider
     *
     * @param plugin the plugin
     */
    public SpigotHologramProvider(Plugin plugin) {
        if (DHHologramProvider.isAvailable()) {
            provider = new DHHologramProvider();
        } else if (HDHologramProvider.isAvailable()) {
            provider = new HDHologramProvider(plugin);
        } else {
            provider = new VanillaHologramProvider(plugin);
        }
    }

    /**
     * Create a new hologram provider
     */
    public SpigotHologramProvider() {
        this(JavaPlugin.getProvidingPlugin(SpigotHologramProvider.class));
    }

    @Override
    public @NotNull Hologram createHologram(@NotNull String name, @NotNull Location location) {
        return provider.createHologram(name, location);
    }

    @Override
    public Optional> getHologram(@NotNull String name) {
        return provider.getHologram(name);
    }

    @Override
    public Collection> getAllHolograms() {
        return provider.getAllHolograms();
    }

    @Override
    public boolean isLocal() {
        return provider.isLocal();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy