Files
TiedUp-/src/main/java/com/tiedup/remake/commands/subcommands/GagCommands.java
NotEvil c1e1f56058 refactor: split BondageSubCommand 1207L → 5 focused files (UC-01)
- BindCommands.java: tie, untie (156L)
- GagCommands.java: gag, ungag (140L)
- BlindfoldCommands.java: blindfold, unblind (142L)
- CollarCommands.java: collar, takecollar, enslave, free (288L)
- AccessoryCommands.java: putearplugs, takeearplugs, putclothes,
  takeclothes, fullyrestrain, adjust (469L)
- BondageSubCommand.java: thin delegator (19L)

Zero logic changes — purely mechanical code move.
2026-04-15 11:09:48 +02:00

141 lines
4.4 KiB
Java

package com.tiedup.remake.commands.subcommands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.tiedup.remake.commands.CommandHelper;
import com.tiedup.remake.core.SystemMessageManager;
import com.tiedup.remake.v2.bondage.datadriven.DataDrivenBondageItem;
import net.minecraft.resources.ResourceLocation;
import com.tiedup.remake.state.PlayerBindState;
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 net.minecraft.world.item.ItemStack;
@SuppressWarnings("null")
public class GagCommands {
public static void register(LiteralArgumentBuilder<CommandSourceStack> root) {
// /tiedup gag <player>
root.then(
Commands.literal("gag")
.requires(CommandHelper.REQUIRES_OP)
.then(
Commands.argument(
"player",
EntityArgument.player()
).executes(GagCommands::gag)
)
);
// /tiedup ungag <player>
root.then(
Commands.literal("ungag")
.requires(CommandHelper.REQUIRES_OP)
.then(
Commands.argument(
"player",
EntityArgument.player()
).executes(GagCommands::ungag)
)
);
}
static int gag(CommandContext<CommandSourceStack> context)
throws CommandSyntaxException {
ServerPlayer targetPlayer = EntityArgument.getPlayer(context, "player");
PlayerBindState state = PlayerBindState.getInstance(targetPlayer);
if (state == null) {
context
.getSource()
.sendFailure(Component.literal("Failed to get player state"));
return 0;
}
if (state.isGagged()) {
context
.getSource()
.sendFailure(
Component.literal(
targetPlayer.getName().getString() +
" is already gagged"
)
);
return 0;
}
ItemStack gag = DataDrivenBondageItem.createStack(new ResourceLocation("tiedup", "cloth_gag"));
state.putGagOn(gag);
CommandHelper.syncPlayerState(targetPlayer, state);
context
.getSource()
.sendSuccess(
() ->
Component.literal(
"\u00a7a" +
targetPlayer.getName().getString() +
" has been gagged"
),
true
);
SystemMessageManager.sendGagged(
context.getSource().getEntity(),
targetPlayer
);
return 1;
}
static int ungag(CommandContext<CommandSourceStack> context)
throws CommandSyntaxException {
ServerPlayer targetPlayer = EntityArgument.getPlayer(context, "player");
PlayerBindState state = PlayerBindState.getInstance(targetPlayer);
if (state == null) {
context
.getSource()
.sendFailure(Component.literal("Failed to get player state"));
return 0;
}
if (!state.isGagged()) {
context
.getSource()
.sendFailure(
Component.literal(
targetPlayer.getName().getString() + " is not gagged"
)
);
return 0;
}
state.takeGagOff();
CommandHelper.syncPlayerState(targetPlayer, state);
context
.getSource()
.sendSuccess(
() ->
Component.literal(
"\u00a7a" +
targetPlayer.getName().getString() +
"'s gag has been removed"
),
true
);
SystemMessageManager.sendToTarget(
context.getSource().getEntity(),
targetPlayer,
SystemMessageManager.MessageCategory.UNGAGGED
);
return 1;
}
}