fabric: Implement FabricClientCommandManager
This commit is contained in:
parent
f16cafda3f
commit
31d1f85830
31 changed files with 275 additions and 66 deletions
|
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// MIT License
|
||||
//
|
||||
// Copyright (c) 2021 Alexander Söderberg & Contributors
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
package cloud.commandframework.fabric.testmod;
|
||||
|
||||
import cloud.commandframework.arguments.standard.StringArgument;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.fabric.FabricClientCommandManager;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class FabricClientExample implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
final FabricClientCommandManager<FabricClientCommandSource> commandManager =
|
||||
FabricClientCommandManager.createNative(CommandExecutionCoordinator.simpleCoordinator());
|
||||
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder("cloud_client")
|
||||
.literal("say")
|
||||
.argument(StringArgument.greedy("message"))
|
||||
.handler(ctx -> ctx.getSender().sendFeedback(
|
||||
Text.of("Cloud client commands says: " + ctx.get("message"))
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,9 @@
|
|||
"entrypoints": {
|
||||
"main": [
|
||||
"cloud.commandframework.fabric.testmod.FabricExample"
|
||||
],
|
||||
"client": [
|
||||
"cloud.commandframework.fabric.testmod.FabricClientExample"
|
||||
]
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue