Skip to content

Commit 9c9676a

Browse files
committed
Always register ServerResourcesReloadedEvent
1 parent 96a7014 commit 9c9676a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/PaperImplementations.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.bukkit.ChatColor;
1212
import org.bukkit.command.CommandMap;
1313
import org.bukkit.command.CommandSender;
14+
import org.bukkit.entity.Player;
1415
import org.bukkit.event.EventHandler;
1516
import org.bukkit.event.Listener;
1617
import org.bukkit.plugin.Plugin;
@@ -53,14 +54,24 @@ public PaperImplementations(boolean isPaperPresent, boolean isFoliaPresent, NMS<
5354
* @param plugin the plugin that the CommandAPI is being used from
5455
*/
5556
public void registerReloadHandler(Plugin plugin) {
56-
if (isPaperPresent && CommandAPIBukkit.getConfiguration().shouldHookPaperReload()) {
57+
if (isPaperPresent) {
5758
Bukkit.getServer().getPluginManager().registerEvents(new Listener() {
58-
5959
@EventHandler
6060
public void onServerReloadResources(ServerResourcesReloadedEvent event) {
6161
// This event is called after Paper is done with everything command related
6262
// which means we can put commands back
6363
CommandAPIBukkit.get().getCommandRegistrationStrategy().preReloadDataPacks();
64+
65+
// Normally, the reloadDataPacks() method is responsible for updating commands for
66+
// online players. If, however, datapacks aren't supposed to be reloaded upon /minecraft:reload
67+
// we have to do this manually here. This won't have any effect on Spigot and Paper version prior to
68+
// paper-1.20.6-65
69+
if (!CommandAPIBukkit.getConfiguration().shouldHookPaperReload()) {
70+
for (Player player : Bukkit.getOnlinePlayers()) {
71+
player.updateCommands();
72+
}
73+
return;
74+
}
6475
CommandAPI.logNormal("/minecraft:reload detected. Reloading CommandAPI commands!");
6576
nmsInstance.reloadDataPacks();
6677
}

0 commit comments

Comments
 (0)