From 5afe6799fee944c90f0f32641dff81dd6b6175b9 Mon Sep 17 00:00:00 2001 From: jascotty2 Date: Wed, 4 Sep 2019 08:06:46 -0500 Subject: [PATCH] fix hologram load error, classloader errors for missing hooks --- src/main/java/com/songoda/core/hooks/PluginHook.java | 5 ++++- .../java/com/songoda/core/hooks/holograms/Holograms.java | 6 +++--- .../songoda/core/hooks/holograms/HologramsHolograms.java | 4 ++-- .../core/hooks/holograms/HolographicDisplaysHolograms.java | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/songoda/core/hooks/PluginHook.java b/src/main/java/com/songoda/core/hooks/PluginHook.java index ddd0210a..f131d57f 100644 --- a/src/main/java/com/songoda/core/hooks/PluginHook.java +++ b/src/main/java/com/songoda/core/hooks/PluginHook.java @@ -55,9 +55,12 @@ public final class PluginHook { hooks.put(handler, this); // Does this class have a plugin constructor? try { - pluginConstructor = type.getDeclaredConstructor(Plugin.class); + pluginConstructor = handler.getDeclaredConstructor(Plugin.class); } catch (NoSuchMethodException | SecurityException ex) { // nope! + } catch (Throwable t) { + // (can also reach here if there is a class loader exception) + hooks.remove(handler); } } diff --git a/src/main/java/com/songoda/core/hooks/holograms/Holograms.java b/src/main/java/com/songoda/core/hooks/holograms/Holograms.java index 2384666e..de6f94af 100644 --- a/src/main/java/com/songoda/core/hooks/holograms/Holograms.java +++ b/src/main/java/com/songoda/core/hooks/holograms/Holograms.java @@ -2,7 +2,7 @@ package com.songoda.core.hooks.holograms; import com.songoda.core.hooks.Hook; import org.bukkit.Location; -import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.plugin.Plugin; import java.util.Collections; import java.util.List; @@ -13,9 +13,9 @@ public abstract class Holograms implements Hook { protected double yOffset = 0.5; protected double zOffset = 0.5; - protected final JavaPlugin plugin; + protected final Plugin plugin; - public Holograms(JavaPlugin plugin) { + public Holograms(Plugin plugin) { this.plugin = plugin; } diff --git a/src/main/java/com/songoda/core/hooks/holograms/HologramsHolograms.java b/src/main/java/com/songoda/core/hooks/holograms/HologramsHolograms.java index a446bb0d..724339db 100644 --- a/src/main/java/com/songoda/core/hooks/holograms/HologramsHolograms.java +++ b/src/main/java/com/songoda/core/hooks/holograms/HologramsHolograms.java @@ -6,7 +6,7 @@ import com.sainttx.holograms.api.line.HologramLine; import com.sainttx.holograms.api.line.TextLine; import java.util.HashSet; import org.bukkit.Location; -import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.plugin.Plugin; import java.util.List; import org.bukkit.Bukkit; @@ -16,7 +16,7 @@ public class HologramsHolograms extends Holograms { HologramPlugin hologramPlugin; HashSet ourHolograms = new HashSet(); - public HologramsHolograms(JavaPlugin plugin) { + public HologramsHolograms(Plugin plugin) { super(plugin); hologramPlugin = (HologramPlugin) Bukkit.getPluginManager().getPlugin("Holograms"); } diff --git a/src/main/java/com/songoda/core/hooks/holograms/HolographicDisplaysHolograms.java b/src/main/java/com/songoda/core/hooks/holograms/HolographicDisplaysHolograms.java index e3fbde13..5db0bf27 100644 --- a/src/main/java/com/songoda/core/hooks/holograms/HolographicDisplaysHolograms.java +++ b/src/main/java/com/songoda/core/hooks/holograms/HolographicDisplaysHolograms.java @@ -3,13 +3,13 @@ package com.songoda.core.hooks.holograms; import com.gmail.filoghost.holographicdisplays.api.Hologram; import com.gmail.filoghost.holographicdisplays.api.HologramsAPI; import org.bukkit.Location; -import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.plugin.Plugin; import java.util.List; public class HolographicDisplaysHolograms extends Holograms { - public HolographicDisplaysHolograms(JavaPlugin plugin) { + public HolographicDisplaysHolograms(Plugin plugin) { super(plugin); }