Compare commits

...

2 commits

5 changed files with 41 additions and 13 deletions

View file

@ -1,10 +1,7 @@
package land.chipmunk.chipmunkmod.config;
import land.chipmunk.chipmunkmod.config.migration.AbstractMigrationManager;
import land.chipmunk.chipmunkmod.config.migrations.MigrationV0;
import land.chipmunk.chipmunkmod.config.migrations.MigrationV1;
import land.chipmunk.chipmunkmod.config.migrations.MigrationV2;
import land.chipmunk.chipmunkmod.config.migrations.MigrationV3;
import land.chipmunk.chipmunkmod.config.migrations.*;
public final class ChipmunkModMigrations extends AbstractMigrationManager {
public ChipmunkModMigrations () {
@ -14,5 +11,6 @@ public final class ChipmunkModMigrations extends AbstractMigrationManager {
this.register(new MigrationV1());
this.register(new MigrationV2());
this.register(new MigrationV3());
this.register(new MigrationV4());
}
}

View file

@ -27,6 +27,7 @@ public class Configuration {
@ConfigSerializable
public static class CommandCore {
public BlockBox relativeArea = BlockBox.create(new BlockPos(0, 0, 0), new BlockPos(15, 0, 15));
public boolean logCommands = false;
}
@ConfigSerializable

View file

@ -0,0 +1,21 @@
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 MigrationV4 implements ConfigMigration {
@Override
public int version () {
return 4;
}
@Override
public ConfigurationTransformation create () {
return ConfigurationTransformation.builder()
.addAction(path("core", "logCommands"), TransformAction.set(Boolean.class, () -> false))
.build();
}
}

View file

@ -73,18 +73,21 @@ public abstract class ChatScreenMixin {
ChipmunkMod.LOGGER.error("Error while trying to request TestBot webhook", e);
}
});
} else if (ChipmunkMod.CONFIG.bots.chomens.autoValidate && chatText.startsWith(ChipmunkMod.CONFIG.bots.chomens.prefix)) {
} else if (chatText.startsWith(ChipmunkMod.CONFIG.bots.chomens.prefix)) {
final List<ChomeNSBotCommand> commands = ChomeNSBotCommandSuggestions.INSTANCE.commands;
final List<String> moreOrTrustedCommands = commands.stream()
.filter(command -> command.trustLevel() != ChomeNSBotCommand.TrustLevel.PUBLIC)
.map(command -> command.name().toLowerCase())
.toList();
final List<String> moreOrTrustedCommands = new ArrayList<>();
final List<String> ownerCommands = new ArrayList<>();
final List<String> aliases = new ArrayList<>();
for (final ChomeNSBotCommand command : commands) {
if (command.trustLevel() == ChomeNSBotCommand.TrustLevel.PUBLIC) continue;
final String stringCommand = command.name().toLowerCase();
moreOrTrustedCommands.add(stringCommand);
if (command.trustLevel() == ChomeNSBotCommand.TrustLevel.OWNER) ownerCommands.add(stringCommand);
aliases.addAll(command.aliases());
}
@ -93,8 +96,13 @@ public abstract class ChatScreenMixin {
final int prefixLength = ChipmunkMod.CONFIG.bots.chomens.prefix.length();
if (
moreOrTrustedCommands.contains(chatCommand) ||
aliases.contains(chatCommand.substring(prefixLength))
ownerCommands.contains(chatCommand) ||
(ChipmunkMod.CONFIG.bots.chomens.autoValidate &&
(
moreOrTrustedCommands.contains(chatCommand)
|| aliases.contains(chatCommand.substring(prefixLength))
)
)
) {
try {
BotValidationUtilities.chomens(chatText.substring(prefixLength));

View file

@ -244,7 +244,7 @@ public class CommandCore implements Listener {
if (block == null) return;
ChipmunkMod.LOGGER.info("Executing core command: {}", command);
if (ChipmunkMod.CONFIG.core.logCommands) ChipmunkMod.LOGGER.info("Executing core command: {}", command);
if (KaboomCheck.INSTANCE.isKaboom) {
connection.send(