diff --git a/README.md b/README.md index 8666d04..7182a16 100644 --- a/README.md +++ b/README.md @@ -101,9 +101,9 @@ The config file can be found in `/config/htm_config.json`. (is set to true by default, meaning copper golems can take items from or put items into locked containers) -`auto_locking_containers`: List of containers which will be set to PRIVATE by default +`auto_locking_containers`: Map of containers which will be automatically locked - (add or remove blocks to the list to lock them by default, or not, block tags can also be used). + (add or remove blocks to the map to lock them by default, or not, block tags can also be used). An example config file, with custom flag overrides for copper golems: @@ -124,16 +124,16 @@ An example config file, with custom flag overrides for copper golems: "copper_golems": false } }, - "auto_locking_containers": [ - "minecraft:chest", - "minecraft:trapped_chest", - "minecraft:barrel", - "minecraft:furnace", - "minecraft:blast_furnace", - "minecraft:smoker", - "#minecraft:shulker_boxes", - "#minecraft:copper_chests" - ] + "auto_locking_containers": { + "minecraft:chest": "private", + "minecraft:trapped_chest": "private", + "minecraft:blast_furnace": "private", + "minecraft:barrel": "private", + "minecraft:smoker": "private", + "minecraft:furnace": "private", + "#minecraft:copper_chests": "public", + "#minecraft:shulker_boxes": "public" + } } ``` diff --git a/gradle.properties b/gradle.properties index 9003c93..950e2c1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ minecraft_version=1.21.11 loader_version=0.18.2 # Mod Properties -mod_version=1.2.1 +mod_version=1.2.2 maven_group=us.potatoboy archives_base_name=htm diff --git a/src/main/java/com/github/fabricservertools/htm/HTM.java b/src/main/java/com/github/fabricservertools/htm/HTM.java index d29b4cc..1192068 100644 --- a/src/main/java/com/github/fabricservertools/htm/HTM.java +++ b/src/main/java/com/github/fabricservertools/htm/HTM.java @@ -2,16 +2,13 @@ import com.github.fabricservertools.htm.api.Lock; import com.github.fabricservertools.htm.command.HTMCommand; -import com.github.fabricservertools.htm.command.subcommands.*; import com.github.fabricservertools.htm.config.HTMConfig; import com.github.fabricservertools.htm.interactions.InteractionManager; import com.github.fabricservertools.htm.listeners.PlayerEventListener; import com.github.fabricservertools.htm.listeners.LevelEventListener; -import com.mojang.brigadier.CommandDispatcher; import eu.pb4.common.protection.api.CommonProtection; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; -import net.minecraft.commands.CommandSourceStack; import net.minecraft.resources.Identifier; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -26,23 +23,11 @@ public void onInitialize() { Lock.bootstrap(); HTMConfig.load(); - CommandRegistrationCallback.EVENT.register(((dispatcher, environment, registryAccess) -> registerCommands(dispatcher))); + HTMCommand.bootstrap(); + CommandRegistrationCallback.EVENT.register(((dispatcher, buildContext, selection) -> HTMCommand.register(dispatcher))); CommonProtection.register(Identifier.fromNamespaceAndPath("htm", "containers"), new InteractionManager()); PlayerEventListener.init(); LevelEventListener.init(); } - - private void registerCommands(CommandDispatcher dispatcher) { - HTMCommand.registerSubCommand(new SetCommand()); - HTMCommand.registerSubCommand(new RemoveCommand()); - HTMCommand.registerSubCommand(new TrustCommand()); - HTMCommand.registerSubCommand(new UntrustCommand()); - HTMCommand.registerSubCommand(new InfoCommand()); - HTMCommand.registerSubCommand(new TransferCommand()); - HTMCommand.registerSubCommand(new FlagCommand()); - HTMCommand.registerSubCommand(new PersistCommand()); - HTMCommand.registerSubCommand(new QuietCommand()); - HTMCommand.register(dispatcher); - } } diff --git a/src/main/java/com/github/fabricservertools/htm/command/HTMCommand.java b/src/main/java/com/github/fabricservertools/htm/command/HTMCommand.java index 2bd16c4..496b4f3 100644 --- a/src/main/java/com/github/fabricservertools/htm/command/HTMCommand.java +++ b/src/main/java/com/github/fabricservertools/htm/command/HTMCommand.java @@ -1,5 +1,14 @@ package com.github.fabricservertools.htm.command; +import com.github.fabricservertools.htm.command.subcommands.FlagCommand; +import com.github.fabricservertools.htm.command.subcommands.InfoCommand; +import com.github.fabricservertools.htm.command.subcommands.PersistCommand; +import com.github.fabricservertools.htm.command.subcommands.QuietCommand; +import com.github.fabricservertools.htm.command.subcommands.RemoveCommand; +import com.github.fabricservertools.htm.command.subcommands.SetCommand; +import com.github.fabricservertools.htm.command.subcommands.TransferCommand; +import com.github.fabricservertools.htm.command.subcommands.TrustCommand; +import com.github.fabricservertools.htm.command.subcommands.UntrustCommand; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import me.lucko.fabric.api.permissions.v0.Permissions; @@ -29,4 +38,16 @@ public static void registerSubCommand(SubCommand subCommand) { } SUB_COMMANDS.add(subCommand); } + + public static void bootstrap() { + registerSubCommand(new SetCommand()); + registerSubCommand(new RemoveCommand()); + registerSubCommand(new TrustCommand()); + registerSubCommand(new UntrustCommand()); + registerSubCommand(new InfoCommand()); + registerSubCommand(new TransferCommand()); + registerSubCommand(new FlagCommand()); + registerSubCommand(new PersistCommand()); + registerSubCommand(new QuietCommand()); + } }