From 37316238e2c6ab3c985d1a03c690349134c7fc03 Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Sun, 19 May 2024 00:53:18 -0400 Subject: [PATCH] Only get package name for 1.8 versions --- .../convo/misc/NpcOfferQuestPrompt.java | 1 - .../quests/nms/BukkitParticleProvider.java | 21 +++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/me/pikamug/quests/convo/misc/NpcOfferQuestPrompt.java b/core/src/main/java/me/pikamug/quests/convo/misc/NpcOfferQuestPrompt.java index 309b59c10..98c04f3b6 100644 --- a/core/src/main/java/me/pikamug/quests/convo/misc/NpcOfferQuestPrompt.java +++ b/core/src/main/java/me/pikamug/quests/convo/misc/NpcOfferQuestPrompt.java @@ -77,7 +77,6 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt { return ChatColor.GOLD; } } else if (number == (quests.size() + 1)) { - //return ChatColor.RED; return ChatColor.GOLD; } } diff --git a/core/src/main/java/me/pikamug/quests/nms/BukkitParticleProvider.java b/core/src/main/java/me/pikamug/quests/nms/BukkitParticleProvider.java index 54a49e28e..898d602ce 100644 --- a/core/src/main/java/me/pikamug/quests/nms/BukkitParticleProvider.java +++ b/core/src/main/java/me/pikamug/quests/nms/BukkitParticleProvider.java @@ -23,19 +23,20 @@ public abstract class BukkitParticleProvider { private static BukkitParticleProvider loaded; static { - final String internalsName = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; + final String bukkitVersion = Bukkit.getServer().getBukkitVersion().split("-")[0]; try { final String packageName = BukkitParticleProvider.class.getPackage().getName(); - if (internalsName.startsWith("v1_8_R")) { - loaded = (BukkitParticleProvider) Class.forName(packageName + ".BukkitParticleProvider_" + internalsName) - .newInstance(); + if (bukkitVersion.startsWith("1.8.")) { + final String internalsName = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; + loaded = (BukkitParticleProvider) Class.forName(packageName + ".BukkitParticleProvider_" + + internalsName).newInstance(); } else { - // Should not be an issue because single thread, alternatives welcome! + // Referencing subclass should not be an issue because single thread, alternatives welcome! loaded = new BukkitParticleProvider_Modern(); } } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException | ClassCastException exception) { - Bukkit.getLogger().severe("[Quests] No valid particle implementation for version " + internalsName); + Bukkit.getLogger().severe("[Quests] No valid particle implementation for version " + bukkitVersion); } } @@ -68,8 +69,9 @@ public abstract class BukkitParticleProvider { * packets such as block crack or particle colour on redstone / * firework particles. */ - public static void sendToPlayer(final Player player, final Location location, final String particleId, final float offsetX, final float offsetY, - final float offsetZ, final float speed, final int count, final int[] data) { + public static void sendToPlayer(final Player player, final Location location, final String particleId, + final float offsetX, final float offsetY, final float offsetZ, final float speed, + final int count, final int[] data) { final Object particle; final BukkitPreBuiltParticle pbp = BukkitPreBuiltParticle.fromIdentifier(particleId); if (pbp != null) { @@ -123,7 +125,8 @@ public abstract class BukkitParticleProvider { * @param particle * The pre-built particle. */ - public static void sendToPlayer(final Player player, final Location location, final BukkitPreBuiltParticle particle) { + public static void sendToPlayer(final Player player, final Location location, + final BukkitPreBuiltParticle particle) { final Location pos = location.clone(); if (particle.getVector() != null) { pos.add(particle.getVector());