Skip to content

Commit

Permalink
add player argument to skill command
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Jul 21, 2024
1 parent 42f159d commit 582364c
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import de.teamlapen.vampirism.util.RegUtil;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.NotNull;
Expand All @@ -33,16 +34,20 @@ public class SkillCommand extends BasicCommand {
return builder.requires(context -> context.hasPermission(PERMISSION_LEVEL_ADMIN))
.then(Commands.argument("type", SkillArgument.skills())
.executes(context -> skill(context.getSource(), context.getSource().getPlayerOrException(), SkillArgument.getSkill(context, "type"), false))
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> skill(context.getSource(), EntityArgument.getPlayer(context, "player"), SkillArgument.getSkill(context, "type"), false))
.then(Commands.literal("force")
.executes(context -> skill(context.getSource(), EntityArgument.getPlayer(context, "player"), SkillArgument.getSkill(context, "type"), true))))
.then(Commands.literal("force")
.executes(context -> skill(context.getSource(), context.getSource().getPlayerOrException(), SkillArgument.getSkill(context, "type"), true))))
.then(Commands.literal("disableall")
.executes(context -> {
return disableall(context.getSource(), context.getSource().getPlayerOrException());
}))
.executes(context -> disableall(context.getSource(), context.getSource().getPlayerOrException()))
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> disableall(context.getSource(), EntityArgument.getPlayer(context, "player")))))
.then(Commands.literal("enableall")
.executes(context -> {
return enableAll(context.getSource(), context.getSource().getPlayerOrException());
}));
.executes(context -> enableAll(context.getSource(), context.getSource().getPlayerOrException()))
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> enableAll(context.getSource(), EntityArgument.getPlayer(context, "player")))));
}

private static int disableall(@NotNull CommandSourceStack commandSource, @NotNull ServerPlayer asPlayer) throws CommandSyntaxException {
Expand Down

0 comments on commit 582364c

Please sign in to comment.