From 04a668da0dd99ee46d6bc7a22d8a2a3558989e21 Mon Sep 17 00:00:00 2001 From: copokbl Date: Sat, 24 Aug 2024 19:54:56 +1000 Subject: [PATCH] Fix a random bug with paper servers --- .../ServerApi/Implementations/Bukkit/BukkitServer.java | 9 ++++++++- .../ServerApi/Implementations/Folia/FoliaServer.java | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/estools/ServerApi/Implementations/Bukkit/BukkitServer.java b/src/main/java/net/estools/ServerApi/Implementations/Bukkit/BukkitServer.java index b569cb3..88d75e1 100644 --- a/src/main/java/net/estools/ServerApi/Implementations/Bukkit/BukkitServer.java +++ b/src/main/java/net/estools/ServerApi/Implementations/Bukkit/BukkitServer.java @@ -325,7 +325,14 @@ public void startEvents() { @Override public void registerCommand(String cmd, EsToolsTabCompleter tab) { - PluginCommand command = Objects.requireNonNull(Bukkit.getPluginCommand(cmd)); + PluginCommand command = Bukkit.getPluginCommand(cmd); + + if (command == null) { + Main.logger.severe("Could not register command: " + cmd + ", the server didn't let us"); + Main.logger.severe("We think this is an issue with PaperMC, consider using Spigot"); + return; + } + if (!Main.tabCompleteEnabled || command.getTabCompleter() == null) { command.setExecutor(cmdExecutor); } diff --git a/src/main/java/net/estools/ServerApi/Implementations/Folia/FoliaServer.java b/src/main/java/net/estools/ServerApi/Implementations/Folia/FoliaServer.java index 6c7546b..906b468 100644 --- a/src/main/java/net/estools/ServerApi/Implementations/Folia/FoliaServer.java +++ b/src/main/java/net/estools/ServerApi/Implementations/Folia/FoliaServer.java @@ -306,7 +306,14 @@ public void startEvents() { @Override public void registerCommand(String cmd, EsToolsTabCompleter tab) { - PluginCommand command = Objects.requireNonNull(Bukkit.getPluginCommand(cmd)); + PluginCommand command = Bukkit.getPluginCommand(cmd); + + if (command == null) { + Main.logger.severe("Could not register command: " + cmd + ", the server didn't let us"); + Main.logger.severe("We think this is an issue with PaperMC so Folia probably inherited it"); + return; + } + command.setExecutor(listener); if (Main.tabCompleteEnabled) { command.setTabCompleter(BukkitTabCompleteGenerator.generate(tab));