Еще недавно мог юзать это Player player = args.<Player>getOne("player").get();. Теперь выбивает ошибку.
Player player = args.<Player>getOne("player").get();
[Server thread/ERROR] [Sponge]: Error occurred while executing command 'metaclear Mr_Krab' for source EntityPlayerMP['Mr_Krab'/769, l='world', x=635,63, y=74,00, z=-564,78]: No value present java.util.NoSuchElementException: No value present at java.util.Optional.get(Optional.java:135) ~[?:1.8.0_171] at mr_krab.beancore.Main$1.execute(Main.java:499) ~[Main$1.class:?] at org.spongepowered.api.command.spec.CommandSpec.process(CommandSpec.java:388) ~[CommandSpec.class:1.12.2-2705-7.1.0-BETA-3358] at org.spongepowered.api.command.dispatcher.SimpleDispatcher.process(SimpleDispatcher.java:341) ~[SimpleDispatcher.class:1.12.2-2705-7.1.0-BETA-3358] at org.spongepowered.common.command.SpongeCommandManager.process(SpongeCommandManager.java:329) [SpongeCommandManager.class:1.12.2-2705-7.1.0-BETA-3358] at net.minecraft.command.ServerCommandManager.func_71556_a(SourceFile:1083) [dh.class:?] at net.minecraft.network.NetHandlerPlayServer.func_147361_d(NetHandlerPlayServer.java:958) [pa.class:?] at net.minecraft.network.NetHandlerPlayServer.func_147354_a(NetHandlerPlayServer.java:937) [pa.class:?] at net.minecraft.network.play.client.CPacketChatMessage.func_148833_a(SourceFile:37) [la.class:?] at net.minecraft.network.play.client.CPacketChatMessage.func_148833_a(SourceFile:9) [la.class:?] at org.spongepowered.common.network.PacketUtil.onProcessPacket(PacketUtil.java:92) [PacketUtil.class:1.12.2-2705-7.1.0-BETA-3358] at net.minecraft.network.PacketThreadUtil$1.redirect$onProcessPacket$zld000(SourceFile:539) [hv$1.class:?] at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) [hv$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_171] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_171] at net.minecraft.util.Util.func_181617_a(SourceFile:46) [h.class:?] at org.spongepowered.common.SpongeImplHooks.onUtilRunTask(SpongeImplHooks.java:293) [SpongeImplHooks.class:1.12.2-2705-7.1.0-BETA-3358] at net.minecraft.server.MinecraftServer.redirect$onRun$zji000(MinecraftServer.java:3963) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:723) [MinecraftServer.class:?] at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:396) [nz.class:?] at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]
На строке 499 приведенный выше код.
Как добавляешь этот аргумент?
admin
CommandSpec command = CommandSpec.builder() .permission("перм") .arguments(GenericArguments.onlyOne(GenericArguments.player(Text.of("игрок")))) .executor(new CommandExecutor() { @Override public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { Player player = args.<Player>getOne("player").get(); //Тут операция над игроком return CommandResult.success(); } }) .build();
Кажись понял где шибка(но это не точно), ща проверю.
Тьфу, точно. (GenericArguments.player(Text.of("player")))) надо писать, а не то чего я намудрил для большего понимания команды помощниками. Вопрос закрыт. PS В заголовке опечатался, а изменить не могу.
(GenericArguments.player(Text.of("player"))))