mirror of
https://code.chipmunk.land/ChomeNS/chipmunkmod.git
synced 2026-03-31 04:22:05 +00:00
Compare commits
No commits in common. "dda3b525a03153c769138554835c3a8a382f3858" and "590b954c306283edaf2649f5a72eff4fea82c8bf" have entirely different histories.
dda3b525a0
...
590b954c30
8 changed files with 7 additions and 90 deletions
|
|
@ -39,7 +39,6 @@ public class CommandManager {
|
||||||
ReloadConfigCommand.register(this.dispatcher);
|
ReloadConfigCommand.register(this.dispatcher);
|
||||||
SelfCareCommand.register(this.dispatcher);
|
SelfCareCommand.register(this.dispatcher);
|
||||||
PrefixCommand.register(this.dispatcher);
|
PrefixCommand.register(this.dispatcher);
|
||||||
AutoPrefixCommand.register(this.dispatcher);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LiteralArgumentBuilder<FabricClientCommandSource> literal (final String name) {
|
public static LiteralArgumentBuilder<FabricClientCommandSource> literal (final String name) {
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
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.network.chat.Component;
|
|
||||||
|
|
||||||
import static com.mojang.brigadier.arguments.StringArgumentType.*;
|
|
||||||
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
|
||||||
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
|
||||||
|
|
||||||
|
|
||||||
public class AutoPrefixCommand {
|
|
||||||
public static void register (final CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
|
||||||
dispatcher.register(
|
|
||||||
literal("autoprefix")
|
|
||||||
.then(
|
|
||||||
argument("prefix", greedyString())
|
|
||||||
.executes(AutoPrefixCommand::execute)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int execute (final CommandContext<FabricClientCommandSource> context) {
|
|
||||||
final FabricClientCommandSource source = context.getSource();
|
|
||||||
|
|
||||||
final String prefix = getString(context, "prefix");
|
|
||||||
|
|
||||||
SelfCare.INSTANCE.targetPrefix = prefix;
|
|
||||||
|
|
||||||
if (prefix.equalsIgnoreCase("off")) {
|
|
||||||
source.sendFeedback(Component.literal("Successfully disabled auto prefix"));
|
|
||||||
} else {
|
|
||||||
SelfCare.INSTANCE.hasPrefix = false;
|
|
||||||
source.sendFeedback(Component.literal("Set your prefix to: " + prefix));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Command.SINGLE_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -30,7 +30,7 @@ public class AutoSkinCommand {
|
||||||
|
|
||||||
SelfCare.INSTANCE.targetSkin = username;
|
SelfCare.INSTANCE.targetSkin = username;
|
||||||
|
|
||||||
if (username.equalsIgnoreCase("off")) {
|
if (username.equals("off")) {
|
||||||
source.sendFeedback(Component.literal("Successfully disabled auto skin"));
|
source.sendFeedback(Component.literal("Successfully disabled auto skin"));
|
||||||
} else {
|
} else {
|
||||||
SelfCare.INSTANCE.hasSkin = false;
|
SelfCare.INSTANCE.hasSkin = false;
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,5 @@ public final class ChipmunkModMigrations extends AbstractMigrationManager {
|
||||||
this.register(new MigrationV2());
|
this.register(new MigrationV2());
|
||||||
this.register(new MigrationV3());
|
this.register(new MigrationV3());
|
||||||
this.register(new MigrationV4());
|
this.register(new MigrationV4());
|
||||||
this.register(new MigrationV5());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ public class Configuration {
|
||||||
public CustomChat customChat = new CustomChat();
|
public CustomChat customChat = new CustomChat();
|
||||||
public SelfCare selfCare = new SelfCare();
|
public SelfCare selfCare = new SelfCare();
|
||||||
public String autoSkinUsername = "off";
|
public String autoSkinUsername = "off";
|
||||||
public String autoPrefix = "off";
|
|
||||||
|
|
||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public static class CommandManager {
|
public static class CommandManager {
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
package land.chipmunk.chipmunkmod.config.migrations;
|
|
||||||
|
|
||||||
import land.chipmunk.chipmunkmod.config.migration.ConfigMigration;
|
|
||||||
import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
|
||||||
import org.spongepowered.configurate.transformation.TransformAction;
|
|
||||||
|
|
||||||
import static org.spongepowered.configurate.NodePath.path;
|
|
||||||
|
|
||||||
public final class MigrationV5 implements ConfigMigration {
|
|
||||||
@Override
|
|
||||||
public int version () {
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConfigurationTransformation create () {
|
|
||||||
return ConfigurationTransformation.builder()
|
|
||||||
.addAction(path("autoPrefix"), TransformAction.set(String.class, () -> "off"))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -181,7 +181,7 @@ public class CommandCore implements Listener {
|
||||||
if (world == null || noPos == null) return;
|
if (world == null || noPos == null) return;
|
||||||
|
|
||||||
// also delete the old core
|
// also delete the old core
|
||||||
if (withPos != null && !isSingleBlock) {
|
if (withPos != null) {
|
||||||
pendingCommands.add(
|
pendingCommands.add(
|
||||||
String.format(
|
String.format(
|
||||||
"fill %d %d %d %d %d %d air",
|
"fill %d %d %d %d %d %d air",
|
||||||
|
|
@ -246,7 +246,7 @@ public class CommandCore implements Listener {
|
||||||
if (player == null || connection == null) return;
|
if (player == null || connection == null) return;
|
||||||
|
|
||||||
final int distanceSquared = player.chunkPosition().distanceSquared(new ChunkPos(origin));
|
final int distanceSquared = player.chunkPosition().distanceSquared(new ChunkPos(origin));
|
||||||
final int distance = (int) Math.sqrt(Math.abs(distanceSquared));
|
final int distance = (int) Math.sqrt(distanceSquared);
|
||||||
|
|
||||||
final int simulationDistance = connection.getLevel().getServerSimulationDistance();
|
final int simulationDistance = connection.getLevel().getServerSimulationDistance();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,16 +28,12 @@ public class SelfCare implements Listener {
|
||||||
public String targetSkin;
|
public String targetSkin;
|
||||||
public boolean hasSkin = false;
|
public boolean hasSkin = false;
|
||||||
|
|
||||||
public String targetPrefix;
|
|
||||||
public boolean hasPrefix = false;
|
|
||||||
|
|
||||||
private boolean isCommandSpyEnabled = false;
|
private boolean isCommandSpyEnabled = false;
|
||||||
|
|
||||||
public SelfCare (final Minecraft client) {
|
public SelfCare (final Minecraft client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
|
||||||
this.targetSkin = ChipmunkMod.CONFIG.autoSkinUsername == null ? "off" : ChipmunkMod.CONFIG.autoSkinUsername;
|
this.targetSkin = ChipmunkMod.CONFIG.autoSkinUsername == null ? "off" : ChipmunkMod.CONFIG.autoSkinUsername;
|
||||||
this.targetPrefix = ChipmunkMod.CONFIG.autoPrefix == null ? "off" : ChipmunkMod.CONFIG.autoPrefix;
|
|
||||||
|
|
||||||
ListenerManager.addListener(this);
|
ListenerManager.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
@ -47,7 +43,6 @@ public class SelfCare implements Listener {
|
||||||
|
|
||||||
public void cleanup () {
|
public void cleanup () {
|
||||||
hasSkin = false;
|
hasSkin = false;
|
||||||
hasPrefix = false;
|
|
||||||
isCommandSpyEnabled = false;
|
isCommandSpyEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,18 +55,9 @@ public class SelfCare implements Listener {
|
||||||
|
|
||||||
else if (stringMessage.equals("Successfully set your skin to " + targetSkin + "'s")) hasSkin = true;
|
else if (stringMessage.equals("Successfully set your skin to " + targetSkin + "'s")) hasSkin = true;
|
||||||
else if (
|
else if (
|
||||||
stringMessage.equals("Successfully removed your skin")
|
stringMessage.equals("Successfully removed your skin") ||
|
||||||
|| stringMessage.startsWith("Successfully set your skin to ")
|
stringMessage.startsWith("Successfully set your skin to ")
|
||||||
) hasSkin = false;
|
) hasSkin = false;
|
||||||
|
|
||||||
else if (
|
|
||||||
stringMessage.equals("You now have the tag: " + targetPrefix)
|
|
||||||
|| stringMessage.equals("Something went wrong while saving the prefix. Please check console.")
|
|
||||||
) hasPrefix = true;
|
|
||||||
else if (
|
|
||||||
stringMessage.startsWith("You no longer have a tag")
|
|
||||||
|| stringMessage.startsWith("You now have the tag: ")
|
|
||||||
) hasPrefix = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -92,8 +78,7 @@ public class SelfCare implements Listener {
|
||||||
networkHandler.send(new ServerboundChangeGameModePacket(targetGameMode));
|
networkHandler.send(new ServerboundChangeGameModePacket(targetGameMode));
|
||||||
} else if (!isCommandSpyEnabled && configCommandSpyEnabled && serverHasCommand("c")) {
|
} else if (!isCommandSpyEnabled && configCommandSpyEnabled && serverHasCommand("c")) {
|
||||||
if (
|
if (
|
||||||
CommandCore.INSTANCE.isSingleBlock
|
!CommandCore.INSTANCE.ready
|
||||||
|| !CommandCore.INSTANCE.ready
|
|
||||||
|| !CommandCore.INSTANCE.runFillCommand
|
|| !CommandCore.INSTANCE.runFillCommand
|
||||||
|| !player.canUseGameMasterBlocks()
|
|| !player.canUseGameMasterBlocks()
|
||||||
) {
|
) {
|
||||||
|
|
@ -101,10 +86,8 @@ public class SelfCare implements Listener {
|
||||||
} else {
|
} else {
|
||||||
CommandCore.INSTANCE.run("c " + player.getStringUUID() + " on");
|
CommandCore.INSTANCE.run("c " + player.getStringUUID() + " on");
|
||||||
}
|
}
|
||||||
} else if (!hasSkin && serverHasCommand("skin") && !targetSkin.equalsIgnoreCase("off")) {
|
} else if (!hasSkin && !targetSkin.equalsIgnoreCase("off")) {
|
||||||
networkHandler.sendCommand("skin " + targetSkin);
|
networkHandler.sendCommand("skin " + targetSkin);
|
||||||
} else if (!hasPrefix && serverHasCommand("prefix") && !targetPrefix.equalsIgnoreCase("off")) {
|
|
||||||
networkHandler.sendCommand("prefix " + targetPrefix);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue