forked from NLthijs48/AreaShop
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
60 additions
and
3 deletions.
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
56 changes: 56 additions & 0 deletions
56
AreaShop/src/main/java/me/wiefferink/areashop/commands/cloud/AreashopCloudCommands.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,56 @@ | ||
package me.wiefferink.areashop.commands.cloud; | ||
|
||
import com.google.inject.Inject; | ||
import com.google.inject.Injector; | ||
import com.google.inject.Singleton; | ||
import me.wiefferink.areashop.commands.CloudCommandBean; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.plugin.Plugin; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import org.incendo.cloud.SenderMapper; | ||
import org.incendo.cloud.bukkit.CloudBukkitCapabilities; | ||
import org.incendo.cloud.execution.ExecutionCoordinator; | ||
import org.incendo.cloud.paper.PaperCommandManager; | ||
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
@Singleton | ||
public class AreashopCloudCommands { | ||
|
||
private static final List<Class<? extends CloudCommandBean>> COMMAND_CLASSES = List.of( | ||
AddCommandCloud.class, | ||
AddFriendCloudCommand.class, | ||
AddSignCloudCommand.class | ||
); | ||
|
||
private final Injector injector; | ||
private final PaperCommandManager<CommandSender> commandManager; | ||
|
||
@Inject | ||
AreashopCloudCommands(@NonNull Injector injector, @NonNull Plugin plugin) { | ||
this.injector = injector; | ||
this.commandManager = new PaperCommandManager<>( | ||
plugin, | ||
ExecutionCoordinator.simpleCoordinator(), | ||
SenderMapper.identity() | ||
); | ||
} | ||
|
||
public void registerCommands() { | ||
initCommandManager(this.commandManager); | ||
for (Class<? extends CloudCommandBean> commandClass : COMMAND_CLASSES) { | ||
CloudCommandBean commandBean = injector.getInstance(commandClass); | ||
commandManager.command(commandBean); | ||
} | ||
} | ||
|
||
private static void initCommandManager(PaperCommandManager<?> commandManager) { | ||
if (commandManager.hasCapability(CloudBukkitCapabilities.NATIVE_BRIGADIER)) { | ||
commandManager.registerBrigadier(); | ||
} | ||
} | ||
|
||
|
||
|
||
} |