Skip to content

Commit

Permalink
Update IFeature.java
Browse files Browse the repository at this point in the history
  • Loading branch information
AV306 authored Oct 26, 2023
1 parent b2e0441 commit 61d9c82
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/me/av306/xenon/feature/IFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import me.av306.xenon.event.MinecraftClientEvents;
import me.av306.xenon.util.text.TextFactory;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
//import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import com.mojang.brigadier.tree.LiteralCommandNode;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
Expand Down Expand Up @@ -99,7 +100,7 @@ protected IFeature( String name, int key, String... aliases )
// Register aliases as Brigadier command redirects
ClientCommandRegistrationCallback.EVENT.register(
(dispatcher, registryAccess) ->
dispatcher.register( ClientCommandManager.literal( alias ).redirect( this.commandNode ) )
dispatcher.register( literal( alias ).redirect( this.commandNode ) )
);
}
}
Expand Down Expand Up @@ -154,12 +155,18 @@ protected IFeature( String name, int key )
(dispatcher, registryAccess) ->
{
this.commandNode = dispatcher.register(
ClientCommandManager.literal( name )
literal( name )
.executes( context ->
{
context.getSource().sendFeedback( TextFactory.createLiteral( "Executed command for " + name ) );
return 1;
} )
.then( literal( "enable" ).executes( context -> this.enable() ) ) // Enable feature
.then( literal( "e" ).redirect( "enable" ) ) // Enable alias
.then( literal( "disable" ).executes( context -> this.disable() ) // Disable feature
.then( literal( "d" ).redirect( "disable" ) // Disable alias
//.then( literal( "set" ).then( TODO: config change command

);
}
);
Expand Down

0 comments on commit 61d9c82

Please sign in to comment.