mirror of
https://code.chipmunk.land/ChomeNS/chipmunkmod.git
synced 2025-11-13 21:06:16 +00:00
Compare commits
2 commits
b613c10565
...
03eb3c84f6
| Author | SHA1 | Date | |
|---|---|---|---|
| 03eb3c84f6 | |||
| 8dcd2257f3 |
5 changed files with 41 additions and 13 deletions
|
|
@ -1,10 +1,7 @@
|
||||||
package land.chipmunk.chipmunkmod.config;
|
package land.chipmunk.chipmunkmod.config;
|
||||||
|
|
||||||
import land.chipmunk.chipmunkmod.config.migration.AbstractMigrationManager;
|
import land.chipmunk.chipmunkmod.config.migration.AbstractMigrationManager;
|
||||||
import land.chipmunk.chipmunkmod.config.migrations.MigrationV0;
|
import land.chipmunk.chipmunkmod.config.migrations.*;
|
||||||
import land.chipmunk.chipmunkmod.config.migrations.MigrationV1;
|
|
||||||
import land.chipmunk.chipmunkmod.config.migrations.MigrationV2;
|
|
||||||
import land.chipmunk.chipmunkmod.config.migrations.MigrationV3;
|
|
||||||
|
|
||||||
public final class ChipmunkModMigrations extends AbstractMigrationManager {
|
public final class ChipmunkModMigrations extends AbstractMigrationManager {
|
||||||
public ChipmunkModMigrations () {
|
public ChipmunkModMigrations () {
|
||||||
|
|
@ -14,5 +11,6 @@ public final class ChipmunkModMigrations extends AbstractMigrationManager {
|
||||||
this.register(new MigrationV1());
|
this.register(new MigrationV1());
|
||||||
this.register(new MigrationV2());
|
this.register(new MigrationV2());
|
||||||
this.register(new MigrationV3());
|
this.register(new MigrationV3());
|
||||||
|
this.register(new MigrationV4());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ public class Configuration {
|
||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public static class CommandCore {
|
public static class CommandCore {
|
||||||
public BlockBox relativeArea = BlockBox.create(new BlockPos(0, 0, 0), new BlockPos(15, 0, 15));
|
public BlockBox relativeArea = BlockBox.create(new BlockPos(0, 0, 0), new BlockPos(15, 0, 15));
|
||||||
|
public boolean logCommands = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -73,18 +73,21 @@ public abstract class ChatScreenMixin {
|
||||||
ChipmunkMod.LOGGER.error("Error while trying to request TestBot webhook", e);
|
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<ChomeNSBotCommand> commands = ChomeNSBotCommandSuggestions.INSTANCE.commands;
|
||||||
|
|
||||||
final List<String> moreOrTrustedCommands = commands.stream()
|
final List<String> moreOrTrustedCommands = new ArrayList<>();
|
||||||
.filter(command -> command.trustLevel() != ChomeNSBotCommand.TrustLevel.PUBLIC)
|
final List<String> ownerCommands = new ArrayList<>();
|
||||||
.map(command -> command.name().toLowerCase())
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
final List<String> aliases = new ArrayList<>();
|
final List<String> aliases = new ArrayList<>();
|
||||||
|
|
||||||
for (final ChomeNSBotCommand command : commands) {
|
for (final ChomeNSBotCommand command : commands) {
|
||||||
if (command.trustLevel() == ChomeNSBotCommand.TrustLevel.PUBLIC) continue;
|
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());
|
aliases.addAll(command.aliases());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,8 +96,13 @@ public abstract class ChatScreenMixin {
|
||||||
final int prefixLength = ChipmunkMod.CONFIG.bots.chomens.prefix.length();
|
final int prefixLength = ChipmunkMod.CONFIG.bots.chomens.prefix.length();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
moreOrTrustedCommands.contains(chatCommand) ||
|
ownerCommands.contains(chatCommand) ||
|
||||||
aliases.contains(chatCommand.substring(prefixLength))
|
(ChipmunkMod.CONFIG.bots.chomens.autoValidate &&
|
||||||
|
(
|
||||||
|
moreOrTrustedCommands.contains(chatCommand)
|
||||||
|
|| aliases.contains(chatCommand.substring(prefixLength))
|
||||||
|
)
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
BotValidationUtilities.chomens(chatText.substring(prefixLength));
|
BotValidationUtilities.chomens(chatText.substring(prefixLength));
|
||||||
|
|
|
||||||
|
|
@ -244,7 +244,7 @@ public class CommandCore implements Listener {
|
||||||
|
|
||||||
if (block == null) return;
|
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) {
|
if (KaboomCheck.INSTANCE.isKaboom) {
|
||||||
connection.send(
|
connection.send(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue