bring back .selfcare it's so hard to toggle the self cares
This commit is contained in:
parent
306319e6a1
commit
e578d45490
4 changed files with 84 additions and 1 deletions
|
@ -38,6 +38,7 @@ public class CommandManager {
|
||||||
SayCommand.register(this.dispatcher);
|
SayCommand.register(this.dispatcher);
|
||||||
AutoSkinCommand.register(this.dispatcher);
|
AutoSkinCommand.register(this.dispatcher);
|
||||||
ReloadConfigCommand.register(this.dispatcher);
|
ReloadConfigCommand.register(this.dispatcher);
|
||||||
|
SelfCareCommand.register(this.dispatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executeCommand (String command) {
|
public void executeCommand (String command) {
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package land.chipmunk.chipmunkmod.commands;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.Command;
|
||||||
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
|
import land.chipmunk.chipmunkmod.modules.SelfCare;
|
||||||
|
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
import static com.mojang.brigadier.arguments.BoolArgumentType.bool;
|
||||||
|
import static com.mojang.brigadier.arguments.BoolArgumentType.getBool;
|
||||||
|
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
||||||
|
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||||
|
|
||||||
|
public class SelfCareCommand {
|
||||||
|
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||||
|
dispatcher.register(
|
||||||
|
literal("selfcare")
|
||||||
|
.then(
|
||||||
|
literal("op")
|
||||||
|
.then(
|
||||||
|
argument("boolean", bool())
|
||||||
|
.executes(m -> setSelfCare(m, "op"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
literal("gamemode")
|
||||||
|
.then(
|
||||||
|
argument("boolean", bool())
|
||||||
|
.executes(m -> setSelfCare(m, "gamemode"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
literal("cspy")
|
||||||
|
.then(
|
||||||
|
argument("boolean", bool())
|
||||||
|
.executes(m -> setSelfCare(m, "cspy"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// setSelfCare is probably not a good name for this
|
||||||
|
public static int setSelfCare (CommandContext<FabricClientCommandSource> context, String type) {
|
||||||
|
final FabricClientCommandSource source = context.getSource();
|
||||||
|
final boolean bool = getBool(context, "boolean");
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case "op" -> {
|
||||||
|
SelfCare.INSTANCE.opEnabled = bool;
|
||||||
|
source.sendFeedback(Text.literal("The op self care is now " + (bool ? "enabled" : "disabled")));
|
||||||
|
}
|
||||||
|
case "gamemode" -> {
|
||||||
|
SelfCare.INSTANCE.gamemodeEnabled = bool;
|
||||||
|
source.sendFeedback(Text.literal("The gamemode self care is now " + (bool ? "enabled" : "disabled")));
|
||||||
|
}
|
||||||
|
case "cspy" -> {
|
||||||
|
SelfCare.INSTANCE.cspyEnabled = bool;
|
||||||
|
source.sendFeedback(Text.literal("The CommandSpy self care is now " + (bool ? "enabled" : "disabled")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Command.SINGLE_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package land.chipmunk.chipmunkmod.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.SharedConstants;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(SharedConstants.class)
|
||||||
|
public class SharedConstantsMixin {
|
||||||
|
@Inject(method = "isValidChar", at = @At("HEAD"), cancellable = true)
|
||||||
|
private static void isValidChar (char chr, CallbackInfoReturnable<Boolean> cir) {
|
||||||
|
cir.setReturnValue(chr >= ' ' && chr != '\u007f');
|
||||||
|
cir.cancel();
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,7 +20,8 @@
|
||||||
"TextMixin",
|
"TextMixin",
|
||||||
"ClientConnectionInvoker",
|
"ClientConnectionInvoker",
|
||||||
"ClientConnectionAccessor",
|
"ClientConnectionAccessor",
|
||||||
"PlayerListEntryAccessor"
|
"PlayerListEntryAccessor",
|
||||||
|
"SharedConstantsMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|
Loading…
Reference in a new issue