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.
This commit is contained in:
@@ -0,0 +1,288 @@
|
||||
package com.tiedup.remake.commands.subcommands;
|
||||
|
||||
import com.tiedup.remake.network.ModNetwork;
|
||||
import com.tiedup.remake.network.sync.PacketSyncBindState;
|
||||
import com.tiedup.remake.v2.bondage.CollarHelper;
|
||||
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 CollarCommands {
|
||||
|
||||
public static void register(LiteralArgumentBuilder<CommandSourceStack> root) {
|
||||
// /tiedup collar <player>
|
||||
root.then(
|
||||
Commands.literal("collar")
|
||||
.requires(CommandHelper.REQUIRES_OP)
|
||||
.then(
|
||||
Commands.argument(
|
||||
"player",
|
||||
EntityArgument.player()
|
||||
).executes(CollarCommands::collar)
|
||||
)
|
||||
);
|
||||
// /tiedup takecollar <player>
|
||||
root.then(
|
||||
Commands.literal("takecollar")
|
||||
.requires(CommandHelper.REQUIRES_OP)
|
||||
.then(
|
||||
Commands.argument(
|
||||
"player",
|
||||
EntityArgument.player()
|
||||
).executes(CollarCommands::takecollar)
|
||||
)
|
||||
);
|
||||
// /tiedup enslave <player>
|
||||
root.then(
|
||||
Commands.literal("enslave")
|
||||
.requires(CommandHelper.REQUIRES_OP)
|
||||
.then(
|
||||
Commands.argument(
|
||||
"player",
|
||||
EntityArgument.player()
|
||||
).executes(CollarCommands::enslave)
|
||||
)
|
||||
);
|
||||
// /tiedup free <player>
|
||||
root.then(
|
||||
Commands.literal("free")
|
||||
.requires(CommandHelper.REQUIRES_OP)
|
||||
.then(
|
||||
Commands.argument(
|
||||
"player",
|
||||
EntityArgument.player()
|
||||
).executes(CollarCommands::free)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
static int collar(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.hasCollar()) {
|
||||
context
|
||||
.getSource()
|
||||
.sendFailure(
|
||||
Component.literal(
|
||||
targetPlayer.getName().getString() +
|
||||
" already has a collar"
|
||||
)
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ItemStack collar = com.tiedup.remake.v2.bondage.datadriven.DataDrivenBondageItem.createStack(new net.minecraft.resources.ResourceLocation("tiedup", "classic_collar"));
|
||||
|
||||
if (context.getSource().getEntity() instanceof ServerPlayer executor) {
|
||||
CollarHelper.addOwner(collar, executor);
|
||||
}
|
||||
|
||||
state.putCollarOn(collar);
|
||||
|
||||
CommandHelper.syncPlayerState(targetPlayer, state);
|
||||
|
||||
context
|
||||
.getSource()
|
||||
.sendSuccess(
|
||||
() ->
|
||||
Component.literal(
|
||||
"\u00a7a" +
|
||||
targetPlayer.getName().getString() +
|
||||
" has been collared"
|
||||
),
|
||||
true
|
||||
);
|
||||
SystemMessageManager.sendToTarget(
|
||||
context.getSource().getEntity(),
|
||||
targetPlayer,
|
||||
SystemMessageManager.MessageCategory.COLLARED
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int takecollar(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.hasCollar()) {
|
||||
context
|
||||
.getSource()
|
||||
.sendFailure(
|
||||
Component.literal(
|
||||
targetPlayer.getName().getString() +
|
||||
" does not have a collar"
|
||||
)
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
state.takeCollarOff();
|
||||
CommandHelper.syncPlayerState(targetPlayer, state);
|
||||
|
||||
context
|
||||
.getSource()
|
||||
.sendSuccess(
|
||||
() ->
|
||||
Component.literal(
|
||||
"\u00a7a" +
|
||||
targetPlayer.getName().getString() +
|
||||
"'s collar has been removed"
|
||||
),
|
||||
true
|
||||
);
|
||||
SystemMessageManager.sendToTarget(
|
||||
context.getSource().getEntity(),
|
||||
targetPlayer,
|
||||
SystemMessageManager.MessageCategory.UNCOLLARED
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int enslave(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;
|
||||
}
|
||||
|
||||
// First fully restrain
|
||||
if (!state.isTiedUp()) {
|
||||
ItemStack ropes = DataDrivenBondageItem.createStack(new ResourceLocation("tiedup", "ropes"));
|
||||
state.putBindOn(ropes);
|
||||
}
|
||||
if (!state.isGagged()) {
|
||||
ItemStack gag = DataDrivenBondageItem.createStack(new ResourceLocation("tiedup", "cloth_gag"));
|
||||
state.putGagOn(gag);
|
||||
}
|
||||
if (!state.isBlindfolded()) {
|
||||
ItemStack blindfold = DataDrivenBondageItem.createStack(new ResourceLocation("tiedup", "classic_blindfold"));
|
||||
state.putBlindfoldOn(blindfold);
|
||||
}
|
||||
if (!state.hasCollar()) {
|
||||
ItemStack collar = com.tiedup.remake.v2.bondage.datadriven.DataDrivenBondageItem.createStack(new net.minecraft.resources.ResourceLocation("tiedup", "classic_collar"));
|
||||
if (
|
||||
context.getSource().getEntity() instanceof ServerPlayer executor
|
||||
) {
|
||||
CollarHelper.addOwner(collar, executor);
|
||||
}
|
||||
state.putCollarOn(collar);
|
||||
}
|
||||
if (!state.hasEarplugs()) {
|
||||
ItemStack earplugs = DataDrivenBondageItem.createStack(new ResourceLocation("tiedup", "classic_earplugs"));
|
||||
state.putEarplugsOn(earplugs);
|
||||
}
|
||||
|
||||
// Capture target (this makes them a captive)
|
||||
if (context.getSource().getEntity() instanceof ServerPlayer master) {
|
||||
PlayerBindState masterState = PlayerBindState.getInstance(master);
|
||||
if (masterState != null && masterState.getCaptorManager() != null) {
|
||||
masterState.getCaptorManager().addCaptive(state);
|
||||
}
|
||||
}
|
||||
|
||||
CommandHelper.syncPlayerState(targetPlayer, state);
|
||||
|
||||
context
|
||||
.getSource()
|
||||
.sendSuccess(
|
||||
() ->
|
||||
Component.literal(
|
||||
"\u00a7a" +
|
||||
targetPlayer.getName().getString() +
|
||||
" has been enslaved"
|
||||
),
|
||||
true
|
||||
);
|
||||
SystemMessageManager.sendEnslaved(
|
||||
context.getSource().getEntity(),
|
||||
targetPlayer
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int free(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.isCaptive()) {
|
||||
context
|
||||
.getSource()
|
||||
.sendFailure(
|
||||
Component.literal(
|
||||
targetPlayer.getName().getString() + " is not captured"
|
||||
)
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
state.free(true);
|
||||
|
||||
PacketSyncBindState statePacket = PacketSyncBindState.fromPlayer(
|
||||
targetPlayer
|
||||
);
|
||||
if (statePacket != null) {
|
||||
ModNetwork.sendToPlayer(statePacket, targetPlayer);
|
||||
}
|
||||
|
||||
context
|
||||
.getSource()
|
||||
.sendSuccess(
|
||||
() ->
|
||||
Component.literal(
|
||||
"\u00a7a" +
|
||||
targetPlayer.getName().getString() +
|
||||
" has been freed from slavery"
|
||||
),
|
||||
true
|
||||
);
|
||||
SystemMessageManager.sendFreed(targetPlayer);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user