Skip to content

Commit

Permalink
Removed Service provider api
Browse files Browse the repository at this point in the history
  • Loading branch information
Mqzn committed Sep 17, 2024
1 parent a028290 commit 2294bc7
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions bukkit/src/main/java/dev/velix/imperat/BukkitImperat.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicePriority;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -99,35 +97,17 @@ private AdventureProvider<CommandSender> loadAdventure(@Nullable AdventureProvid
* @param plugin the plugin
* @param audienceProvider the kyori adventure audience provider
* @param permissionResolver the permission resolver
* @param override whether to override the existing instance in the bukkit server
* or just use an already existing instance in the server loaded
* from any other plugin
* @return the new or existing bukkit command dispatcher instance in the bukkit server
*/
public static BukkitImperat create(
@NotNull Plugin plugin,
@Nullable AdventureProvider<CommandSender> audienceProvider,
@NotNull PermissionResolver<BukkitSource> permissionResolver,
boolean override
@NotNull PermissionResolver<BukkitSource> permissionResolver
) {
Preconditions.notNull(plugin, "plugin");
RegisteredServiceProvider<BukkitImperat> provider =
Bukkit.getServicesManager().getRegistration(BukkitImperat.class);
if (provider == null || override) {
BukkitImperat dispatcher = new BukkitImperat(plugin, audienceProvider, permissionResolver);
Bukkit.getServicesManager().register(BukkitImperat.class, dispatcher, plugin, ServicePriority.Normal);
return dispatcher;
}
return provider.getProvider();
return new BukkitImperat(plugin, audienceProvider, permissionResolver);
}

public static BukkitImperat create(
@NotNull Plugin plugin,
@Nullable AdventureProvider<CommandSender> audienceProvider,
@NotNull PermissionResolver<BukkitSource> permissionResolver
) {
return create(plugin, audienceProvider, permissionResolver, false);
}

public static BukkitImperat create(Plugin plugin, @Nullable AdventureProvider<CommandSender> audienceProvider) {
return create(plugin, audienceProvider, DEFAULT_PERMISSION_RESOLVER);
Expand Down

0 comments on commit 2294bc7

Please sign in to comment.