mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-12-29 11:57:58 +01:00
more hologram stuff
This commit is contained in:
parent
95288fd8b0
commit
a5a855787d
@ -4,6 +4,7 @@ import com.songoda.core.library.hologram.holograms.Hologram;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -15,15 +16,17 @@ public class HologramManager {
|
||||
/**
|
||||
* Load all supported hologram plugins. <br />
|
||||
* Note: This method should be called in your plugin's onEnable() section
|
||||
*
|
||||
* @param javaPlugin the plugin owning the holograms
|
||||
*/
|
||||
public static void load() {
|
||||
public static void load(JavaPlugin javaPlugin) {
|
||||
if (!registeredHolograms.isEmpty()) return;
|
||||
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
|
||||
for (HologramType type : HologramType.values()) {
|
||||
if (pluginManager.isPluginEnabled(type.plugin)) {
|
||||
Hologram holo = type.getInstance();
|
||||
Hologram holo = type.getInstance(javaPlugin);
|
||||
registeredHolograms.put(type, holo);
|
||||
if (defaultHolo == null)
|
||||
defaultHolo = holo;
|
||||
|
@ -1,18 +1,16 @@
|
||||
package com.songoda.core.library.hologram;
|
||||
|
||||
import com.songoda.core.library.economy.economies.Economy;
|
||||
import com.songoda.core.library.economy.economies.PlayerPointsEconomy;
|
||||
import com.songoda.core.library.economy.economies.ReserveEconomy;
|
||||
import com.songoda.core.library.economy.economies.VaultEconomy;
|
||||
import com.songoda.core.library.hologram.holograms.Hologram;
|
||||
import com.songoda.core.library.hologram.holograms.HolographicDisplaysHologram;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public enum HologramType {
|
||||
|
||||
VAULT("HolographicDisplays", HolographicDisplaysHologram.class);
|
||||
HOLOGRAPHIC_DISPLAYS("HolographicDisplays", HolographicDisplaysHologram.class);
|
||||
|
||||
public final String plugin;
|
||||
protected final Class managerClass;
|
||||
@ -22,10 +20,10 @@ public enum HologramType {
|
||||
this.managerClass = managerClass;
|
||||
}
|
||||
|
||||
protected Hologram getInstance() {
|
||||
protected Hologram getInstance(JavaPlugin javaPlugin) {
|
||||
try {
|
||||
return (Hologram) managerClass.newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException ex) {
|
||||
return (Hologram) managerClass.getDeclaredConstructor(JavaPlugin.class).newInstance(javaPlugin);
|
||||
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Unexpected Error while creating a new Hologram Manager for " + name(), ex);
|
||||
}
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user