From ac00261afb8a76c99c6841d2e936ac36ea4e70fb Mon Sep 17 00:00:00 2001 From: Jikoo Date: Thu, 12 May 2022 12:18:18 -0400 Subject: [PATCH] Note Spigot requirement --- .../main/java/com/lishid/openinv/OpenInv.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/plugin/src/main/java/com/lishid/openinv/OpenInv.java b/plugin/src/main/java/com/lishid/openinv/OpenInv.java index 238b5a2..3ad4f5c 100644 --- a/plugin/src/main/java/com/lishid/openinv/OpenInv.java +++ b/plugin/src/main/java/com/lishid/openinv/OpenInv.java @@ -112,6 +112,7 @@ public class OpenInv extends JavaPlugin implements IOpenInv { private InternalAccessor accessor; private LanguageManager languageManager; + private boolean isSpigot = false; /** * Evicts all viewers lacking cross-world permissions from a Player's inventory. @@ -355,8 +356,16 @@ public class OpenInv extends JavaPlugin implements IOpenInv { this.languageManager = new LanguageManager(this, "en_us"); + try { + Class.forName("org.bukkit.entity.Player$Spigot"); + isSpigot = true; + } catch (ClassNotFoundException e) { + e.printStackTrace(); + isSpigot = false; + } + // Version check - if (this.accessor.isSupported()) { + if (isSpigot && this.accessor.isSupported()) { // Update existing configuration. May require internal access. new ConfigUpdater(this).checkForUpdates(); @@ -379,8 +388,16 @@ public class OpenInv extends JavaPlugin implements IOpenInv { } private void sendVersionError(Consumer messageMethod) { - messageMethod.accept("Your server version (" + this.accessor.getVersion() + ") is not supported."); - messageMethod.accept("Please obtain an appropriate version here: " + accessor.getReleasesLink()); + if (!this.accessor.isSupported()) { + messageMethod.accept("Your server version (" + this.accessor.getVersion() + ") is not supported."); + messageMethod.accept("Please obtain an appropriate version here: " + this.accessor.getReleasesLink()); + } + if (!isSpigot) { + messageMethod.accept("OpenInv requires that you use Spigot or a Spigot fork. Per the 1.14 update thread"); + messageMethod.accept("(https://www.spigotmc.org/threads/369724/ \"A Note on CraftBukkit\"), if you are"); + messageMethod.accept("encountering an inconsistency with vanilla that prevents you from using Spigot,"); + messageMethod.accept("that is considered a Spigot bug and should be reported as such."); + } } private void setCommandExecutor(CommandExecutor executor, String... commands) { @@ -394,7 +411,7 @@ public class OpenInv extends JavaPlugin implements IOpenInv { @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { - if (!this.accessor.isSupported()) { + if (!isSpigot || !this.accessor.isSupported()) { this.sendVersionError(sender::sendMessage); return true; }