-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/java/spigey/asteroide/commands/CommandBlockCommand.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,35 @@ | ||
package spigey.asteroide.commands; | ||
|
||
import com.mojang.brigadier.arguments.StringArgumentType; | ||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import meteordevelopment.meteorclient.commands.Command; | ||
import meteordevelopment.meteorclient.systems.config.Config; | ||
import meteordevelopment.meteorclient.utils.player.ChatUtils; | ||
import net.minecraft.command.CommandSource; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.text.Text; | ||
|
||
import static com.mojang.brigadier.Command.SINGLE_SUCCESS; | ||
import static meteordevelopment.meteorclient.MeteorClient.mc; | ||
import static spigey.asteroide.util.CommandBlock; | ||
|
||
public class CommandBlockCommand extends Command { | ||
public CommandBlockCommand() { | ||
super("cmdblock", "Gives you a command block with the specified command inside"); | ||
} | ||
|
||
@Override | ||
public void build(LiteralArgumentBuilder<CommandSource> builder) { | ||
builder.executes(context -> { | ||
error("You have to specify a command! F.e: " + Config.get().prefix.get() + "cmdblock /say Asteroide on Crack!"); // .cmdblock /say Asteroide on Crack! | ||
return SINGLE_SUCCESS; | ||
}); | ||
builder.then(argument("command", StringArgumentType.greedyString()).executes(context -> { | ||
if(!mc.player.getAbilities().creativeMode){error("You need to be in creative mode to use this command!"); return SINGLE_SUCCESS;} | ||
if(!mc.player.hasPermissionLevel(4)){error("You're missing the permission level '§f4§c', you can most likely not place the command block!");} | ||
ChatUtils.sendMsg(Text.of("§fReceiving command block with command '§7" + StringArgumentType.getString(context,"command") + "§f'.")); | ||
CommandBlock(Items.COMMAND_BLOCK, StringArgumentType.getString(context, "command"), 1); | ||
return SINGLE_SUCCESS; | ||
})); | ||
} | ||
} |