Skip to content

Commit

Permalink
Use Paper-specific API to fetch CommandMap when available
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed May 15, 2024
1 parent fa7bd11 commit 3d0892d
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package com.sk89q.bukkit.util;

import com.sk89q.util.ReflectionUtil;
import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand Down Expand Up @@ -92,7 +93,7 @@ public CommandMap getCommandMap() {
return fallbackCommands;
}

CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap");
CommandMap commandMap = PaperLib.isPaper() ? Bukkit.getCommandMap() : ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap");
if (commandMap == null) {
Bukkit.getServer().getLogger().severe(plugin.getDescription().getName()
+ ": Could not retrieve server CommandMap, using fallback instead!");
Expand Down

0 comments on commit 3d0892d

Please sign in to comment.