-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add non-reflection provider for syncCommands
On 1.21.4+ Player#updateCommands has the same logic as CraftServer#updateCommands, so we can just use that.
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...s/BaseProviders/src/main/java/net/ess3/provider/providers/ModernSyncCommandsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package net.ess3.provider.providers; | ||
|
||
import net.ess3.provider.SyncCommandsProvider; | ||
import net.essentialsx.providers.ProviderData; | ||
import net.essentialsx.providers.ProviderTest; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
|
||
@ProviderData(description = "1.21.4+ Sync Commands Provider", weight = 1) | ||
public class ModernSyncCommandsProvider implements SyncCommandsProvider { | ||
@Override | ||
public void syncCommands() { | ||
for (final Player player : Bukkit.getOnlinePlayers()) { | ||
player.updateCommands(); | ||
} | ||
} | ||
|
||
@ProviderTest | ||
public static boolean test() { | ||
try { | ||
// There isn't a real good way to test this, but we can check if the Creaking class exists. | ||
Class.forName("org.bukkit.entity.Creaking"); | ||
return true; | ||
} catch (final Throwable ignored) { | ||
return false; | ||
} | ||
} | ||
} |